@uzum-tech/ui 2.2.1 → 2.3.0
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/index.js +1423 -721
- package/dist/index.mjs +1416 -722
- package/dist/index.prod.js +2 -2
- package/dist/index.prod.mjs +2 -2
- package/es/chat/index.d.ts +2 -0
- package/es/chat/index.mjs +1 -0
- package/es/chat/src/Chat.d.ts +20800 -24
- package/es/chat/src/Chat.mjs +1 -1
- package/es/chat/src/ChatMainArea.d.ts +9749 -0
- package/es/chat/src/{ChatParts/MainArea.mjs → ChatMainArea.mjs} +409 -75
- package/es/chat/src/ChatMessages.d.ts +1 -33
- package/es/chat/src/ChatMessages.mjs +79 -167
- package/es/chat/src/interface.d.ts +16 -12
- package/es/chat/src/interface.mjs +7 -1
- package/es/chat/src/styles/index.cssr.mjs +4 -1
- package/es/components.d.ts +28778 -256
- package/es/components.mjs +6 -1
- package/es/config-provider/src/internal-interface.d.ts +4 -0
- package/es/message-bubble/index.d.ts +3 -0
- package/es/message-bubble/index.mjs +2 -0
- package/es/message-bubble/src/MessageBubble.d.ts +304 -0
- package/es/message-bubble/src/MessageBubble.mjs +336 -0
- package/es/message-bubble/src/interface.d.ts +204 -0
- package/es/message-bubble/src/interface.mjs +92 -0
- package/es/message-bubble/src/styles/index.cssr.d.ts +2 -0
- package/es/message-bubble/src/styles/index.cssr.mjs +133 -0
- package/es/message-bubble/styles/dark.d.ts +29 -0
- package/es/message-bubble/styles/dark.mjs +13 -0
- package/es/message-bubble/styles/index.d.ts +3 -0
- package/es/message-bubble/styles/index.mjs +2 -0
- package/es/message-bubble/styles/light.d.ts +49 -0
- package/es/message-bubble/styles/light.mjs +44 -0
- package/es/styles.d.ts +1 -0
- package/es/styles.mjs +1 -0
- package/es/themes/dark.mjs +2 -0
- package/es/themes/light.mjs +2 -0
- package/es/upload/src/Upload.d.ts +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/chat/index.d.ts +2 -0
- package/lib/chat/index.js +3 -1
- package/lib/chat/src/Chat.d.ts +20800 -24
- package/lib/chat/src/Chat.js +2 -2
- package/lib/chat/src/ChatMainArea.d.ts +9749 -0
- package/lib/chat/src/{ChatParts/MainArea.js → ChatMainArea.js} +299 -30
- package/lib/chat/src/ChatMessages.d.ts +1 -33
- package/lib/chat/src/ChatMessages.js +61 -158
- package/lib/chat/src/interface.d.ts +16 -12
- package/lib/chat/src/interface.js +7 -1
- package/lib/chat/src/styles/index.cssr.js +4 -1
- package/lib/components.d.ts +28778 -256
- package/lib/components.js +18 -8
- package/lib/config-provider/src/internal-interface.d.ts +4 -0
- package/lib/message-bubble/index.d.ts +3 -0
- package/lib/message-bubble/index.js +14 -0
- package/lib/message-bubble/src/MessageBubble.d.ts +304 -0
- package/lib/message-bubble/src/MessageBubble.js +276 -0
- package/lib/message-bubble/src/interface.d.ts +204 -0
- package/lib/message-bubble/src/interface.js +80 -0
- package/lib/message-bubble/src/styles/index.cssr.d.ts +2 -0
- package/lib/message-bubble/src/styles/index.cssr.js +138 -0
- package/lib/message-bubble/styles/dark.d.ts +29 -0
- package/lib/message-bubble/styles/dark.js +15 -0
- package/lib/message-bubble/styles/index.d.ts +3 -0
- package/lib/message-bubble/styles/index.js +10 -0
- package/lib/message-bubble/styles/light.d.ts +49 -0
- package/lib/message-bubble/styles/light.js +36 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +84 -82
- package/lib/themes/dark.js +78 -76
- package/lib/themes/light.js +76 -74
- package/lib/upload/src/Upload.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/volar.d.ts +2 -0
- package/web-types.json +168 -1
- package/es/chat/src/ChatParts/MainArea.d.ts +0 -20
- package/lib/chat/src/ChatParts/MainArea.d.ts +0 -20
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) {
|
|
3
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
+
resolve(value);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) {
|
|
9
|
+
try {
|
|
10
|
+
step(generator.next(value));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
reject(e);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function rejected(value) {
|
|
16
|
+
try {
|
|
17
|
+
step(generator["throw"](value));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function step(result) {
|
|
23
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
24
|
+
}
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
import { computed, defineComponent, Fragment, h, nextTick, ref } from 'vue';
|
|
29
|
+
import { useConfig, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
30
|
+
import { UDropdown } from "../../dropdown/index.mjs";
|
|
31
|
+
import { UIcon } from "../../icon/index.mjs";
|
|
32
|
+
import { UText } from "../../typography/index.mjs";
|
|
33
|
+
import { UUpload, UUploadFileList } from "../../upload/index.mjs";
|
|
34
|
+
import { messageBubbleLight } from "../styles/index.mjs";
|
|
35
|
+
import { MessageBubbleAttachmentStatus, messageBubbleProps, MessageBubbleStatus, MessageBubbleType, statusIconMapper } from "./interface.mjs";
|
|
36
|
+
import style from "./styles/index.cssr.mjs";
|
|
37
|
+
export default defineComponent({
|
|
38
|
+
name: 'MessageBubble',
|
|
39
|
+
props: messageBubbleProps,
|
|
40
|
+
slots: Object,
|
|
41
|
+
setup(props, {
|
|
42
|
+
slots
|
|
43
|
+
}) {
|
|
44
|
+
const {
|
|
45
|
+
mergedClsPrefixRef,
|
|
46
|
+
inlineThemeDisabled
|
|
47
|
+
} = useConfig(props);
|
|
48
|
+
const themeRef = useTheme('MessageBubble', '-message-bubble', style, messageBubbleLight, props, mergedClsPrefixRef);
|
|
49
|
+
const contextMenuShow = ref(false);
|
|
50
|
+
const mergedRetryTextRef = computed(() => {
|
|
51
|
+
var _a;
|
|
52
|
+
return (_a = props.retryText) !== null && _a !== void 0 ? _a : 'Retry';
|
|
53
|
+
});
|
|
54
|
+
const normalizedAttachmentsRef = computed(() => {
|
|
55
|
+
if (!props.attachments) return [];
|
|
56
|
+
return Array.isArray(props.attachments) ? props.attachments : [props.attachments];
|
|
57
|
+
});
|
|
58
|
+
const messagePayloadRef = computed(() => ({
|
|
59
|
+
id: props.id,
|
|
60
|
+
isOwn: props.isOwn,
|
|
61
|
+
title: props.title,
|
|
62
|
+
content: props.content,
|
|
63
|
+
timestamp: props.timestamp,
|
|
64
|
+
status: props.status,
|
|
65
|
+
attachments: normalizedAttachmentsRef.value
|
|
66
|
+
}));
|
|
67
|
+
const cssVarsRef = computed(() => {
|
|
68
|
+
const {
|
|
69
|
+
common: {
|
|
70
|
+
cubicBezierEaseInOut
|
|
71
|
+
},
|
|
72
|
+
self: {
|
|
73
|
+
messageBubbleBackgroundColorOwn,
|
|
74
|
+
messageBubbleBackgroundColorOther,
|
|
75
|
+
messageBubbleTextColorOwn,
|
|
76
|
+
messageBubbleTextColorOther,
|
|
77
|
+
messageTimeColor,
|
|
78
|
+
messageStatusReadColor,
|
|
79
|
+
messageStatusSuccessColor,
|
|
80
|
+
attachmentBackgroundColorOwn,
|
|
81
|
+
attachmentBackgroundColorOther,
|
|
82
|
+
messageErrorColor,
|
|
83
|
+
messageBorderRadius,
|
|
84
|
+
unreadNotificationBackgroundColor,
|
|
85
|
+
unreadNotificationTextColor,
|
|
86
|
+
serviceMessageTextColor,
|
|
87
|
+
serviceMessageBackgroundColor,
|
|
88
|
+
messageTitleColor
|
|
89
|
+
}
|
|
90
|
+
} = themeRef.value;
|
|
91
|
+
return {
|
|
92
|
+
'--u-bezier': cubicBezierEaseInOut,
|
|
93
|
+
'--u-message-bubble-background-color-own': messageBubbleBackgroundColorOwn,
|
|
94
|
+
'--u-message-bubble-background-color-other': messageBubbleBackgroundColorOther,
|
|
95
|
+
'--u-message-bubble-text-color-own': messageBubbleTextColorOwn,
|
|
96
|
+
'--u-message-bubble-text-color-other': messageBubbleTextColorOther,
|
|
97
|
+
'--u-message-bubble-time-color': messageTimeColor,
|
|
98
|
+
'--u-message-bubble-status-read-color': messageStatusReadColor,
|
|
99
|
+
'--u-message-bubble-status-success-color': messageStatusSuccessColor,
|
|
100
|
+
'--u-message-bubble-attachment-background-color-own': attachmentBackgroundColorOwn,
|
|
101
|
+
'--u-message-bubble-attachment-background-color-other': attachmentBackgroundColorOther,
|
|
102
|
+
'--u-message-bubble-error-color': messageErrorColor,
|
|
103
|
+
'--u-message-bubble-border-radius': messageBorderRadius,
|
|
104
|
+
'--u-message-bubble-unread-background-color': unreadNotificationBackgroundColor,
|
|
105
|
+
'--u-message-bubble-unread-text-color': unreadNotificationTextColor,
|
|
106
|
+
'--u-message-bubble-service-text-color': serviceMessageTextColor,
|
|
107
|
+
'--u-message-bubble-service-background-color': serviceMessageBackgroundColor,
|
|
108
|
+
'--u-message-bubble-title-color': messageTitleColor
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const themeClassHandle = inlineThemeDisabled ? useThemeClass('message-bubble', undefined, cssVarsRef, props) : undefined;
|
|
112
|
+
const messageContextMenuOptions = computed(() => {
|
|
113
|
+
if (!props.actions || props.actions.length === 0) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
const result = [];
|
|
117
|
+
for (const action of props.actions) {
|
|
118
|
+
if (action.visible && !action.visible(messagePayloadRef.value)) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
result.push({
|
|
122
|
+
key: action.key,
|
|
123
|
+
label: typeof action.label === 'function' ? action.label() : action.label
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
});
|
|
128
|
+
const resolveRenderContent = content => {
|
|
129
|
+
if (typeof content === 'function') {
|
|
130
|
+
return content();
|
|
131
|
+
}
|
|
132
|
+
if (content instanceof Date) {
|
|
133
|
+
return content.toString();
|
|
134
|
+
}
|
|
135
|
+
return content;
|
|
136
|
+
};
|
|
137
|
+
const getThumbnailUrl = attachment => {
|
|
138
|
+
const url = [attachment.preview, attachment.thumbnail].find(value => typeof value === 'string');
|
|
139
|
+
return url !== null && url !== void 0 ? url : null;
|
|
140
|
+
};
|
|
141
|
+
const handleAttachmentDownload = file => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
if (props.onAttachmentDownload) {
|
|
143
|
+
const attachment = normalizedAttachmentsRef.value.find(item => item.name === file.name);
|
|
144
|
+
if (attachment) {
|
|
145
|
+
try {
|
|
146
|
+
yield props.onAttachmentDownload(attachment);
|
|
147
|
+
return false;
|
|
148
|
+
} catch (_a) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
});
|
|
155
|
+
const handleRetryClick = () => {
|
|
156
|
+
var _a;
|
|
157
|
+
(_a = props.onRetry) === null || _a === void 0 ? void 0 : _a.call(props, messagePayloadRef.value);
|
|
158
|
+
};
|
|
159
|
+
const handleContextMenuSelect = key => {
|
|
160
|
+
if (!props.actions || props.actions.length === 0) {
|
|
161
|
+
contextMenuShow.value = false;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const action = props.actions.find(action => action.key === key);
|
|
165
|
+
if (action) {
|
|
166
|
+
action.handler(messagePayloadRef.value);
|
|
167
|
+
}
|
|
168
|
+
contextMenuShow.value = false;
|
|
169
|
+
};
|
|
170
|
+
const renderAttachment = (withPadding = false) => {
|
|
171
|
+
if (slots.messageAttachment) {
|
|
172
|
+
return slots.messageAttachment(messagePayloadRef.value);
|
|
173
|
+
}
|
|
174
|
+
const fileList = normalizedAttachmentsRef.value.map(attachment => {
|
|
175
|
+
var _a, _b, _c;
|
|
176
|
+
return {
|
|
177
|
+
id: String(attachment.id),
|
|
178
|
+
name: attachment.name,
|
|
179
|
+
status: attachment.status || MessageBubbleAttachmentStatus.FINISHED,
|
|
180
|
+
percentage: (_a = attachment.percentage) !== null && _a !== void 0 ? _a : null,
|
|
181
|
+
url: (_b = attachment.url) !== null && _b !== void 0 ? _b : null,
|
|
182
|
+
thumbnailUrl: getThumbnailUrl(attachment),
|
|
183
|
+
type: (_c = attachment.type) !== null && _c !== void 0 ? _c : null,
|
|
184
|
+
file: null,
|
|
185
|
+
batchId: null
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
const uploadComponent = h(UUpload, Object.assign({
|
|
189
|
+
abstract: true,
|
|
190
|
+
fileList: fileList,
|
|
191
|
+
fileListStyle: withPadding ? {
|
|
192
|
+
display: 'flex',
|
|
193
|
+
flexDirection: 'column',
|
|
194
|
+
gap: '2px',
|
|
195
|
+
marginTop: '0'
|
|
196
|
+
} : undefined,
|
|
197
|
+
showRemoveButton: false,
|
|
198
|
+
showDownloadButton: normalizedAttachmentsRef.value.some(attachment => attachment.status === MessageBubbleAttachmentStatus.FINISHED && attachment.url && attachment.url !== '#'),
|
|
199
|
+
showRetryButton: normalizedAttachmentsRef.value.some(attachment => attachment.status === MessageBubbleAttachmentStatus.ERROR),
|
|
200
|
+
onDownload: handleAttachmentDownload
|
|
201
|
+
}, props.uploadProps), {
|
|
202
|
+
default: () => h(UUploadFileList, null, {
|
|
203
|
+
'upload-file-title': slots['upload-file-title'] ? ({
|
|
204
|
+
file
|
|
205
|
+
}) => {
|
|
206
|
+
var _a;
|
|
207
|
+
return (_a = slots['upload-file-title']) === null || _a === void 0 ? void 0 : _a.call(slots, file);
|
|
208
|
+
} : undefined,
|
|
209
|
+
'upload-file-subtitle': slots['upload-file-subtitle'] ? ({
|
|
210
|
+
file
|
|
211
|
+
}) => {
|
|
212
|
+
var _a;
|
|
213
|
+
return (_a = slots['upload-file-subtitle']) === null || _a === void 0 ? void 0 : _a.call(slots, file);
|
|
214
|
+
} : ({
|
|
215
|
+
file
|
|
216
|
+
}) => {
|
|
217
|
+
var _a;
|
|
218
|
+
const attachment = normalizedAttachmentsRef.value.find(item => item.name === file.name);
|
|
219
|
+
return h("span", {
|
|
220
|
+
style: {
|
|
221
|
+
fontSize: '12px',
|
|
222
|
+
color: '#999'
|
|
223
|
+
}
|
|
224
|
+
}, (attachment === null || attachment === void 0 ? void 0 : attachment.size) || ((_a = file.file) === null || _a === void 0 ? void 0 : _a.size));
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
});
|
|
228
|
+
if (withPadding) {
|
|
229
|
+
return h("div", {
|
|
230
|
+
style: {
|
|
231
|
+
padding: '2px'
|
|
232
|
+
}
|
|
233
|
+
}, uploadComponent);
|
|
234
|
+
}
|
|
235
|
+
return uploadComponent;
|
|
236
|
+
};
|
|
237
|
+
const renderMessage = () => {
|
|
238
|
+
var _a;
|
|
239
|
+
const hasBubbleActionsSlot = slots.bubbleActions !== undefined;
|
|
240
|
+
const hasBubbleActionsConfig = Boolean(props.actions && props.actions.length > 0);
|
|
241
|
+
const hasTitle = Boolean(props.title || slots.title);
|
|
242
|
+
const hasContentInsideBubble = Boolean(props.content || slots.default || hasTitle || normalizedAttachmentsRef.value.length > 1);
|
|
243
|
+
const messageBubbleContent = hasContentInsideBubble ? h("div", {
|
|
244
|
+
class: [`${mergedClsPrefixRef.value}-message-bubble__bubble`, props.isOwn ? `${mergedClsPrefixRef.value}-message-bubble__bubble--own` : `${mergedClsPrefixRef.value}-message-bubble__bubble--other`]
|
|
245
|
+
}, hasTitle && h(UText, {
|
|
246
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__title`,
|
|
247
|
+
variant: "body-l-semi-bold"
|
|
248
|
+
}, slots.title ? slots.title(messagePayloadRef.value) : resolveRenderContent(props.title)), normalizedAttachmentsRef.value.length > 0 && renderAttachment(true), (props.content || slots.default) && h("div", {
|
|
249
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__text`
|
|
250
|
+
}, slots.default ? slots.default(messagePayloadRef.value) : resolveRenderContent(props.content))) : normalizedAttachmentsRef.value.length === 1 ? renderAttachment() : null;
|
|
251
|
+
return h("div", {
|
|
252
|
+
class: [`${mergedClsPrefixRef.value}-message-bubble__message`, props.isOwn ? `${mergedClsPrefixRef.value}-message-bubble__message--own` : `${mergedClsPrefixRef.value}-message-bubble__message--other`]
|
|
253
|
+
}, h("div", {
|
|
254
|
+
class: [`${mergedClsPrefixRef.value}-message-bubble__message-wrapper`, props.isOwn ? `${mergedClsPrefixRef.value}-message-bubble__message-wrapper--own` : `${mergedClsPrefixRef.value}-message-bubble__message-wrapper--other`]
|
|
255
|
+
}, hasBubbleActionsSlot ? h("div", {
|
|
256
|
+
onContextmenu: event => {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
contextMenuShow.value = false;
|
|
259
|
+
void nextTick().then(() => {
|
|
260
|
+
contextMenuShow.value = true;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}, (_a = slots.bubbleActions) === null || _a === void 0 ? void 0 : _a.call(slots, messagePayloadRef.value), messageBubbleContent) : hasBubbleActionsConfig ? h(UDropdown, {
|
|
264
|
+
show: contextMenuShow.value,
|
|
265
|
+
trigger: "manual",
|
|
266
|
+
placement: "bottom-start",
|
|
267
|
+
options: messageContextMenuOptions.value,
|
|
268
|
+
onSelect: handleContextMenuSelect,
|
|
269
|
+
onUpdateShow: show => {
|
|
270
|
+
contextMenuShow.value = show;
|
|
271
|
+
},
|
|
272
|
+
onClickoutside: () => {
|
|
273
|
+
contextMenuShow.value = false;
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
default: () => h("div", {
|
|
277
|
+
onContextmenu: event => {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
contextMenuShow.value = false;
|
|
280
|
+
void nextTick().then(() => {
|
|
281
|
+
contextMenuShow.value = true;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}, messageBubbleContent)
|
|
285
|
+
}) : messageBubbleContent, h("div", {
|
|
286
|
+
class: [`${mergedClsPrefixRef.value}-message-bubble__meta`, props.isOwn ? `${mergedClsPrefixRef.value}-message-bubble__meta--own` : `${mergedClsPrefixRef.value}-message-bubble__meta--other`]
|
|
287
|
+
}, props.status === MessageBubbleStatus.RETRY ? h("div", {
|
|
288
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__retry`,
|
|
289
|
+
onClick: handleRetryClick
|
|
290
|
+
}, h(UIcon, {
|
|
291
|
+
size: 16,
|
|
292
|
+
component: statusIconMapper[MessageBubbleStatus.RETRY],
|
|
293
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__retry-icon`,
|
|
294
|
+
theme: themeRef.value.peers.StatusIcon,
|
|
295
|
+
themeOverrides: themeRef.value.peerOverrides.StatusIcon
|
|
296
|
+
}), h("span", {
|
|
297
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__retry-text`
|
|
298
|
+
}, mergedRetryTextRef.value)) : h(Fragment, null, h("span", {
|
|
299
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__time`
|
|
300
|
+
}, resolveRenderContent(props.timestamp)), props.isOwn && props.status && h("div", {
|
|
301
|
+
class: `${mergedClsPrefixRef.value}-message-bubble__status`
|
|
302
|
+
}, slots.messageStatus ? slots.messageStatus(messagePayloadRef.value) : statusIconMapper[props.status] && h(UIcon, {
|
|
303
|
+
size: 16,
|
|
304
|
+
component: statusIconMapper[props.status],
|
|
305
|
+
class: [`${mergedClsPrefixRef.value}-message-bubble__status-icon`, `${mergedClsPrefixRef.value}-message-bubble__status-icon--${String(props.status)}`],
|
|
306
|
+
theme: themeRef.value.peers.StatusIcon,
|
|
307
|
+
themeOverrides: themeRef.value.peerOverrides.StatusIcon
|
|
308
|
+
}))))));
|
|
309
|
+
};
|
|
310
|
+
const renderService = () => {
|
|
311
|
+
if (slots.service) {
|
|
312
|
+
return slots.service(props.serviceVariant);
|
|
313
|
+
}
|
|
314
|
+
return h("div", {
|
|
315
|
+
class: [`${mergedClsPrefixRef.value}-message-bubble__service`, `${mergedClsPrefixRef.value}-message-bubble__service--${props.serviceVariant}`]
|
|
316
|
+
}, props.content && h("span", null, resolveRenderContent(props.content)));
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
mergedClsPrefixRef,
|
|
320
|
+
inlineThemeDisabled,
|
|
321
|
+
cssVars: cssVarsRef,
|
|
322
|
+
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
323
|
+
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender,
|
|
324
|
+
renderMessage,
|
|
325
|
+
renderService
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
render() {
|
|
329
|
+
var _a;
|
|
330
|
+
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
331
|
+
return h("div", {
|
|
332
|
+
class: [`${this.mergedClsPrefixRef}-message-bubble`, this.themeClass],
|
|
333
|
+
style: this.inlineThemeDisabled ? undefined : this.cssVars
|
|
334
|
+
}, this.type === MessageBubbleType.SERVICE ? this.renderService() : this.renderMessage());
|
|
335
|
+
}
|
|
336
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { Component, PropType, VNodeChild } from 'vue';
|
|
2
|
+
import type { ExtractPublicPropTypes } from '../../_utils';
|
|
3
|
+
import type { UploadFileInfo, UploadProps } from '../../upload';
|
|
4
|
+
export declare enum MessageBubbleType {
|
|
5
|
+
MESSAGE = "message",
|
|
6
|
+
SERVICE = "service"
|
|
7
|
+
}
|
|
8
|
+
export declare enum MessageBubbleServiceVariant {
|
|
9
|
+
UNREAD = "unread",
|
|
10
|
+
SYSTEM = "system",
|
|
11
|
+
EVENT = "event",
|
|
12
|
+
DIVIDER = "divider"
|
|
13
|
+
}
|
|
14
|
+
export declare enum MessageBubbleStatus {
|
|
15
|
+
READ = "read",
|
|
16
|
+
UNREAD = "unread",
|
|
17
|
+
PENDING = "pending",
|
|
18
|
+
RETRY = "retry"
|
|
19
|
+
}
|
|
20
|
+
export declare enum MessageBubbleAttachmentStatus {
|
|
21
|
+
PENDING = "pending",
|
|
22
|
+
UPLOADING = "uploading",
|
|
23
|
+
FINISHED = "finished",
|
|
24
|
+
ERROR = "error"
|
|
25
|
+
}
|
|
26
|
+
export interface MessageBubbleSlots {
|
|
27
|
+
default?: (message: MessageBubbleMessagePayload) => VNodeChild;
|
|
28
|
+
title?: (message: MessageBubbleMessagePayload) => VNodeChild;
|
|
29
|
+
service?: (variant: MessageBubbleServiceVariant) => VNodeChild;
|
|
30
|
+
messageStatus?: (message: MessageBubbleMessagePayload) => VNodeChild;
|
|
31
|
+
bubbleActions?: (message: MessageBubbleMessagePayload) => VNodeChild;
|
|
32
|
+
messageAttachment?: (message: MessageBubbleMessagePayload) => VNodeChild;
|
|
33
|
+
'upload-file-title'?: (file: UploadFileInfo) => VNodeChild;
|
|
34
|
+
'upload-file-subtitle'?: (file: UploadFileInfo) => VNodeChild;
|
|
35
|
+
}
|
|
36
|
+
export interface MessageBubbleAttachment {
|
|
37
|
+
id: MessageBubbleId;
|
|
38
|
+
name: string;
|
|
39
|
+
url?: string;
|
|
40
|
+
size?: number | string;
|
|
41
|
+
thumbnail?: string;
|
|
42
|
+
preview?: string;
|
|
43
|
+
status?: MessageBubbleAttachmentStatus;
|
|
44
|
+
percentage?: number;
|
|
45
|
+
type?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface MessageBubbleMessagePayload {
|
|
48
|
+
id?: MessageBubbleId;
|
|
49
|
+
isOwn: boolean;
|
|
50
|
+
title?: MessageBubbleRenderContent;
|
|
51
|
+
content?: MessageBubbleRenderContent;
|
|
52
|
+
timestamp?: string | number | Date | (() => VNodeChild);
|
|
53
|
+
status?: MessageBubbleStatus;
|
|
54
|
+
attachments: MessageBubbleAttachment[];
|
|
55
|
+
}
|
|
56
|
+
export interface MessageBubbleAction {
|
|
57
|
+
key: string;
|
|
58
|
+
label: string | (() => VNodeChild);
|
|
59
|
+
handler: (message: MessageBubbleMessagePayload) => void;
|
|
60
|
+
visible?: (message: MessageBubbleMessagePayload) => boolean;
|
|
61
|
+
}
|
|
62
|
+
export type MessageBubbleId = string | number | symbol;
|
|
63
|
+
export type MessageBubbleRenderContent = string | (() => VNodeChild);
|
|
64
|
+
export type MessageBubbleProps = ExtractPublicPropTypes<typeof messageBubbleProps>;
|
|
65
|
+
export declare const statusIconMapper: Partial<Record<MessageBubbleStatus, Component>>;
|
|
66
|
+
export declare const messageBubbleProps: {
|
|
67
|
+
readonly type: {
|
|
68
|
+
readonly type: PropType<MessageBubbleType>;
|
|
69
|
+
readonly default: MessageBubbleType.MESSAGE;
|
|
70
|
+
};
|
|
71
|
+
readonly serviceVariant: {
|
|
72
|
+
readonly type: PropType<MessageBubbleServiceVariant>;
|
|
73
|
+
readonly default: MessageBubbleServiceVariant.SYSTEM;
|
|
74
|
+
};
|
|
75
|
+
readonly id: {
|
|
76
|
+
readonly type: PropType<MessageBubbleId>;
|
|
77
|
+
readonly default: undefined;
|
|
78
|
+
};
|
|
79
|
+
readonly isOwn: {
|
|
80
|
+
readonly type: BooleanConstructor;
|
|
81
|
+
readonly default: false;
|
|
82
|
+
};
|
|
83
|
+
readonly title: {
|
|
84
|
+
readonly type: PropType<MessageBubbleRenderContent>;
|
|
85
|
+
readonly default: undefined;
|
|
86
|
+
};
|
|
87
|
+
readonly content: {
|
|
88
|
+
readonly type: PropType<MessageBubbleRenderContent>;
|
|
89
|
+
readonly default: undefined;
|
|
90
|
+
};
|
|
91
|
+
readonly timestamp: {
|
|
92
|
+
readonly type: PropType<string | number | Date | (() => VNodeChild)>;
|
|
93
|
+
readonly default: undefined;
|
|
94
|
+
};
|
|
95
|
+
readonly status: {
|
|
96
|
+
readonly type: PropType<MessageBubbleStatus>;
|
|
97
|
+
readonly default: undefined;
|
|
98
|
+
};
|
|
99
|
+
readonly attachments: {
|
|
100
|
+
readonly type: PropType<MessageBubbleAttachment[] | MessageBubbleAttachment>;
|
|
101
|
+
readonly default: undefined;
|
|
102
|
+
};
|
|
103
|
+
readonly uploadProps: {
|
|
104
|
+
readonly type: PropType<Partial<UploadProps>>;
|
|
105
|
+
readonly default: undefined;
|
|
106
|
+
};
|
|
107
|
+
readonly actions: {
|
|
108
|
+
readonly type: PropType<MessageBubbleAction[]>;
|
|
109
|
+
readonly default: undefined;
|
|
110
|
+
};
|
|
111
|
+
readonly retryText: {
|
|
112
|
+
readonly type: StringConstructor;
|
|
113
|
+
readonly default: undefined;
|
|
114
|
+
};
|
|
115
|
+
readonly onRetry: {
|
|
116
|
+
readonly type: PropType<(message: MessageBubbleMessagePayload) => void>;
|
|
117
|
+
readonly default: undefined;
|
|
118
|
+
};
|
|
119
|
+
readonly onAttachmentDownload: {
|
|
120
|
+
readonly type: PropType<(attachment: MessageBubbleAttachment) => Promise<void> | void>;
|
|
121
|
+
readonly default: undefined;
|
|
122
|
+
};
|
|
123
|
+
readonly theme: PropType<import("../../_mixins").Theme<"MessageBubble", {
|
|
124
|
+
messageBubbleBackgroundColorOwn: string;
|
|
125
|
+
messageBubbleBackgroundColorOther: string;
|
|
126
|
+
messageBubbleTextColorOwn: string;
|
|
127
|
+
messageBubbleTextColorOther: string;
|
|
128
|
+
messageTimeColor: string;
|
|
129
|
+
messageStatusReadColor: string;
|
|
130
|
+
messageStatusSuccessColor: string;
|
|
131
|
+
attachmentBackgroundColorOwn: string;
|
|
132
|
+
attachmentBackgroundColorOther: string;
|
|
133
|
+
messageErrorColor: string;
|
|
134
|
+
messageBorderRadius: string;
|
|
135
|
+
unreadNotificationBackgroundColor: string;
|
|
136
|
+
unreadNotificationTextColor: string;
|
|
137
|
+
serviceMessageTextColor: string;
|
|
138
|
+
serviceMessageBackgroundColor: string;
|
|
139
|
+
messageTitleColor: string;
|
|
140
|
+
}, {
|
|
141
|
+
StatusIcon: import("../../_mixins").Theme<"Icon", {
|
|
142
|
+
color: string;
|
|
143
|
+
opacity1Depth: string;
|
|
144
|
+
opacity2Depth: string;
|
|
145
|
+
opacity3Depth: string;
|
|
146
|
+
opacity4Depth: string;
|
|
147
|
+
opacity5Depth: string;
|
|
148
|
+
}, any>;
|
|
149
|
+
}>>;
|
|
150
|
+
readonly themeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"MessageBubble", {
|
|
151
|
+
messageBubbleBackgroundColorOwn: string;
|
|
152
|
+
messageBubbleBackgroundColorOther: string;
|
|
153
|
+
messageBubbleTextColorOwn: string;
|
|
154
|
+
messageBubbleTextColorOther: string;
|
|
155
|
+
messageTimeColor: string;
|
|
156
|
+
messageStatusReadColor: string;
|
|
157
|
+
messageStatusSuccessColor: string;
|
|
158
|
+
attachmentBackgroundColorOwn: string;
|
|
159
|
+
attachmentBackgroundColorOther: string;
|
|
160
|
+
messageErrorColor: string;
|
|
161
|
+
messageBorderRadius: string;
|
|
162
|
+
unreadNotificationBackgroundColor: string;
|
|
163
|
+
unreadNotificationTextColor: string;
|
|
164
|
+
serviceMessageTextColor: string;
|
|
165
|
+
serviceMessageBackgroundColor: string;
|
|
166
|
+
messageTitleColor: string;
|
|
167
|
+
}, {
|
|
168
|
+
StatusIcon: import("../../_mixins").Theme<"Icon", {
|
|
169
|
+
color: string;
|
|
170
|
+
opacity1Depth: string;
|
|
171
|
+
opacity2Depth: string;
|
|
172
|
+
opacity3Depth: string;
|
|
173
|
+
opacity4Depth: string;
|
|
174
|
+
opacity5Depth: string;
|
|
175
|
+
}, any>;
|
|
176
|
+
}>>>;
|
|
177
|
+
readonly builtinThemeOverrides: PropType<import("../../_mixins/use-theme").ExtractThemeOverrides<import("../../_mixins").Theme<"MessageBubble", {
|
|
178
|
+
messageBubbleBackgroundColorOwn: string;
|
|
179
|
+
messageBubbleBackgroundColorOther: string;
|
|
180
|
+
messageBubbleTextColorOwn: string;
|
|
181
|
+
messageBubbleTextColorOther: string;
|
|
182
|
+
messageTimeColor: string;
|
|
183
|
+
messageStatusReadColor: string;
|
|
184
|
+
messageStatusSuccessColor: string;
|
|
185
|
+
attachmentBackgroundColorOwn: string;
|
|
186
|
+
attachmentBackgroundColorOther: string;
|
|
187
|
+
messageErrorColor: string;
|
|
188
|
+
messageBorderRadius: string;
|
|
189
|
+
unreadNotificationBackgroundColor: string;
|
|
190
|
+
unreadNotificationTextColor: string;
|
|
191
|
+
serviceMessageTextColor: string;
|
|
192
|
+
serviceMessageBackgroundColor: string;
|
|
193
|
+
messageTitleColor: string;
|
|
194
|
+
}, {
|
|
195
|
+
StatusIcon: import("../../_mixins").Theme<"Icon", {
|
|
196
|
+
color: string;
|
|
197
|
+
opacity1Depth: string;
|
|
198
|
+
opacity2Depth: string;
|
|
199
|
+
opacity3Depth: string;
|
|
200
|
+
opacity4Depth: string;
|
|
201
|
+
opacity5Depth: string;
|
|
202
|
+
}, any>;
|
|
203
|
+
}>>>;
|
|
204
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CheckmarkDoneSharp, MdTime, Refresh } from "../../_internal/icons/index.mjs";
|
|
2
|
+
import { useTheme } from "../../_mixins/index.mjs";
|
|
3
|
+
export var MessageBubbleType;
|
|
4
|
+
(function (MessageBubbleType) {
|
|
5
|
+
MessageBubbleType["MESSAGE"] = "message";
|
|
6
|
+
MessageBubbleType["SERVICE"] = "service";
|
|
7
|
+
})(MessageBubbleType || (MessageBubbleType = {}));
|
|
8
|
+
export var MessageBubbleServiceVariant;
|
|
9
|
+
(function (MessageBubbleServiceVariant) {
|
|
10
|
+
MessageBubbleServiceVariant["UNREAD"] = "unread";
|
|
11
|
+
MessageBubbleServiceVariant["SYSTEM"] = "system";
|
|
12
|
+
MessageBubbleServiceVariant["EVENT"] = "event";
|
|
13
|
+
MessageBubbleServiceVariant["DIVIDER"] = "divider";
|
|
14
|
+
})(MessageBubbleServiceVariant || (MessageBubbleServiceVariant = {}));
|
|
15
|
+
export var MessageBubbleStatus;
|
|
16
|
+
(function (MessageBubbleStatus) {
|
|
17
|
+
MessageBubbleStatus["READ"] = "read";
|
|
18
|
+
MessageBubbleStatus["UNREAD"] = "unread";
|
|
19
|
+
MessageBubbleStatus["PENDING"] = "pending";
|
|
20
|
+
MessageBubbleStatus["RETRY"] = "retry";
|
|
21
|
+
})(MessageBubbleStatus || (MessageBubbleStatus = {}));
|
|
22
|
+
export var MessageBubbleAttachmentStatus;
|
|
23
|
+
(function (MessageBubbleAttachmentStatus) {
|
|
24
|
+
MessageBubbleAttachmentStatus["PENDING"] = "pending";
|
|
25
|
+
MessageBubbleAttachmentStatus["UPLOADING"] = "uploading";
|
|
26
|
+
MessageBubbleAttachmentStatus["FINISHED"] = "finished";
|
|
27
|
+
MessageBubbleAttachmentStatus["ERROR"] = "error";
|
|
28
|
+
})(MessageBubbleAttachmentStatus || (MessageBubbleAttachmentStatus = {}));
|
|
29
|
+
export const statusIconMapper = {
|
|
30
|
+
[MessageBubbleStatus.READ]: CheckmarkDoneSharp,
|
|
31
|
+
[MessageBubbleStatus.PENDING]: MdTime,
|
|
32
|
+
[MessageBubbleStatus.RETRY]: Refresh,
|
|
33
|
+
[MessageBubbleStatus.UNREAD]: CheckmarkDoneSharp
|
|
34
|
+
};
|
|
35
|
+
export const messageBubbleProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
36
|
+
type: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: MessageBubbleType.MESSAGE
|
|
39
|
+
},
|
|
40
|
+
serviceVariant: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: MessageBubbleServiceVariant.SYSTEM
|
|
43
|
+
},
|
|
44
|
+
id: {
|
|
45
|
+
type: [String, Number, Symbol],
|
|
46
|
+
default: undefined
|
|
47
|
+
},
|
|
48
|
+
isOwn: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
title: {
|
|
53
|
+
type: [String, Function],
|
|
54
|
+
default: undefined
|
|
55
|
+
},
|
|
56
|
+
content: {
|
|
57
|
+
type: [String, Function],
|
|
58
|
+
default: undefined
|
|
59
|
+
},
|
|
60
|
+
timestamp: {
|
|
61
|
+
type: [String, Number, Date, Function],
|
|
62
|
+
default: undefined
|
|
63
|
+
},
|
|
64
|
+
status: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: undefined
|
|
67
|
+
},
|
|
68
|
+
attachments: {
|
|
69
|
+
type: [Array, Object],
|
|
70
|
+
default: undefined
|
|
71
|
+
},
|
|
72
|
+
uploadProps: {
|
|
73
|
+
type: Object,
|
|
74
|
+
default: undefined
|
|
75
|
+
},
|
|
76
|
+
actions: {
|
|
77
|
+
type: Array,
|
|
78
|
+
default: undefined
|
|
79
|
+
},
|
|
80
|
+
retryText: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: undefined
|
|
83
|
+
},
|
|
84
|
+
onRetry: {
|
|
85
|
+
type: Function,
|
|
86
|
+
default: undefined
|
|
87
|
+
},
|
|
88
|
+
onAttachmentDownload: {
|
|
89
|
+
type: Function,
|
|
90
|
+
default: undefined
|
|
91
|
+
}
|
|
92
|
+
});
|