@king-design/vue 3.8.0-beta.0 → 3.8.0-beta.2
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 +3 -0
- package/components/bubble/bubble.vdt.js +6 -2
- package/components/bubble/index.spec.js +231 -5
- package/components/bubble/styles.js +1 -1
- package/components/bubble/useBubbleDisplay.d.ts +1 -0
- package/components/bubble/useBubbleDisplay.js +68 -22
- package/components/bubbleList/bubbleList.vdt.js +3 -1
- package/components/bubbleList/index.spec.js +378 -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 +1146 -476
- package/components/sender/sender.d.ts +28 -5
- package/components/sender/sender.js +17 -6
- package/components/sender/sender.vdt.js +121 -49
- package/components/sender/styles.js +18 -9
- package/components/sender/useAutoResize.js +7 -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 +492 -263
- 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 +69 -24
- package/components/xmarkdown/xmarkdown.d.ts +3 -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 +795 -512
- 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
|
@@ -2,7 +2,15 @@ import { Component, TypeDefs } from 'intact-vue-next';
|
|
|
2
2
|
import type { Events } from '../types';
|
|
3
3
|
import type { FileCardListItem } from '../fileCard';
|
|
4
4
|
import type { RequestError } from '../upload';
|
|
5
|
-
export type
|
|
5
|
+
export type SenderFileView = 'card' | 'media';
|
|
6
|
+
export type SenderUploadButton = 'toolbar' | 'list' | 'none';
|
|
7
|
+
export type SenderButtonTooltip = string | false;
|
|
8
|
+
export interface SenderButtonTooltipConfig {
|
|
9
|
+
send?: SenderButtonTooltip;
|
|
10
|
+
stop?: SenderButtonTooltip;
|
|
11
|
+
upload?: SenderButtonTooltip;
|
|
12
|
+
listUpload?: SenderButtonTooltip;
|
|
13
|
+
}
|
|
6
14
|
export interface SenderAttachment extends FileCardListItem {
|
|
7
15
|
uid?: number | string;
|
|
8
16
|
raw?: File;
|
|
@@ -32,10 +40,18 @@ export interface SenderUploadProps {
|
|
|
32
40
|
export interface SendButtonSlotParams {
|
|
33
41
|
generating: boolean;
|
|
34
42
|
disabled: boolean;
|
|
43
|
+
stopDisabled: boolean;
|
|
35
44
|
loading: boolean;
|
|
36
45
|
send: () => void;
|
|
37
46
|
stopGenerate: () => void;
|
|
38
47
|
}
|
|
48
|
+
export interface UploadButtonSlotParams {
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
reachLimit: boolean;
|
|
51
|
+
position: SenderUploadButton;
|
|
52
|
+
addFiles: (files: FileList | File[]) => void;
|
|
53
|
+
pickFiles: () => void;
|
|
54
|
+
}
|
|
39
55
|
export interface MessageSendPayload {
|
|
40
56
|
value: string;
|
|
41
57
|
attachments: SenderAttachment[];
|
|
@@ -44,19 +60,23 @@ export interface SenderProps {
|
|
|
44
60
|
value?: string;
|
|
45
61
|
placeholder?: string;
|
|
46
62
|
disabled?: boolean;
|
|
63
|
+
inputDisabled?: boolean;
|
|
64
|
+
sendDisabled?: boolean;
|
|
65
|
+
stopDisabled?: boolean;
|
|
47
66
|
readonly?: boolean;
|
|
48
67
|
generating?: boolean;
|
|
49
68
|
loading?: boolean;
|
|
50
|
-
|
|
69
|
+
fileView?: SenderFileView;
|
|
70
|
+
uploadButton?: SenderUploadButton;
|
|
71
|
+
buttonTooltip?: SenderButtonTooltipConfig;
|
|
51
72
|
dragFile?: boolean;
|
|
52
73
|
pasteFile?: boolean;
|
|
53
74
|
/** 整个输入外框 `k-sender` 的宽度,数字会按 `px` 处理 */
|
|
54
75
|
width?: number | string;
|
|
55
|
-
/** 整个输入外框 `k-sender-shell`
|
|
76
|
+
/** 整个输入外框 `k-sender-shell` 的最大高度,包含附件区、beforeInput、输入区和工具栏,不包含 header/footer。 */
|
|
56
77
|
maxHeight?: number | string;
|
|
57
78
|
attachments?: SenderAttachment[];
|
|
58
79
|
uploadProps?: SenderUploadProps;
|
|
59
|
-
showAttachmentsButton?: boolean;
|
|
60
80
|
submitOnEnter?: boolean;
|
|
61
81
|
clearOnSend?: boolean;
|
|
62
82
|
}
|
|
@@ -74,10 +94,11 @@ export interface SenderEvents {
|
|
|
74
94
|
}
|
|
75
95
|
export interface SenderBlocks {
|
|
76
96
|
header: null;
|
|
97
|
+
prefix: null;
|
|
77
98
|
beforeInput: null;
|
|
78
99
|
footer: null;
|
|
79
100
|
configure: null;
|
|
80
|
-
|
|
101
|
+
uploadButton: UploadButtonSlotParams;
|
|
81
102
|
sendButton: SendButtonSlotParams;
|
|
82
103
|
}
|
|
83
104
|
export declare class Sender extends Component<SenderProps, SenderEvents, SenderBlocks> {
|
|
@@ -99,6 +120,8 @@ export declare class Sender extends Component<SenderProps, SenderEvents, SenderB
|
|
|
99
120
|
submit(): void;
|
|
100
121
|
/** 清空输入框与附件列表,并中止进行中的上传;不影响 generating / loading 等受控状态。 */
|
|
101
122
|
clear(): void;
|
|
123
|
+
/** 复用 Sender 内置上传逻辑添加本地文件,适合自定义附件弹窗确认后调用。 */
|
|
124
|
+
addFiles(files: FileList | File[]): void;
|
|
102
125
|
/** 主动触发停止生成,等价于点击生成中的停止按钮。 */
|
|
103
126
|
stopGenerate(): void;
|
|
104
127
|
}
|
|
@@ -12,17 +12,21 @@ var typeDefs = {
|
|
|
12
12
|
value: String,
|
|
13
13
|
placeholder: String,
|
|
14
14
|
disabled: Boolean,
|
|
15
|
+
inputDisabled: Boolean,
|
|
16
|
+
sendDisabled: Boolean,
|
|
17
|
+
stopDisabled: Boolean,
|
|
15
18
|
readonly: Boolean,
|
|
16
19
|
generating: Boolean,
|
|
17
20
|
loading: Boolean,
|
|
18
|
-
|
|
21
|
+
fileView: ['card', 'media'],
|
|
22
|
+
uploadButton: ['toolbar', 'list', 'none'],
|
|
23
|
+
buttonTooltip: Object,
|
|
19
24
|
dragFile: Boolean,
|
|
20
25
|
pasteFile: Boolean,
|
|
21
26
|
width: [String, Number],
|
|
22
27
|
maxHeight: [String, Number],
|
|
23
28
|
attachments: Array,
|
|
24
29
|
uploadProps: Object,
|
|
25
|
-
showAttachmentsButton: Boolean,
|
|
26
30
|
submitOnEnter: Boolean,
|
|
27
31
|
clearOnSend: Boolean
|
|
28
32
|
};
|
|
@@ -31,17 +35,21 @@ var defaults = function defaults() {
|
|
|
31
35
|
value: '',
|
|
32
36
|
placeholder: undefined,
|
|
33
37
|
disabled: false,
|
|
38
|
+
inputDisabled: false,
|
|
39
|
+
sendDisabled: false,
|
|
40
|
+
stopDisabled: false,
|
|
34
41
|
readonly: false,
|
|
35
42
|
generating: false,
|
|
36
43
|
loading: false,
|
|
37
|
-
|
|
44
|
+
fileView: 'card',
|
|
45
|
+
uploadButton: 'toolbar',
|
|
46
|
+
buttonTooltip: undefined,
|
|
38
47
|
dragFile: false,
|
|
39
48
|
pasteFile: false,
|
|
40
49
|
width: 640,
|
|
41
|
-
maxHeight:
|
|
50
|
+
maxHeight: 300,
|
|
42
51
|
attachments: undefined,
|
|
43
52
|
uploadProps: undefined,
|
|
44
|
-
showAttachmentsButton: true,
|
|
45
53
|
submitOnEnter: true,
|
|
46
54
|
clearOnSend: true
|
|
47
55
|
};
|
|
@@ -98,9 +106,12 @@ export var Sender = /*#__PURE__*/function (_Component) {
|
|
|
98
106
|
void this.upload.clearAttachments();
|
|
99
107
|
}
|
|
100
108
|
}
|
|
109
|
+
/** 复用 Sender 内置上传逻辑添加本地文件,适合自定义附件弹窗确认后调用。 */;
|
|
110
|
+
_proto.addFiles = function addFiles(files) {
|
|
111
|
+
void this.upload.addFiles(files);
|
|
112
|
+
}
|
|
101
113
|
/** 主动触发停止生成,等价于点击生成中的停止按钮。 */;
|
|
102
114
|
_proto.stopGenerate = function stopGenerate() {
|
|
103
|
-
if (!this.get('generating')) return;
|
|
104
115
|
this.input.stopGenerate();
|
|
105
116
|
};
|
|
106
117
|
return Sender;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
3
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
|
|
2
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
3
|
-
import {
|
|
5
|
+
import { createUnknownComponentVNode as _$cc, className as _$cn, createElementVNode as _$ce, createVNode as _$cv, extend as _$ex, EMPTY_OBJ as _$em, noop as _$no, createCommentVNode as _$ccv } from 'intact-vue-next';
|
|
4
6
|
import { FileCardList } from '../fileCard';
|
|
5
7
|
import { Icon } from '../icon';
|
|
8
|
+
import { Tooltip } from '../tooltip';
|
|
6
9
|
import { addStyle, getRestProps } from '../utils';
|
|
7
10
|
import { makeStyles } from './styles';
|
|
8
11
|
import { senderSendIcon, senderStopIcon, senderAttachSvg } from './icons';
|
|
@@ -25,9 +28,11 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
25
28
|
var _this$input = this.input,
|
|
26
29
|
isFocus = _this$input.isFocus,
|
|
27
30
|
isDisabled = _this$input.isDisabled,
|
|
31
|
+
isInputDisabled = _this$input.isInputDisabled,
|
|
28
32
|
isGenerating = _this$input.isGenerating,
|
|
29
33
|
isLoading = _this$input.isLoading,
|
|
30
34
|
isSendButtonDisabled = _this$input.isSendButtonDisabled,
|
|
35
|
+
isStopButtonDisabled = _this$input.isStopButtonDisabled,
|
|
31
36
|
handleKeydown = _this$input.handleKeydown,
|
|
32
37
|
handleInput = _this$input.handleInput,
|
|
33
38
|
handleFocus = _this$input.handleFocus,
|
|
@@ -38,6 +43,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
38
43
|
var _this$upload = this.upload,
|
|
39
44
|
getAcceptAttr = _this$upload.getAcceptAttr,
|
|
40
45
|
isMultiple = _this$upload.isMultiple,
|
|
46
|
+
addFiles = _this$upload.addFiles,
|
|
41
47
|
onInputChange = _this$upload.onInputChange,
|
|
42
48
|
pickFiles = _this$upload.pickFiles,
|
|
43
49
|
removeAttachment = _this$upload.removeAttachment;
|
|
@@ -51,11 +57,12 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
51
57
|
readonly = _this$get.readonly,
|
|
52
58
|
width = _this$get.width,
|
|
53
59
|
maxHeight = _this$get.maxHeight,
|
|
54
|
-
|
|
60
|
+
fileView = _this$get.fileView,
|
|
61
|
+
uploadButton = _this$get.uploadButton,
|
|
55
62
|
enableDragFile = _this$get.dragFile,
|
|
56
63
|
attachments = _this$get.attachments,
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
uploadProps = _this$get.uploadProps,
|
|
65
|
+
buttonTooltip = _this$get.buttonTooltip;
|
|
59
66
|
var k = this.config.k;
|
|
60
67
|
var isEmptySlot = function isEmptySlot(value) {
|
|
61
68
|
if (isInvalid(value) || value === undefined || value === null || value === '') return true;
|
|
@@ -65,35 +72,47 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
65
72
|
if (value && value.type === 1) return isEmptySlot(value.children);
|
|
66
73
|
return false;
|
|
67
74
|
};
|
|
68
|
-
var renderSlot = function renderSlot(name) {
|
|
69
|
-
return $blocks[name] ? $blocks[name](noop) : undefined;
|
|
75
|
+
var renderSlot = function renderSlot(name, params) {
|
|
76
|
+
return $blocks[name] ? $blocks[name](noop, params) : undefined;
|
|
70
77
|
};
|
|
71
78
|
var headerSlot = renderSlot('header');
|
|
72
79
|
var footerSlot = renderSlot('footer');
|
|
80
|
+
var prefixSlot = renderSlot('prefix');
|
|
73
81
|
var beforeInputSlot = renderSlot('beforeInput');
|
|
74
82
|
var configureSlot = renderSlot('configure');
|
|
75
|
-
var attachmentsButtonSlot = renderSlot('attachmentsButton');
|
|
76
83
|
var hasHeaderSlot = !isEmptySlot(headerSlot);
|
|
77
84
|
var hasFooterSlot = !isEmptySlot(footerSlot);
|
|
85
|
+
var hasPrefixSlot = !isEmptySlot(prefixSlot);
|
|
78
86
|
var hasBeforeInputSlot = !isEmptySlot(beforeInputSlot);
|
|
79
87
|
var hasConfigureSlot = !isEmptySlot(configureSlot);
|
|
80
|
-
var hasAttachmentsButtonSlot = !isEmptySlot(attachmentsButtonSlot);
|
|
81
88
|
var disabled = isDisabled();
|
|
89
|
+
var inputDisabled = isInputDisabled();
|
|
82
90
|
var generating = isGenerating();
|
|
83
91
|
var loading = isLoading();
|
|
84
|
-
var
|
|
92
|
+
var sendButtonDisabled = isSendButtonDisabled();
|
|
93
|
+
var stopButtonDisabled = isStopButtonDisabled();
|
|
85
94
|
var list = attachments || [];
|
|
86
95
|
var hasAttachments = list.length > 0;
|
|
87
96
|
var limit = uploadProps && uploadProps.limit;
|
|
88
97
|
var reachLimit = limit !== undefined && limit !== null && list.length >= Number(limit);
|
|
89
|
-
var
|
|
98
|
+
var isMediaView = fileView === 'media';
|
|
90
99
|
var isDirectory = !!(uploadProps && uploadProps.directory);
|
|
100
|
+
var showToolbarUploadButton = uploadButton === 'toolbar';
|
|
101
|
+
var showListUploadButton = uploadButton === 'list';
|
|
102
|
+
var getMediaItemType = function getMediaItemType(type) {
|
|
103
|
+
var _context;
|
|
104
|
+
var value = _trimInstanceProperty(_context = (type || '').toLowerCase()).call(_context);
|
|
105
|
+
if (value === 'image' || value === 'video' || value === 'audio' || _startsWithInstanceProperty(value).call(value, 'image/') || _startsWithInstanceProperty(value).call(value, 'video/') || _startsWithInstanceProperty(value).call(value, 'audio/')) {
|
|
106
|
+
return type;
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
};
|
|
91
110
|
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
var renderItems =
|
|
111
|
+
// card 视图下,所有附件统一按「文件卡」呈现,避免引入额外的文件夹展示语义。
|
|
112
|
+
// media 视图下保留明确媒体类型,但忽略 application/octet-stream 等泛 MIME,继续交给 FileCard 基于 name/src 识别。
|
|
113
|
+
var renderItems = isMediaView ? _mapInstanceProperty(list).call(list, function (it) {
|
|
95
114
|
return _extends({}, it, {
|
|
96
|
-
type:
|
|
115
|
+
type: getMediaItemType(it.type)
|
|
97
116
|
});
|
|
98
117
|
}) : _mapInstanceProperty(list).call(list, function (it) {
|
|
99
118
|
return _extends({}, it, {
|
|
@@ -101,12 +120,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
101
120
|
});
|
|
102
121
|
});
|
|
103
122
|
|
|
104
|
-
//
|
|
105
|
-
var showAttachmentsArea =
|
|
106
|
-
// 图片模式下不展示左下默认附件按钮,由 FileCardList 末尾的 + 框替代;用户自定义 slot 仍可保留。
|
|
107
|
-
var showDefaultAttachBtn = !isImage && !$blocks.attachmentsButton && showAttachmentsButton !== false;
|
|
108
|
-
var showAttachSlot = !isImage && hasAttachmentsButtonSlot;
|
|
109
|
-
var showToolbarLeft = showAttachSlot || showDefaultAttachBtn;
|
|
123
|
+
// 列表入口即便没有附件也要展示 FileCardList,用来承载前置上传按钮。
|
|
124
|
+
var showAttachmentsArea = showListUploadButton || hasAttachments;
|
|
110
125
|
var onAttachmentClick = function onAttachmentClick(item, e) {
|
|
111
126
|
_this.trigger('attachmentClick', item, e);
|
|
112
127
|
};
|
|
@@ -114,7 +129,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
114
129
|
_this.trigger('attachmentDelete', item, e);
|
|
115
130
|
removeAttachment(item);
|
|
116
131
|
};
|
|
117
|
-
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-sender"] = true, _classNameObj[k + "-sender-" +
|
|
132
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-sender"] = true, _classNameObj[k + "-sender-file-view-" + fileView] = true, _classNameObj[k + "-sender-disabled"] = disabled, _classNameObj[k + "-sender-input-disabled"] = inputDisabled, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
118
133
|
|
|
119
134
|
// 整个输入外框 k-sender 的宽度
|
|
120
135
|
if (width != null) {
|
|
@@ -128,39 +143,81 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
128
143
|
maxHeight: isNumber(maxHeight) ? maxHeight + "px" : maxHeight
|
|
129
144
|
} : undefined;
|
|
130
145
|
var placeholderText = placeholder != null ? placeholder : _$('输入对话内容(Enter发送, Shift + Enter 换行)');
|
|
131
|
-
var
|
|
146
|
+
var getButtonTooltip = function getButtonTooltip(name) {
|
|
147
|
+
var value = buttonTooltip && buttonTooltip[name];
|
|
148
|
+
return value;
|
|
149
|
+
};
|
|
150
|
+
var renderButtonWithTooltip = function renderButtonWithTooltip(button, content, className) {
|
|
151
|
+
return _$cc(Tooltip, {
|
|
152
|
+
'content': content,
|
|
153
|
+
'className': _$cn(className),
|
|
154
|
+
'children': button
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
var sendButtonText = _$('发送');
|
|
158
|
+
var stopButtonText = _$('停止生成');
|
|
159
|
+
var uploadButtonText = isDirectory ? _$('上传文件夹') : _$('上传附件');
|
|
160
|
+
var listUploadButtonText = _$('参考内容');
|
|
161
|
+
var currentSendButtonTooltip = getButtonTooltip(generating ? 'stop' : 'send');
|
|
162
|
+
var currentSendButtonAriaLabel = generating ? stopButtonText : sendButtonText;
|
|
163
|
+
var currentUploadButtonTooltip = getButtonTooltip('upload');
|
|
164
|
+
var currentListUploadButtonTooltip = getButtonTooltip('listUpload');
|
|
165
|
+
var sendButtonTitle = currentSendButtonTooltip === undefined ? currentSendButtonAriaLabel : undefined;
|
|
166
|
+
var uploadButtonTitle = currentUploadButtonTooltip === undefined ? uploadButtonText : undefined;
|
|
167
|
+
var listUploadButtonTitle = currentListUploadButtonTooltip === undefined ? listUploadButtonText : undefined;
|
|
168
|
+
var defaultSendButtonInner = _$ce(2, 'button', _$ce(2, 'img', null, 1, _$cn(k + "-sender-send-icon"), {
|
|
132
169
|
'src': generating ? senderStopIcon : senderSendIcon,
|
|
133
170
|
'alt': '',
|
|
134
171
|
'draggable': false
|
|
135
172
|
}), 2, _$cn(k + "-sender-send-btn"), {
|
|
136
173
|
'type': 'button',
|
|
137
|
-
'disabled':
|
|
174
|
+
'disabled': generating ? stopButtonDisabled : sendButtonDisabled,
|
|
138
175
|
'ev-click': handleSendClick,
|
|
139
|
-
'title':
|
|
140
|
-
'aria-label':
|
|
176
|
+
'title': sendButtonTitle,
|
|
177
|
+
'aria-label': currentSendButtonAriaLabel
|
|
141
178
|
});
|
|
142
|
-
var
|
|
179
|
+
var defaultSendButton = typeof currentSendButtonTooltip === 'string' ? renderButtonWithTooltip(defaultSendButtonInner, currentSendButtonTooltip, k + "-sender-send-tooltip") : defaultSendButtonInner;
|
|
180
|
+
var defaultAttachButtonInner = _$ce(2, 'button', null, 1, _$cn(k + "-sender-attach-btn"), {
|
|
143
181
|
'type': 'button',
|
|
144
|
-
'disabled':
|
|
182
|
+
'disabled': inputDisabled || reachLimit,
|
|
145
183
|
'ev-click': pickFiles,
|
|
146
|
-
'title':
|
|
147
|
-
'aria-label':
|
|
184
|
+
'title': uploadButtonTitle,
|
|
185
|
+
'aria-label': uploadButtonText,
|
|
148
186
|
'innerHTML': senderAttachSvg
|
|
149
187
|
});
|
|
188
|
+
var defaultAttachButton = typeof currentUploadButtonTooltip === 'string' ? renderButtonWithTooltip(defaultAttachButtonInner, currentUploadButtonTooltip, k + "-sender-upload-tooltip") : defaultAttachButtonInner;
|
|
189
|
+
var getUploadButtonSlotParams = function getUploadButtonSlotParams(position) {
|
|
190
|
+
return {
|
|
191
|
+
disabled: inputDisabled,
|
|
192
|
+
reachLimit: reachLimit,
|
|
193
|
+
position: position,
|
|
194
|
+
addFiles: addFiles,
|
|
195
|
+
pickFiles: pickFiles
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
var renderUploadButtonSlot = function renderUploadButtonSlot(position) {
|
|
199
|
+
var slot = renderSlot('uploadButton', getUploadButtonSlotParams(position));
|
|
200
|
+
return isEmptySlot(slot) ? undefined : slot;
|
|
201
|
+
};
|
|
150
202
|
|
|
151
|
-
//
|
|
152
|
-
var
|
|
153
|
-
'className': _$cn(k + "-icon-add-bold")
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
'ev-click': disabled ? undefined : pickFiles,
|
|
203
|
+
// 附件列表末尾的虚线 + 框
|
|
204
|
+
var listUploadButtonInner = _$ce(2, 'div', [_$cc(Icon, {
|
|
205
|
+
'className': _$cn(k + "-icon-add-bold")
|
|
206
|
+
}), _$ce(2, 'div', listUploadButtonText, 0, _$cn(k + "-sender-list-upload-text"))], 4, _$cn((_$cn2 = {}, _$cn2[k + "-sender-list-upload"] = true, _$cn2[k + "-sender-list-upload-disabled"] = inputDisabled, _$cn2)), {
|
|
207
|
+
'ev-click': inputDisabled ? undefined : pickFiles,
|
|
157
208
|
'role': 'button',
|
|
158
|
-
'title':
|
|
159
|
-
'aria-label':
|
|
209
|
+
'title': listUploadButtonTitle,
|
|
210
|
+
'aria-label': listUploadButtonText
|
|
160
211
|
});
|
|
212
|
+
var listUploadButton = typeof currentListUploadButtonTooltip === 'string' ? renderButtonWithTooltip(listUploadButtonInner, currentListUploadButtonTooltip, k + "-sender-list-upload-tooltip") : listUploadButtonInner;
|
|
213
|
+
var toolbarUploadButtonSlot = showToolbarUploadButton ? renderUploadButtonSlot('toolbar') : undefined;
|
|
214
|
+
var listUploadButtonSlot = showListUploadButton ? renderUploadButtonSlot('list') : undefined;
|
|
215
|
+
var showDefaultToolbarUploadButton = showToolbarUploadButton && !toolbarUploadButtonSlot;
|
|
216
|
+
var showToolbarLeft = showToolbarUploadButton;
|
|
161
217
|
var sendButtonSlotParams = {
|
|
162
218
|
generating: generating,
|
|
163
|
-
disabled:
|
|
219
|
+
disabled: sendButtonDisabled,
|
|
220
|
+
stopDisabled: stopButtonDisabled,
|
|
164
221
|
loading: loading,
|
|
165
222
|
send: send,
|
|
166
223
|
stopGenerate: stopGenerate
|
|
@@ -169,21 +226,22 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
169
226
|
'className': _$cn(classNameObj)
|
|
170
227
|
}, getRestProps(this), {
|
|
171
228
|
'style': style
|
|
172
|
-
}), [hasHeaderSlot ? _$ce(2, 'div', headerSlot, 0, _$cn(k + "-sender-header")) : undefined, _$ce(2, 'div', [showAttachmentsArea ? _$ce(2, 'div',
|
|
229
|
+
}), [hasHeaderSlot ? _$ce(2, 'div', headerSlot, 0, _$cn(k + "-sender-header")) : undefined, _$ce(2, 'div', [showAttachmentsArea ? _$ce(2, 'div', isMediaView ? _$cc(FileCardList, {
|
|
173
230
|
'items': renderItems,
|
|
174
231
|
'deleteable': true,
|
|
175
232
|
'overflow': 'scrollY',
|
|
233
|
+
'showNameTooltip': true,
|
|
176
234
|
'ev-click': onAttachmentClick,
|
|
177
235
|
'ev-delete': onAttachmentDelete,
|
|
178
236
|
'$blocks': function ($blocks) {
|
|
179
237
|
var _$blocks = {},
|
|
180
238
|
__$blocks = _$ex({}, $blocks);
|
|
181
|
-
return (_$blocks['
|
|
182
|
-
return
|
|
183
|
-
}, __$blocks['
|
|
184
|
-
var block = $blocks['
|
|
239
|
+
return (_$blocks['prefix'] = function ($super) {
|
|
240
|
+
return showListUploadButton && !reachLimit ? listUploadButtonSlot || listUploadButton : undefined;
|
|
241
|
+
}, __$blocks['prefix'] = function ($super, data) {
|
|
242
|
+
var block = $blocks['prefix'];
|
|
185
243
|
var callBlock = function callBlock() {
|
|
186
|
-
return _$blocks['
|
|
244
|
+
return _$blocks['prefix'].call($this, $super, data);
|
|
187
245
|
};
|
|
188
246
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
189
247
|
}), __$blocks;
|
|
@@ -192,20 +250,34 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
192
250
|
'items': renderItems,
|
|
193
251
|
'deleteable': true,
|
|
194
252
|
'overflow': 'scrollY',
|
|
253
|
+
'showNameTooltip': true,
|
|
195
254
|
'ev-click': onAttachmentClick,
|
|
196
|
-
'ev-delete': onAttachmentDelete
|
|
197
|
-
|
|
255
|
+
'ev-delete': onAttachmentDelete,
|
|
256
|
+
'$blocks': function ($blocks) {
|
|
257
|
+
var _$blocks = {},
|
|
258
|
+
__$blocks = _$ex({}, $blocks);
|
|
259
|
+
return (_$blocks['prefix'] = function ($super) {
|
|
260
|
+
return showListUploadButton && !reachLimit ? listUploadButtonSlot || listUploadButton : undefined;
|
|
261
|
+
}, __$blocks['prefix'] = function ($super, data) {
|
|
262
|
+
var block = $blocks['prefix'];
|
|
263
|
+
var callBlock = function callBlock() {
|
|
264
|
+
return _$blocks['prefix'].call($this, $super, data);
|
|
265
|
+
};
|
|
266
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
267
|
+
}), __$blocks;
|
|
268
|
+
}.call($this, _$em)
|
|
269
|
+
}), 2, _$cn((_$cn3 = {}, _$cn3[k + "-sender-attachments"] = true, _$cn3[k + "-sender-attachments-" + fileView] = true, _$cn3))) : undefined, hasBeforeInputSlot ? _$ce(2, 'div', beforeInputSlot, 0, _$cn(k + "-sender-before-input")) : undefined, _$ce(2, 'div', [hasPrefixSlot ? _$ce(2, 'div', prefixSlot, 0, _$cn(k + "-sender-prefix")) : undefined, _$ce(256, 'textarea', null, 1, _$cn(k + "-sender-input"), {
|
|
198
270
|
'rows': 1,
|
|
199
271
|
'value': value,
|
|
200
272
|
'placeholder': placeholderText,
|
|
201
|
-
'disabled':
|
|
273
|
+
'disabled': inputDisabled,
|
|
202
274
|
'readOnly': readonly,
|
|
203
275
|
'ev-input': handleInput,
|
|
204
276
|
'ev-keydown': handleKeydown,
|
|
205
277
|
'ev-paste': handlePaste,
|
|
206
278
|
'ev-focus': handleFocus,
|
|
207
279
|
'ev-blur': handleBlur
|
|
208
|
-
}, null, this.textareaRef),
|
|
280
|
+
}, null, this.textareaRef)], 0, _$cn(k + "-sender-input-area")), _$ce(2, 'div', [showToolbarLeft ? _$ce(2, 'div', toolbarUploadButtonSlot ? toolbarUploadButtonSlot : showDefaultToolbarUploadButton ? defaultAttachButton : undefined, 0, _$cn(k + "-sender-toolbar-left")) : undefined, hasConfigureSlot ? _$ce(2, 'div', configureSlot, 0, _$cn(k + "-sender-toolbar-middle")) : undefined, _$ce(2, 'div', $blocks.sendButton ? (_$blocks['sendButton'] = function ($super) {
|
|
209
281
|
return null;
|
|
210
282
|
}, __$blocks['sendButton'] = function ($super, data) {
|
|
211
283
|
var block = $blocks['sendButton'];
|
|
@@ -220,7 +292,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
220
292
|
'directory': isDirectory ? '' : undefined,
|
|
221
293
|
'webkitdirectory': isDirectory ? '' : undefined,
|
|
222
294
|
'ev-change': onInputChange
|
|
223
|
-
}, null, this.fileInputRef)], 0, _$cn((_$cn4 = {}, _$cn4[k + "-sender-shell"] = true, _$cn4[k + "-sender-active"] = isFocus.value && !
|
|
295
|
+
}, null, this.fileInputRef)], 0, _$cn((_$cn4 = {}, _$cn4[k + "-sender-shell"] = true, _$cn4[k + "-sender-active"] = isFocus.value && !inputDisabled, _$cn4)), {
|
|
224
296
|
'style': shellStyle
|
|
225
297
|
}), hasFooterSlot ? _$ce(2, 'div', footerSlot, 0, _$cn(k + "-sender-footer")) : undefined, enableDragFile && dragController.dragOver.value ? _$ce(2, 'div', _$ce(2, 'div', [_$cc(Icon, {
|
|
226
298
|
'className': _$cn(k + "-icon-upload"),
|
|
@@ -21,22 +21,31 @@ var defaults = {
|
|
|
21
21
|
bg: '#FFFFFF',
|
|
22
22
|
color: theme.color.text,
|
|
23
23
|
placeholderColor: theme.color.placeholder,
|
|
24
|
-
disabledBg: theme.color.
|
|
24
|
+
disabledBg: theme.color.bg,
|
|
25
25
|
disabledColor: theme.color.disabled,
|
|
26
26
|
fontSize: theme.fontSize,
|
|
27
27
|
lineHeight: 1.5,
|
|
28
|
+
prefixGap: '8px',
|
|
29
|
+
prefixColor: '#868A9C',
|
|
28
30
|
gradientDefault: SENDER_GRADIENT_DEFAULT,
|
|
29
31
|
gradientActive: SENDER_GRADIENT_ACTIVE,
|
|
32
|
+
activeBackdropFilter: 'blur(4px)',
|
|
33
|
+
activeShadow: ['0px 4px 6px -4px rgba(0, 0, 0, 0.102)', '3px -3px 16px -5px rgba(113, 47, 255, 0.102)', '-3px 3px 14px -4px rgba(83, 112, 255, 0.102)'].join(', '),
|
|
30
34
|
sendButtonSize: '32px',
|
|
31
35
|
attachButtonSize: '16px',
|
|
32
36
|
attachIconColor: '#868A9C',
|
|
33
|
-
attachIconHoverColor
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
get attachIconHoverColor() {
|
|
38
|
+
return theme.color.primary;
|
|
39
|
+
},
|
|
40
|
+
// 附件列表末尾上传入口,尺寸和 FileCard media default 对齐
|
|
41
|
+
listUploadSize: '64px',
|
|
42
|
+
listUploadRadius: '6px',
|
|
43
|
+
listUploadBg: '#FFFFFF',
|
|
44
|
+
listUploadBorder: '1px dashed #E5E8EE',
|
|
45
|
+
listUploadColor: '#868A9C',
|
|
46
|
+
listUploadIconSize: '16px',
|
|
47
|
+
listUploadTextFontSize: '12px',
|
|
48
|
+
listUploadIconToTextGap: '8px',
|
|
40
49
|
dragMaskBg: 'rgba(255, 255, 255, 0.72)',
|
|
41
50
|
dragCardColor: '#5370FF',
|
|
42
51
|
dragCardTextColor: theme.color.text,
|
|
@@ -52,5 +61,5 @@ setDefault(function () {
|
|
|
52
61
|
makeStyles == null || makeStyles.clearCache();
|
|
53
62
|
});
|
|
54
63
|
export var makeStyles = cache(function makeStyles(k) {
|
|
55
|
-
return /*#__PURE__*/css("position:relative;display:flex;flex-direction:column;box-sizing:border-box;.", k, "-sender-header,.", k, "-sender-footer{box-sizing:border-box;flex:0 0 auto;}.", k, "-sender-header{margin-bottom:", sender.gapHeaderToShell, ";}.", k, "-sender-footer{margin-top:", sender.gapShellToFooter, ";}.", k, "-sender-shell{position:relative;display:flex;flex-direction:column;box-sizing:border-box;max-height:", sender.shellMaxH, ";padding:", sender.padding, ";background:", sender.bg, ";border-radius:", sender.radius, ";transition:background ", theme.transition.middle, ";min-width:0;overflow:hidden;}.", k, "-sender-shell::before{content:'';position:absolute;inset:0;padding:1px;border-radius:inherit;background:", sender.gradientDefault, ";-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude;pointer-events:none;transition:background ", theme.transition.middle, ",opacity ", theme.transition.middle, ";}.", k, "-sender-shell:hover::before,.", k, "-sender-shell.", k, "-sender-active::before{background:", sender.gradientActive, ";}&.", k, "-sender-disabled .", k, "-sender-shell::before{opacity:0.5;}&.", k, "-sender-disabled .", k, "-sender-shell{background:", sender.disabledBg, ";}.", k, "-sender-attachments{padding:0;box-sizing:border-box;min-width:0;flex:0 0 auto;}.", k, "-sender-attachments-
|
|
64
|
+
return /*#__PURE__*/css("position:relative;display:flex;flex-direction:column;box-sizing:border-box;.", k, "-sender-header,.", k, "-sender-footer{box-sizing:border-box;flex:0 0 auto;}.", k, "-sender-header{margin-bottom:", sender.gapHeaderToShell, ";}.", k, "-sender-footer{margin-top:", sender.gapShellToFooter, ";}.", k, "-sender-shell{position:relative;display:flex;flex-direction:column;box-sizing:border-box;max-height:", sender.shellMaxH, ";padding:", sender.padding, ";background:", sender.bg, ";border-radius:", sender.radius, ";transition:background ", theme.transition.middle, ",box-shadow ", theme.transition.middle, ";min-width:0;overflow:hidden;}.", k, "-sender-shell::before{content:'';position:absolute;inset:0;padding:1px;border-radius:inherit;background:", sender.gradientDefault, ";-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude;pointer-events:none;transition:background ", theme.transition.middle, ",opacity ", theme.transition.middle, ";}&:not(.", k, "-sender-disabled) .", k, "-sender-shell:hover::before,.", k, "-sender-shell.", k, "-sender-active::before{background:", sender.gradientActive, ";}.", k, "-sender-shell.", k, "-sender-active{backdrop-filter:", sender.activeBackdropFilter, ";-webkit-backdrop-filter:", sender.activeBackdropFilter, ";box-shadow:", sender.activeShadow, ";}&.", k, "-sender-disabled .", k, "-sender-shell::before{opacity:0.5;}&.", k, "-sender-disabled .", k, "-sender-shell{background:", sender.disabledBg, ";}&.", k, "-sender-input-disabled .", k, "-sender-shell{background:", sender.disabledBg, ";}.", k, "-sender-attachments{padding:0;box-sizing:border-box;min-width:0;flex:0 0 auto;}.", k, "-sender-attachments-media .", k, "-file-card-list{min-width:0;}.", k, "-sender-before-input{margin-bottom:", sender.gapTopToInput, ";padding:0;box-sizing:border-box;flex:0 0 auto;}.", k, "-sender-attachments+.", k, "-sender-before-input{margin-top:", sender.gapAttachToTop, ";}.", k, "-sender-attachments+.", k, "-sender-input-area{margin-top:", sender.gapTopToInput, ";}.", k, "-sender-input-area{position:relative;display:flex;align-items:flex-start;flex:0 0 auto;min-height:0;margin-bottom:", sender.gapInputToToolbar, ";padding:0;box-sizing:border-box;}.", k, "-sender-prefix{display:inline-flex;align-items:center;flex:0 0 auto;min-height:calc(", sender.fontSize, " * ", sender.lineHeight, ");margin-right:", sender.prefixGap, ";color:", sender.prefixColor, ";line-height:", sender.lineHeight, ";}.", k, "-sender-input{flex:1 1 auto;width:0;min-width:0;min-height:0;border:none;outline:none;resize:none;background:transparent;color:", sender.color, ";font-family:inherit;font-size:", sender.fontSize, ";line-height:", sender.lineHeight, ";padding:0;scrollbar-width:thin;scrollbar-color:transparent transparent;}.", k, "-sender-input::-webkit-scrollbar{width:8px;}.", k, "-sender-input::-webkit-scrollbar-track{background:transparent;}.", k, "-sender-input::-webkit-scrollbar-thumb{border-radius:999px;border:2px solid transparent;background:transparent;background-clip:content-box;}.", k, "-sender-input:hover{scrollbar-color:", sender.scrollbarThumb, " transparent;}.", k, "-sender-input:hover::-webkit-scrollbar-thumb{background:", sender.scrollbarThumb, ";background-clip:content-box;}.", k, "-sender-input:hover::-webkit-scrollbar-thumb:hover{background:", sender.scrollbarThumbHover, ";background-clip:content-box;}.", k, "-sender-input::placeholder{color:", sender.placeholderColor, ";}&.", k, "-sender-disabled .", k, "-sender-input,&.", k, "-sender-input-disabled .", k, "-sender-input{color:", sender.disabledColor, ";cursor:not-allowed;}.", k, "-sender-toolbar{display:flex;gap:8px;padding:0;box-sizing:border-box;flex:0 0 auto;}.", k, "-sender-toolbar-left{display:flex;align-items:center;gap:8px;margin-top:8px;flex:0 0 auto;}.", k, "-sender-toolbar-right{display:flex;align-items:center;gap:8px;flex:0 0 auto;margin-left:auto;}.", k, "-sender-toolbar-middle{flex:1 1 auto;min-width:0;display:flex;align-items:flex-end;gap:8px;}.", k, "-sender-attach-btn{display:inline-flex;align-items:center;justify-content:center;width:", sender.attachButtonSize, ";height:", sender.attachButtonSize, ";border-radius:50%;background:transparent;border:none;padding:0;cursor:pointer;color:", sender.attachIconColor, ";transition:color ", theme.transition.small, ",background ", theme.transition.small, ";}.", k, "-sender-attach-btn:hover{color:", sender.attachIconHoverColor, ";}.", k, "-sender-attach-btn:disabled,&.", k, "-sender-disabled .", k, "-sender-attach-btn,&.", k, "-sender-input-disabled .", k, "-sender-attach-btn{color:", theme.color.disabled, ";cursor:not-allowed;background:transparent;}.", k, "-sender-attach-btn svg{display:block;}.", k, "-sender-send-btn{display:inline-flex;align-items:center;justify-content:center;width:", sender.sendButtonSize, ";height:", sender.sendButtonSize, ";background:transparent;border:none;padding:0;cursor:pointer;transition:filter ", theme.transition.small, ";}.", k, "-sender-send-btn:disabled{cursor:not-allowed;filter:opacity(0.5);}.", k, "-sender-send-btn:not(:disabled):hover{filter:opacity(0.85);}.", k, "-sender-send-icon{display:block;width:32px;height:32px;pointer-events:none;filter:drop-shadow(0 4px 8px rgba(83, 112, 255, 0.32));}.", k, "-sender-list-upload{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:", sender.listUploadIconToTextGap, ";width:", sender.listUploadSize, ";height:", sender.listUploadSize, ";box-sizing:border-box;flex:0 0 auto;padding:0;border-radius:", sender.listUploadRadius, ";border:", sender.listUploadBorder, ";background:", sender.listUploadBg, ";color:", sender.listUploadColor, ";cursor:pointer;transition:border-color ", theme.transition.small, ",color ", theme.transition.small, ";}.", k, "-sender-list-upload .", k, "-icon{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:", sender.listUploadIconSize, ";height:", sender.listUploadIconSize, ";color:inherit;font-size:", sender.listUploadIconSize, ";line-height:1;transition:color ", theme.transition.small, ";}.", k, "-sender-list-upload-text{flex:0 0 auto;font-size:", sender.listUploadTextFontSize, ";line-height:1;color:inherit;transition:color ", theme.transition.small, ";}.", k, "-sender-list-upload:hover{border-color:", theme.color.primary, ";color:", theme.color.primary, ";}.", k, "-sender-list-upload:hover .", k, "-icon,.", k, "-sender-list-upload:hover .", k, "-sender-list-upload-text{color:inherit;}.", k, "-sender-list-upload-disabled,.", k, "-sender-list-upload-disabled:hover{cursor:not-allowed;border:", sender.listUploadBorder, ";color:", theme.color.disabled, ";}.", k, "-sender-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;top:-9999px;left:-9999px;}.", k, "-sender-drag-mask{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;background:", sender.dragMaskBg, ";backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);}.", k, "-sender-drag-card{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;color:", sender.dragCardColor, ";}.", k, "-sender-drag-card .", k, "-icon{color:", sender.dragCardColor, ";font-size:32px;line-height:1;}.", k, "-sender-drag-text{color:", sender.dragCardTextColor, ";font-size:14px;font-weight:500;line-height:20px;}");
|
|
56
65
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _Number$isFinite from "@babel/runtime-corejs3/core-js/number/is-finite";
|
|
2
2
|
import { useInstance, onMounted, onUpdated, nextTick } from 'intact-vue-next';
|
|
3
3
|
import { useConfigContext } from '../config';
|
|
4
|
-
// textarea
|
|
4
|
+
// textarea 高度自适应:默认保留 64 的输入区高度;当上传入口放进附件列表时压缩为单行输入。
|
|
5
|
+
// maxHeight 约束整个输入外框而非 textarea 本身。
|
|
5
6
|
var SHELL_MAX_FALLBACK = 300;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
7
|
+
var TEXTAREA_MIN_DEFAULT = 64;
|
|
8
|
+
var TEXTAREA_MIN_LIST_UPLOAD = 20;
|
|
8
9
|
export function useAutoResize(textareaRef) {
|
|
9
10
|
var instance = useInstance();
|
|
10
11
|
var _useConfigContext = useConfigContext(),
|
|
@@ -45,8 +46,8 @@ export function useAutoResize(textareaRef) {
|
|
|
45
46
|
if (!el) return;
|
|
46
47
|
var shell = getShell(el);
|
|
47
48
|
if (!shell) return;
|
|
48
|
-
var
|
|
49
|
-
var min =
|
|
49
|
+
var isListUpload = instance.get('uploadButton') === 'list';
|
|
50
|
+
var min = isListUpload ? TEXTAREA_MIN_LIST_UPLOAD : TEXTAREA_MIN_DEFAULT;
|
|
50
51
|
/** 整框最大高度(props 或默认 300),从实际 CSS 读取,支持 50vh 等合法 CSS 值 */
|
|
51
52
|
var shellMax = getShellMaxHeight(shell);
|
|
52
53
|
var nonInputH = measureNonInputBlockHeight(el, shell);
|
|
@@ -85,7 +86,7 @@ export function useAutoResize(textareaRef) {
|
|
|
85
86
|
inited: true,
|
|
86
87
|
presented: true
|
|
87
88
|
});
|
|
88
|
-
instance.watch('
|
|
89
|
+
instance.watch('uploadButton', scheduleAdjust, {
|
|
89
90
|
inited: true,
|
|
90
91
|
presented: true
|
|
91
92
|
});
|
|
@@ -230,8 +230,11 @@ function _extractDroppedFiles() {
|
|
|
230
230
|
export function useSenderDrag(addFiles) {
|
|
231
231
|
var instance = useInstance();
|
|
232
232
|
var dragOver = useState(false);
|
|
233
|
+
function isInputDisabled() {
|
|
234
|
+
return !!instance.get('disabled') || !!instance.get('inputDisabled');
|
|
235
|
+
}
|
|
233
236
|
function isEnabled() {
|
|
234
|
-
return !!instance.get('dragFile') && !
|
|
237
|
+
return !!instance.get('dragFile') && !isInputDisabled();
|
|
235
238
|
}
|
|
236
239
|
var controller = {
|
|
237
240
|
dragOver: dragOver,
|
|
@@ -242,7 +245,7 @@ export function useSenderDrag(addFiles) {
|
|
|
242
245
|
e.stopPropagation();
|
|
243
246
|
},
|
|
244
247
|
onDragEnter: function onDragEnter() {
|
|
245
|
-
if (
|
|
248
|
+
if (isInputDisabled()) return;
|
|
246
249
|
controller.counter++;
|
|
247
250
|
if (!dragOver.value) {
|
|
248
251
|
dragOver.set(true);
|
|
@@ -259,7 +262,7 @@ export function useSenderDrag(addFiles) {
|
|
|
259
262
|
var _instance$get, _e$dataTransfer2;
|
|
260
263
|
controller.stopEvent(e);
|
|
261
264
|
controller.reset();
|
|
262
|
-
if (
|
|
265
|
+
if (isInputDisabled()) return;
|
|
263
266
|
var directoryEnabled = !!((_instance$get = instance.get('uploadProps')) != null && _instance$get.directory);
|
|
264
267
|
var directFiles = (_e$dataTransfer2 = e.dataTransfer) == null ? void 0 : _e$dataTransfer2.files;
|
|
265
268
|
if (!directoryEnabled && directFiles != null && directFiles.length) {
|
|
@@ -314,6 +317,12 @@ export function useSenderDrag(addFiles) {
|
|
|
314
317
|
}
|
|
315
318
|
syncController();
|
|
316
319
|
});
|
|
320
|
+
instance.watch('inputDisabled', function (disabled) {
|
|
321
|
+
if (disabled) {
|
|
322
|
+
controller.reset();
|
|
323
|
+
}
|
|
324
|
+
syncController();
|
|
325
|
+
});
|
|
317
326
|
return {
|
|
318
327
|
dragOver: dragOver
|
|
319
328
|
};
|
|
@@ -2,9 +2,12 @@ import { RefObject } from 'intact-vue-next';
|
|
|
2
2
|
export declare function useSenderInput(textareaRef: RefObject<HTMLTextAreaElement>): {
|
|
3
3
|
isFocus: import("../../hooks/useState").State<boolean>;
|
|
4
4
|
isDisabled: () => boolean;
|
|
5
|
+
isInputDisabled: () => boolean;
|
|
5
6
|
isGenerating: () => boolean;
|
|
6
7
|
isLoading: () => boolean;
|
|
7
8
|
isSendButtonDisabled: () => boolean;
|
|
9
|
+
isStopButtonDisabled: () => boolean;
|
|
10
|
+
isSendDisabled: () => boolean;
|
|
8
11
|
send: () => void;
|
|
9
12
|
stopGenerate: () => void;
|
|
10
13
|
handleKeydown: (e: KeyboardEvent) => void;
|