@uzum-tech/ui 1.7.2 → 1.8.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/index.js +1673 -996
- package/dist/index.prod.js +3 -3
- package/es/chat/index.d.ts +6 -1
- package/es/chat/index.js +3 -0
- package/es/chat/src/Chat.d.ts +19 -6
- package/es/chat/src/Chat.js +54 -14
- package/es/chat/src/ChatListItems.d.ts +7782 -0
- package/es/chat/src/ChatListItems.js +188 -0
- package/es/chat/src/ChatMessages.d.ts +7805 -0
- package/es/chat/src/ChatMessages.js +325 -0
- package/es/chat/src/ChatParts/ChatAttachment.js +4 -3
- package/es/chat/src/ChatParts/MainArea.d.ts +0 -2
- package/es/chat/src/ChatParts/MainArea.js +108 -229
- package/es/chat/src/ChatParts/Sidebar.js +16 -80
- package/es/chat/src/interface.d.ts +10 -1
- package/es/chat/src/styles/index.cssr.js +16 -16
- package/es/chat/styles/light.d.ts +1 -1
- package/es/chat/styles/light.js +15 -3
- package/es/locales/common/arDZ.js +2 -1
- package/es/locales/common/deDE.js +2 -1
- package/es/locales/common/enGB.js +2 -1
- package/es/locales/common/enUS.d.ts +1 -0
- package/es/locales/common/enUS.js +2 -1
- package/es/locales/common/eo.js +2 -1
- package/es/locales/common/esAR.js +2 -1
- package/es/locales/common/faIR.js +2 -1
- package/es/locales/common/frFR.js +2 -1
- package/es/locales/common/idID.js +2 -1
- package/es/locales/common/itIT.js +2 -1
- package/es/locales/common/jaJP.js +2 -1
- package/es/locales/common/koKR.js +2 -1
- package/es/locales/common/nbNO.js +2 -1
- package/es/locales/common/nlNL.js +2 -1
- package/es/locales/common/plPL.js +2 -1
- package/es/locales/common/ptBR.js +2 -1
- package/es/locales/common/ruRU.js +2 -1
- package/es/locales/common/skSK.js +2 -1
- package/es/locales/common/svSE.js +2 -1
- package/es/locales/common/thTH.js +2 -1
- package/es/locales/common/trTR.js +2 -1
- package/es/locales/common/ukUA.js +2 -1
- package/es/locales/common/viVN.js +2 -1
- package/es/locales/common/zhCN.js +2 -1
- package/es/locales/common/zhTW.js +2 -1
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/chat/index.d.ts +6 -1
- package/lib/chat/index.js +9 -1
- package/lib/chat/src/Chat.d.ts +19 -6
- package/lib/chat/src/Chat.js +53 -13
- package/lib/chat/src/ChatListItems.d.ts +7782 -0
- package/lib/chat/src/ChatListItems.js +194 -0
- package/lib/chat/src/ChatMessages.d.ts +7805 -0
- package/lib/chat/src/ChatMessages.js +331 -0
- package/lib/chat/src/ChatParts/ChatAttachment.js +4 -3
- package/lib/chat/src/ChatParts/MainArea.d.ts +0 -2
- package/lib/chat/src/ChatParts/MainArea.js +107 -228
- package/lib/chat/src/ChatParts/Sidebar.js +17 -78
- package/lib/chat/src/interface.d.ts +10 -1
- package/lib/chat/src/styles/index.cssr.js +16 -16
- package/lib/chat/styles/light.d.ts +1 -1
- package/lib/chat/styles/light.js +15 -3
- package/lib/locales/common/arDZ.js +2 -1
- package/lib/locales/common/deDE.js +2 -1
- package/lib/locales/common/enGB.js +2 -1
- package/lib/locales/common/enUS.d.ts +1 -0
- package/lib/locales/common/enUS.js +2 -1
- package/lib/locales/common/eo.js +2 -1
- package/lib/locales/common/esAR.js +2 -1
- package/lib/locales/common/faIR.js +2 -1
- package/lib/locales/common/frFR.js +2 -1
- package/lib/locales/common/idID.js +2 -1
- package/lib/locales/common/itIT.js +2 -1
- package/lib/locales/common/jaJP.js +2 -1
- package/lib/locales/common/koKR.js +2 -1
- package/lib/locales/common/nbNO.js +2 -1
- package/lib/locales/common/nlNL.js +2 -1
- package/lib/locales/common/plPL.js +2 -1
- package/lib/locales/common/ptBR.js +2 -1
- package/lib/locales/common/ruRU.js +2 -1
- package/lib/locales/common/skSK.js +2 -1
- package/lib/locales/common/svSE.js +2 -1
- package/lib/locales/common/thTH.js +2 -1
- package/lib/locales/common/trTR.js +2 -1
- package/lib/locales/common/ukUA.js +2 -1
- package/lib/locales/common/viVN.js +2 -1
- package/lib/locales/common/zhCN.js +2 -1
- package/lib/locales/common/zhTW.js +2 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/volar.d.ts +2 -0
- package/web-types.json +149 -1
- package/es/chat/src/ChatGlobalState.d.ts +0 -13
- package/es/chat/src/ChatGlobalState.js +0 -32
- package/lib/chat/src/ChatGlobalState.d.ts +0 -13
- package/lib/chat/src/ChatGlobalState.js +0 -36
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { h, defineComponent, computed, inject, Fragment } from 'vue';
|
|
2
|
+
import { MessageStatus, ChatMessageType, ChatMarkType, chatInjectionKey } from './interface';
|
|
3
|
+
import ChatAttachmentComponent from './ChatParts/ChatAttachment';
|
|
4
|
+
import { UIcon } from '../../icon';
|
|
5
|
+
import { USkeleton } from '../../skeleton';
|
|
6
|
+
import style from './styles/index.cssr';
|
|
7
|
+
import { chatLight } from '../styles';
|
|
8
|
+
import { useConfig, useTheme, useThemeClass, useLocale } from '../../_mixins';
|
|
9
|
+
import { CheckmarkDoneSharp, Refresh, MdTime } from '../../_internal/icons';
|
|
10
|
+
const statusIconMapper = {
|
|
11
|
+
[MessageStatus.READ]: CheckmarkDoneSharp,
|
|
12
|
+
[MessageStatus.PENDING]: MdTime,
|
|
13
|
+
[MessageStatus.RETRY]: Refresh,
|
|
14
|
+
[MessageStatus.UNREAD]: CheckmarkDoneSharp
|
|
15
|
+
};
|
|
16
|
+
export const chatMessagesProps = Object.assign(Object.assign({}, useTheme.props), { messages: {
|
|
17
|
+
type: Array,
|
|
18
|
+
default: () => []
|
|
19
|
+
}, loading: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
}, loadingCount: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 5
|
|
25
|
+
}, typingChatIds: {
|
|
26
|
+
type: Array,
|
|
27
|
+
default: () => []
|
|
28
|
+
}, selectedChatId: {
|
|
29
|
+
type: [String, Number, Symbol],
|
|
30
|
+
default: undefined
|
|
31
|
+
}, typingText: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: undefined
|
|
34
|
+
}, retryText: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: undefined
|
|
37
|
+
}, uploadProps: {
|
|
38
|
+
type: Object,
|
|
39
|
+
default: undefined
|
|
40
|
+
}, showUnreadNotification: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
}, unreadNotificationText: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: undefined
|
|
46
|
+
}, unreadNotificationCount: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: undefined
|
|
49
|
+
}, onMessageRetry: {
|
|
50
|
+
type: Function,
|
|
51
|
+
default: undefined
|
|
52
|
+
} });
|
|
53
|
+
export default defineComponent({
|
|
54
|
+
name: 'ChatMessages',
|
|
55
|
+
props: chatMessagesProps,
|
|
56
|
+
setup(props, { slots }) {
|
|
57
|
+
var _a;
|
|
58
|
+
const UChat = inject(chatInjectionKey, null);
|
|
59
|
+
const { mergedClsPrefixRef } = useConfig(props);
|
|
60
|
+
const themeRef = (_a = UChat === null || UChat === void 0 ? void 0 : UChat.mergedThemeRef) !== null && _a !== void 0 ? _a : useTheme('Chat', '-chat', style, chatLight, props, mergedClsPrefixRef);
|
|
61
|
+
const { localeRef } = useLocale('Chat');
|
|
62
|
+
const cssVarsRef = computed(() => {
|
|
63
|
+
const { common: { cubicBezierEaseInOut, brandPrimary500, staticGreen, staticRed, textPrimary, textSecondary, textTertiary }, self: { backgroundColor, borderColor, mainBackgroundColor, headerBackgroundColor, headerBorderColor, headerTitleColor, messageBubbleBackgroundColorOwn, messageBubbleBackgroundColorOther, messageBubbleTextColorOwn, messageBubbleTextColorOther, messageTimeColor, messageStatusColor, attachmentBackgroundColorOwn, attachmentBackgroundColorOther, unreadNotificationBackgroundColor, unreadNotificationTextColor, typingIndicatorColor, dateSeparatorColor, dateSeparatorBackgroundColor, borderRadius, errorColor } } = themeRef.value;
|
|
64
|
+
return {
|
|
65
|
+
'--u-bezier': cubicBezierEaseInOut,
|
|
66
|
+
'--u-color-primary': brandPrimary500,
|
|
67
|
+
'--u-color-success': staticGreen,
|
|
68
|
+
'--u-color-error': errorColor || staticRed,
|
|
69
|
+
'--u-text-color-base': textPrimary,
|
|
70
|
+
'--u-text-color-secondary': textSecondary,
|
|
71
|
+
'--u-text-color-disabled': textTertiary,
|
|
72
|
+
'--u-background-color': backgroundColor,
|
|
73
|
+
'--u-border-color': borderColor,
|
|
74
|
+
'--u-main-background-color': mainBackgroundColor,
|
|
75
|
+
'--u-header-background-color': headerBackgroundColor,
|
|
76
|
+
'--u-header-border-color': headerBorderColor,
|
|
77
|
+
'--u-header-title-color': headerTitleColor,
|
|
78
|
+
'--u-message-bubble-background-color-own': messageBubbleBackgroundColorOwn,
|
|
79
|
+
'--u-message-bubble-background-color-other': messageBubbleBackgroundColorOther,
|
|
80
|
+
'--u-message-bubble-text-color-own': messageBubbleTextColorOwn,
|
|
81
|
+
'--u-message-bubble-text-color-other': messageBubbleTextColorOther,
|
|
82
|
+
'--u-message-time-color': messageTimeColor,
|
|
83
|
+
'--u-message-status-color': messageStatusColor,
|
|
84
|
+
'--u-attachment-background-color-own': attachmentBackgroundColorOwn,
|
|
85
|
+
'--u-attachment-background-color-other': attachmentBackgroundColorOther,
|
|
86
|
+
'--u-unread-notification-background-color': unreadNotificationBackgroundColor,
|
|
87
|
+
'--u-unread-notification-text-color': unreadNotificationTextColor,
|
|
88
|
+
'--u-typing-indicator-color': typingIndicatorColor,
|
|
89
|
+
'--u-date-separator-color': dateSeparatorColor,
|
|
90
|
+
'--u-date-separator-background-color': dateSeparatorBackgroundColor,
|
|
91
|
+
'--u-border-radius': borderRadius
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
const themeClassHandle = useThemeClass('chat-messages', computed(() => ''), cssVarsRef, props);
|
|
95
|
+
const mergedTypingTextRef = computed(() => { var _a; return (_a = props.typingText) !== null && _a !== void 0 ? _a : localeRef.value.typingText; });
|
|
96
|
+
const mergedRetryTextRef = computed(() => { var _a; return (_a = props.retryText) !== null && _a !== void 0 ? _a : localeRef.value.retryText; });
|
|
97
|
+
const mergedUnreadNotificationTextRef = computed(() => { var _a; return (_a = props.unreadNotificationText) !== null && _a !== void 0 ? _a : localeRef.value.unreadNotificationText; });
|
|
98
|
+
const unreadMessagesCount = computed(() => {
|
|
99
|
+
if (!props.messages)
|
|
100
|
+
return 0;
|
|
101
|
+
return props.messages.filter((msg) => !msg.isOwn && msg.status === MessageStatus.UNREAD).length;
|
|
102
|
+
});
|
|
103
|
+
const handleMessageRetry = (message) => {
|
|
104
|
+
var _a;
|
|
105
|
+
(_a = props.onMessageRetry) === null || _a === void 0 ? void 0 : _a.call(props, message);
|
|
106
|
+
};
|
|
107
|
+
const renderDateSeparator = (date) => {
|
|
108
|
+
return (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__date-separator` },
|
|
109
|
+
h("span", null, date)));
|
|
110
|
+
};
|
|
111
|
+
const renderUnreadNotification = () => {
|
|
112
|
+
var _a;
|
|
113
|
+
const count = (_a = props.unreadNotificationCount) !== null && _a !== void 0 ? _a : unreadMessagesCount.value;
|
|
114
|
+
return (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__unread-notification` },
|
|
115
|
+
h("span", null,
|
|
116
|
+
count,
|
|
117
|
+
" ",
|
|
118
|
+
mergedUnreadNotificationTextRef.value)));
|
|
119
|
+
};
|
|
120
|
+
const renderMarkMessage = (message) => {
|
|
121
|
+
const markTypeClass = message.markType === ChatMarkType.SYSTEM
|
|
122
|
+
? 'system'
|
|
123
|
+
: message.markType === ChatMarkType.EVENT
|
|
124
|
+
? 'event'
|
|
125
|
+
: 'divider';
|
|
126
|
+
return (h("div", { key: message.id, class: [
|
|
127
|
+
`${mergedClsPrefixRef.value}-chat-main__mark`,
|
|
128
|
+
`${mergedClsPrefixRef.value}-chat-main__mark--${markTypeClass}`
|
|
129
|
+
] }, message.content && h("span", null, message.content)));
|
|
130
|
+
};
|
|
131
|
+
const renderMessage = (message) => {
|
|
132
|
+
const isOwn = message.isOwn;
|
|
133
|
+
const attachments = message.attachment
|
|
134
|
+
? Array.isArray(message.attachment)
|
|
135
|
+
? message.attachment
|
|
136
|
+
: [message.attachment]
|
|
137
|
+
: [];
|
|
138
|
+
return (h("div", { key: message.id, class: [
|
|
139
|
+
`${mergedClsPrefixRef.value}-chat-main__message`,
|
|
140
|
+
isOwn
|
|
141
|
+
? `${mergedClsPrefixRef.value}-chat-main__message--own`
|
|
142
|
+
: `${mergedClsPrefixRef.value}-chat-main__message--other`
|
|
143
|
+
] },
|
|
144
|
+
h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-wrapper` },
|
|
145
|
+
message.content || attachments.length > 1 ? (h("div", { class: [
|
|
146
|
+
`${mergedClsPrefixRef.value}-chat-main__message-bubble`,
|
|
147
|
+
isOwn
|
|
148
|
+
? `${mergedClsPrefixRef.value}-chat-main__message-bubble--own`
|
|
149
|
+
: `${mergedClsPrefixRef.value}-chat-main__message-bubble--other`
|
|
150
|
+
] },
|
|
151
|
+
attachments.length > 0 && (h(ChatAttachmentComponent, { message: message, attachments: attachments, uploadProps: props.uploadProps, withPadding: true }, {
|
|
152
|
+
default: slots.messageAttachment,
|
|
153
|
+
'upload-file-title': slots.messageAttachmentTitle,
|
|
154
|
+
'upload-file-subtitle': slots.messageAttachmentSubtitle
|
|
155
|
+
})),
|
|
156
|
+
message.content && (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-text` }, message.content)))) : attachments.length === 1 ? (h(ChatAttachmentComponent, { message: message, attachments: attachments, uploadProps: props.uploadProps }, {
|
|
157
|
+
default: slots.messageAttachment,
|
|
158
|
+
'upload-file-title': slots.messageAttachmentTitle,
|
|
159
|
+
'upload-file-subtitle': slots.messageAttachmentSubtitle
|
|
160
|
+
})) : null,
|
|
161
|
+
h("div", { class: [
|
|
162
|
+
`${mergedClsPrefixRef.value}-chat-main__message-meta`,
|
|
163
|
+
isOwn
|
|
164
|
+
? `${mergedClsPrefixRef.value}-chat-main__message-meta--own`
|
|
165
|
+
: `${mergedClsPrefixRef.value}-chat-main__message-meta--other`,
|
|
166
|
+
message.status === MessageStatus.RETRY &&
|
|
167
|
+
`${mergedClsPrefixRef.value}-chat-main__message-meta--retry`
|
|
168
|
+
] }, message.status === MessageStatus.RETRY ? (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-retry`, onClick: () => {
|
|
169
|
+
handleMessageRetry(message);
|
|
170
|
+
}, style: { cursor: 'pointer' } },
|
|
171
|
+
h(UIcon, { size: 16, component: statusIconMapper[MessageStatus.RETRY], class: `${mergedClsPrefixRef.value}-chat-main__message-retry-icon`, theme: themeRef.value.peers.Icon, themeOverrides: themeRef.value.peerOverrides.Icon }),
|
|
172
|
+
h("span", { class: `${mergedClsPrefixRef.value}-chat-main__message-retry-text` }, mergedRetryTextRef.value))) : (h(Fragment, null,
|
|
173
|
+
h("span", { class: `${mergedClsPrefixRef.value}-chat-main__message-time` }, message.timestamp),
|
|
174
|
+
isOwn && message.status && (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-status` }, slots.messageStatus
|
|
175
|
+
? slots.messageStatus(message)
|
|
176
|
+
: statusIconMapper[message.status] && (h(UIcon, { size: 16, component: statusIconMapper[message.status], class: [
|
|
177
|
+
`${mergedClsPrefixRef.value}-chat-main__message-status-icon`,
|
|
178
|
+
`${mergedClsPrefixRef.value}-chat-main__message-status-icon--${String(message.status)}`
|
|
179
|
+
], theme: themeRef.value.peers.Icon, themeOverrides: themeRef.value.peerOverrides.Icon }))))))))));
|
|
180
|
+
};
|
|
181
|
+
const renderTypingIndicator = () => {
|
|
182
|
+
return (h("div", { class: [
|
|
183
|
+
`${mergedClsPrefixRef.value}-chat-main__message`,
|
|
184
|
+
`${mergedClsPrefixRef.value}-chat-main__message--other`
|
|
185
|
+
] },
|
|
186
|
+
h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-wrapper` },
|
|
187
|
+
h("div", { class: [
|
|
188
|
+
`${mergedClsPrefixRef.value}-chat-main__message-bubble`,
|
|
189
|
+
`${mergedClsPrefixRef.value}-chat-main__message-bubble--other`,
|
|
190
|
+
`${mergedClsPrefixRef.value}-chat-main__message-bubble--typing`
|
|
191
|
+
] }),
|
|
192
|
+
h("div", { class: [
|
|
193
|
+
`${mergedClsPrefixRef.value}-chat-main__message-meta`,
|
|
194
|
+
`${mergedClsPrefixRef.value}-chat-main__message-meta--other`
|
|
195
|
+
] },
|
|
196
|
+
h("span", { class: `${mergedClsPrefixRef.value}-chat-main__message-time` }, mergedTypingTextRef.value)))));
|
|
197
|
+
};
|
|
198
|
+
const renderSkeletonMessage = (isOwn, index) => {
|
|
199
|
+
return (h("div", { key: `skeleton-${index}`, class: [
|
|
200
|
+
`${mergedClsPrefixRef.value}-chat-main__message`,
|
|
201
|
+
isOwn
|
|
202
|
+
? `${mergedClsPrefixRef.value}-chat-main__message--own`
|
|
203
|
+
: `${mergedClsPrefixRef.value}-chat-main__message--other`
|
|
204
|
+
] },
|
|
205
|
+
h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-wrapper` },
|
|
206
|
+
h("div", { class: [
|
|
207
|
+
`${mergedClsPrefixRef.value}-chat-main__message-bubble`,
|
|
208
|
+
isOwn
|
|
209
|
+
? `${mergedClsPrefixRef.value}-chat-main__message-bubble--own`
|
|
210
|
+
: `${mergedClsPrefixRef.value}-chat-main__message-bubble--other`
|
|
211
|
+
] },
|
|
212
|
+
h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-text` },
|
|
213
|
+
h("div", { style: { width: '376px', height: '20px' } }))),
|
|
214
|
+
h("div", { class: [
|
|
215
|
+
`${mergedClsPrefixRef.value}-chat-main__message-meta`,
|
|
216
|
+
isOwn
|
|
217
|
+
? `${mergedClsPrefixRef.value}-chat-main__message-meta--own`
|
|
218
|
+
: `${mergedClsPrefixRef.value}-chat-main__message-meta--other`
|
|
219
|
+
] },
|
|
220
|
+
h(USkeleton, { style: { width: '36px', height: '20px', borderRadius: '4px' } })))));
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
mergedClsPrefixRef,
|
|
224
|
+
mergedTheme: themeRef,
|
|
225
|
+
renderMessage,
|
|
226
|
+
renderMarkMessage,
|
|
227
|
+
renderTypingIndicator,
|
|
228
|
+
renderSkeletonMessage,
|
|
229
|
+
renderDateSeparator,
|
|
230
|
+
renderUnreadNotification,
|
|
231
|
+
cssVars: cssVarsRef,
|
|
232
|
+
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
233
|
+
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
render() {
|
|
237
|
+
var _a, _b, _c;
|
|
238
|
+
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
239
|
+
const { mergedClsPrefixRef, renderMessage, renderMarkMessage, renderTypingIndicator, renderSkeletonMessage, renderDateSeparator, renderUnreadNotification } = this;
|
|
240
|
+
if (this.loading) {
|
|
241
|
+
return (h("div", { class: [`${mergedClsPrefixRef}-chat`, this.themeClass], style: this.cssVars },
|
|
242
|
+
h("div", { class: `${mergedClsPrefixRef}-chat-main`, style: {
|
|
243
|
+
border: 'none',
|
|
244
|
+
borderRadius: '0',
|
|
245
|
+
padding: '0',
|
|
246
|
+
background: 'transparent'
|
|
247
|
+
} },
|
|
248
|
+
h("div", { class: `${mergedClsPrefixRef}-chat-main__messages` }, Array.from({ length: this.loadingCount || 5 }).map((_, index) => {
|
|
249
|
+
const isOwn = index % 2 === 0;
|
|
250
|
+
return renderSkeletonMessage(isOwn, index);
|
|
251
|
+
})))));
|
|
252
|
+
}
|
|
253
|
+
const messagesWithDates = [];
|
|
254
|
+
let currentDate = '';
|
|
255
|
+
let unreadNotificationInserted = false;
|
|
256
|
+
(_b = this.messages) === null || _b === void 0 ? void 0 : _b.forEach((message, index) => {
|
|
257
|
+
const messageDate = message.date || '';
|
|
258
|
+
if (messageDate !== currentDate) {
|
|
259
|
+
messagesWithDates.push({
|
|
260
|
+
type: 'date-separator',
|
|
261
|
+
date: messageDate,
|
|
262
|
+
id: `date-${String(index)}`
|
|
263
|
+
});
|
|
264
|
+
currentDate = messageDate;
|
|
265
|
+
}
|
|
266
|
+
if (!unreadNotificationInserted &&
|
|
267
|
+
!message.isOwn &&
|
|
268
|
+
message.status === MessageStatus.UNREAD &&
|
|
269
|
+
this.showUnreadNotification) {
|
|
270
|
+
messagesWithDates.push({
|
|
271
|
+
type: 'unread-notification',
|
|
272
|
+
id: 'unread-notification'
|
|
273
|
+
});
|
|
274
|
+
unreadNotificationInserted = true;
|
|
275
|
+
}
|
|
276
|
+
messagesWithDates.push(Object.assign({ type: 'message' }, message));
|
|
277
|
+
});
|
|
278
|
+
if (!unreadNotificationInserted && this.showUnreadNotification) {
|
|
279
|
+
const unreadCount = this.unreadNotificationCount || 0;
|
|
280
|
+
let incomingMessagesFound = 0;
|
|
281
|
+
let insertIndex = messagesWithDates.length;
|
|
282
|
+
for (let i = messagesWithDates.length - 1; i >= 0; i--) {
|
|
283
|
+
const item = messagesWithDates[i];
|
|
284
|
+
if (item.type === 'message') {
|
|
285
|
+
const message = item;
|
|
286
|
+
if (!message.isOwn) {
|
|
287
|
+
incomingMessagesFound++;
|
|
288
|
+
if (incomingMessagesFound === unreadCount) {
|
|
289
|
+
insertIndex = i;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
messagesWithDates.splice(insertIndex, 0, {
|
|
296
|
+
type: 'unread-notification',
|
|
297
|
+
id: 'unread-notification'
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
const isTyping = this.selectedChatId && ((_c = this.typingChatIds) === null || _c === void 0 ? void 0 : _c.includes(this.selectedChatId));
|
|
301
|
+
return (h("div", { class: [`${mergedClsPrefixRef}-chat`, this.themeClass], style: this.cssVars },
|
|
302
|
+
h("div", { class: `${mergedClsPrefixRef}-chat-main`, style: {
|
|
303
|
+
border: 'none',
|
|
304
|
+
borderRadius: '0',
|
|
305
|
+
padding: '0',
|
|
306
|
+
background: 'transparent'
|
|
307
|
+
} },
|
|
308
|
+
h("div", { class: `${mergedClsPrefixRef}-chat-main__messages-container` },
|
|
309
|
+
messagesWithDates.map((item) => {
|
|
310
|
+
var _a;
|
|
311
|
+
if (item.type === 'date-separator') {
|
|
312
|
+
return renderDateSeparator((_a = item.date) !== null && _a !== void 0 ? _a : '');
|
|
313
|
+
}
|
|
314
|
+
if (item.type === 'unread-notification') {
|
|
315
|
+
return renderUnreadNotification();
|
|
316
|
+
}
|
|
317
|
+
const message = item;
|
|
318
|
+
if (message.type === ChatMessageType.MARK) {
|
|
319
|
+
return renderMarkMessage(message);
|
|
320
|
+
}
|
|
321
|
+
return renderMessage(message);
|
|
322
|
+
}),
|
|
323
|
+
isTyping && renderTypingIndicator()))));
|
|
324
|
+
}
|
|
325
|
+
});
|
|
@@ -47,8 +47,8 @@ export default defineComponent({
|
|
|
47
47
|
gap: '2px',
|
|
48
48
|
marginTop: '0'
|
|
49
49
|
}
|
|
50
|
-
: undefined, showRemoveButton: false, showDownloadButton: props.attachments.some((att) => att.status === 'finished'), showRetryButton: props.attachments.some((att) => att.status === 'error') }, props.uploadProps),
|
|
51
|
-
h(UUploadFileList, null, {
|
|
50
|
+
: undefined, showRemoveButton: false, showDownloadButton: props.attachments.some((att) => att.status === 'finished'), showRetryButton: props.attachments.some((att) => att.status === 'error') }, props.uploadProps), {
|
|
51
|
+
default: () => (h(UUploadFileList, null, {
|
|
52
52
|
'upload-file-title': slots['upload-file-title']
|
|
53
53
|
? ({ file }) => { var _a; return (_a = slots['upload-file-title']) === null || _a === void 0 ? void 0 : _a.call(slots, file); }
|
|
54
54
|
: undefined,
|
|
@@ -59,7 +59,8 @@ export default defineComponent({
|
|
|
59
59
|
const att = props.attachments.find((a) => a.name === file.name);
|
|
60
60
|
return (h("span", { style: { fontSize: '12px', color: '#999' } }, (att === null || att === void 0 ? void 0 : att.size) || ((_a = file.file) === null || _a === void 0 ? void 0 : _a.size)));
|
|
61
61
|
}
|
|
62
|
-
}))
|
|
62
|
+
}))
|
|
63
|
+
}));
|
|
63
64
|
if (props.withPadding) {
|
|
64
65
|
return h("div", { style: { padding: '2px' } }, uploadComponent);
|
|
65
66
|
}
|
|
@@ -2,8 +2,6 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
2
2
|
renderHeader: () => JSX.Element;
|
|
3
3
|
renderMessages: () => JSX.Element;
|
|
4
4
|
renderFooter: () => JSX.Element;
|
|
5
|
-
renderUnreadNotification: () => JSX.Element | null;
|
|
6
|
-
showUnreadNotification: import("vue").ComputedRef<boolean>;
|
|
7
5
|
messagesBodyRef: import("vue").Ref<HTMLElement | {
|
|
8
6
|
$el: HTMLElement;
|
|
9
7
|
} | undefined>;
|