@uzum-tech/ui 1.7.0 → 1.7.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.
Files changed (204) hide show
  1. package/dist/index.js +1365 -41760
  2. package/dist/index.prod.js +3 -3
  3. package/es/_internal/icons/CheckmarkDoneSharp.d.ts +2 -0
  4. package/es/_internal/icons/CheckmarkDoneSharp.js +10 -0
  5. package/es/_internal/icons/MdTime.d.ts +2 -0
  6. package/es/_internal/icons/MdTime.js +10 -0
  7. package/es/_internal/icons/PersonOutline.d.ts +2 -0
  8. package/es/_internal/icons/PersonOutline.js +9 -0
  9. package/es/_internal/icons/Refresh.d.ts +2 -0
  10. package/es/_internal/icons/Refresh.js +9 -0
  11. package/es/_internal/icons/index.d.ts +4 -0
  12. package/es/_internal/icons/index.js +4 -0
  13. package/es/_internal/select-menu/src/styles/index.cssr.js +2 -1
  14. package/es/_internal/select-menu/styles/light.js +1 -1
  15. package/es/_internal/selection/src/Selection.d.ts +0 -16
  16. package/es/_internal/selection/src/Selection.js +3 -4
  17. package/es/_internal/selection/src/styles/index.cssr.js +0 -4
  18. package/es/_internal/selection/styles/light.d.ts +0 -4
  19. package/es/_internal/selection/styles/light.js +1 -3
  20. package/es/cascader/src/Cascader.d.ts +0 -20
  21. package/es/cascader/src/CascaderMenu.d.ts +0 -2
  22. package/es/cascader/src/CascaderOption.d.ts +0 -2
  23. package/es/cascader/src/CascaderSelectMenu.d.ts +0 -2
  24. package/es/cascader/src/CascaderSubmenu.d.ts +0 -2
  25. package/es/cascader/styles/light.d.ts +0 -2
  26. package/es/chat/src/Chat.d.ts +38 -34
  27. package/es/chat/src/Chat.js +28 -7
  28. package/es/chat/src/ChatGlobalState.d.ts +13 -0
  29. package/es/chat/src/ChatGlobalState.js +32 -0
  30. package/es/chat/src/ChatParts/ChatAttachment.d.ts +43 -0
  31. package/es/chat/src/ChatParts/ChatAttachment.js +75 -0
  32. package/es/chat/src/ChatParts/MainArea.d.ts +3 -9
  33. package/es/chat/src/ChatParts/MainArea.js +129 -123
  34. package/es/chat/src/ChatParts/Sidebar.js +12 -19
  35. package/es/chat/src/interface.d.ts +8 -3
  36. package/es/chat/src/styles/index.cssr.js +7 -0
  37. package/es/chat/styles/dark.d.ts +0 -2
  38. package/es/chat/styles/light.d.ts +0 -2
  39. package/es/data-table/src/DataTable.d.ts +0 -16
  40. package/es/data-table/src/HeaderButton/FilterButton.d.ts +0 -4
  41. package/es/data-table/src/HeaderButton/FilterMenu.d.ts +0 -4
  42. package/es/data-table/src/TableParts/Body.d.ts +0 -4
  43. package/es/data-table/src/TableParts/Body.js +3 -1
  44. package/es/data-table/src/TableParts/Cell.js +18 -5
  45. package/es/data-table/src/TableParts/Header.d.ts +0 -4
  46. package/es/data-table/src/interface.d.ts +1 -7
  47. package/es/data-table/src/utils.js +1 -1
  48. package/es/data-table/styles/light.d.ts +0 -2
  49. package/es/dynamic-tags/src/DynamicTags.d.ts +4 -454
  50. package/es/dynamic-tags/styles/light.d.ts +0 -45
  51. package/es/empty/styles/light.js +3 -3
  52. package/es/locales/common/arDZ.js +6 -0
  53. package/es/locales/common/deDE.js +6 -0
  54. package/es/locales/common/enGB.js +6 -0
  55. package/es/locales/common/enUS.d.ts +6 -0
  56. package/es/locales/common/enUS.js +6 -0
  57. package/es/locales/common/eo.js +6 -0
  58. package/es/locales/common/esAR.js +6 -0
  59. package/es/locales/common/faIR.js +6 -0
  60. package/es/locales/common/frFR.js +6 -0
  61. package/es/locales/common/idID.js +6 -0
  62. package/es/locales/common/itIT.js +6 -0
  63. package/es/locales/common/jaJP.js +6 -0
  64. package/es/locales/common/koKR.js +6 -0
  65. package/es/locales/common/nbNO.js +6 -0
  66. package/es/locales/common/nlNL.js +6 -0
  67. package/es/locales/common/plPL.js +6 -0
  68. package/es/locales/common/ptBR.js +6 -0
  69. package/es/locales/common/ruRU.js +6 -0
  70. package/es/locales/common/skSK.js +6 -0
  71. package/es/locales/common/svSE.js +6 -0
  72. package/es/locales/common/thTH.js +6 -0
  73. package/es/locales/common/trTR.js +6 -0
  74. package/es/locales/common/ukUA.js +6 -0
  75. package/es/locales/common/viVN.js +6 -0
  76. package/es/locales/common/zhCN.js +6 -0
  77. package/es/locales/common/zhTW.js +6 -0
  78. package/es/pagination/src/Pagination.d.ts +0 -22
  79. package/es/pagination/styles/light.d.ts +0 -2
  80. package/es/select/src/Select.d.ts +0 -20
  81. package/es/select/styles/light.d.ts +0 -2
  82. package/es/status/src/Status.d.ts +14 -13
  83. package/es/status/src/Status.js +10 -13
  84. package/es/status/src/interface.d.ts +5 -1
  85. package/es/status/src/styles/index.cssr.js +1 -1
  86. package/es/status/styles/light.d.ts +1 -1
  87. package/es/status/styles/light.js +3 -3
  88. package/es/steps/src/Step.js +1 -5
  89. package/es/steps/src/styles/index.cssr.js +2 -1
  90. package/es/tabs/src/Tab.js +8 -3
  91. package/es/tabs/src/Tabs.js +2 -1
  92. package/es/tabs/src/interface.d.ts +1 -0
  93. package/es/tag/src/Tag.d.ts +4 -409
  94. package/es/tag/src/Tag.js +3 -0
  95. package/es/tag/src/common-props.d.ts +1 -1
  96. package/es/tag/styles/light.d.ts +0 -45
  97. package/es/tag/styles/light.js +2 -58
  98. package/es/tree-select/src/TreeSelect.d.ts +0 -20
  99. package/es/tree-select/styles/light.d.ts +0 -2
  100. package/es/upload/src/useUploadActionsRender.js +1 -1
  101. package/es/version.d.ts +1 -1
  102. package/es/version.js +1 -1
  103. package/lib/_internal/icons/CheckmarkDoneSharp.d.ts +2 -0
  104. package/lib/_internal/icons/CheckmarkDoneSharp.js +12 -0
  105. package/lib/_internal/icons/MdTime.d.ts +2 -0
  106. package/lib/_internal/icons/MdTime.js +12 -0
  107. package/lib/_internal/icons/PersonOutline.d.ts +2 -0
  108. package/lib/_internal/icons/PersonOutline.js +11 -0
  109. package/lib/_internal/icons/Refresh.d.ts +2 -0
  110. package/lib/_internal/icons/Refresh.js +11 -0
  111. package/lib/_internal/icons/index.d.ts +4 -0
  112. package/lib/_internal/icons/index.js +9 -1
  113. package/lib/_internal/select-menu/src/styles/index.cssr.js +2 -1
  114. package/lib/_internal/select-menu/styles/light.js +1 -1
  115. package/lib/_internal/selection/src/Selection.d.ts +0 -16
  116. package/lib/_internal/selection/src/Selection.js +3 -4
  117. package/lib/_internal/selection/src/styles/index.cssr.js +0 -4
  118. package/lib/_internal/selection/styles/light.d.ts +0 -4
  119. package/lib/_internal/selection/styles/light.js +1 -3
  120. package/lib/cascader/src/Cascader.d.ts +0 -20
  121. package/lib/cascader/src/CascaderMenu.d.ts +0 -2
  122. package/lib/cascader/src/CascaderOption.d.ts +0 -2
  123. package/lib/cascader/src/CascaderSelectMenu.d.ts +0 -2
  124. package/lib/cascader/src/CascaderSubmenu.d.ts +0 -2
  125. package/lib/cascader/styles/light.d.ts +0 -2
  126. package/lib/chat/src/Chat.d.ts +38 -34
  127. package/lib/chat/src/Chat.js +27 -6
  128. package/lib/chat/src/ChatGlobalState.d.ts +13 -0
  129. package/lib/chat/src/ChatGlobalState.js +36 -0
  130. package/lib/chat/src/ChatParts/ChatAttachment.d.ts +43 -0
  131. package/lib/chat/src/ChatParts/ChatAttachment.js +77 -0
  132. package/lib/chat/src/ChatParts/MainArea.d.ts +3 -9
  133. package/lib/chat/src/ChatParts/MainArea.js +135 -126
  134. package/lib/chat/src/ChatParts/Sidebar.js +16 -23
  135. package/lib/chat/src/interface.d.ts +8 -3
  136. package/lib/chat/src/styles/index.cssr.js +7 -0
  137. package/lib/chat/styles/dark.d.ts +0 -2
  138. package/lib/chat/styles/light.d.ts +0 -2
  139. package/lib/data-table/src/DataTable.d.ts +0 -16
  140. package/lib/data-table/src/HeaderButton/FilterButton.d.ts +0 -4
  141. package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +0 -4
  142. package/lib/data-table/src/TableParts/Body.d.ts +0 -4
  143. package/lib/data-table/src/TableParts/Body.js +3 -1
  144. package/lib/data-table/src/TableParts/Cell.js +18 -5
  145. package/lib/data-table/src/TableParts/Header.d.ts +0 -4
  146. package/lib/data-table/src/interface.d.ts +1 -7
  147. package/lib/data-table/src/utils.js +1 -1
  148. package/lib/data-table/styles/light.d.ts +0 -2
  149. package/lib/dynamic-tags/src/DynamicTags.d.ts +4 -454
  150. package/lib/dynamic-tags/styles/light.d.ts +0 -45
  151. package/lib/empty/styles/light.js +3 -3
  152. package/lib/locales/common/arDZ.js +6 -0
  153. package/lib/locales/common/deDE.js +6 -0
  154. package/lib/locales/common/enGB.js +6 -0
  155. package/lib/locales/common/enUS.d.ts +6 -0
  156. package/lib/locales/common/enUS.js +6 -0
  157. package/lib/locales/common/eo.js +6 -0
  158. package/lib/locales/common/esAR.js +6 -0
  159. package/lib/locales/common/faIR.js +6 -0
  160. package/lib/locales/common/frFR.js +6 -0
  161. package/lib/locales/common/idID.js +6 -0
  162. package/lib/locales/common/itIT.js +6 -0
  163. package/lib/locales/common/jaJP.js +6 -0
  164. package/lib/locales/common/koKR.js +6 -0
  165. package/lib/locales/common/nbNO.js +6 -0
  166. package/lib/locales/common/nlNL.js +6 -0
  167. package/lib/locales/common/plPL.js +6 -0
  168. package/lib/locales/common/ptBR.js +6 -0
  169. package/lib/locales/common/ruRU.js +6 -0
  170. package/lib/locales/common/skSK.js +6 -0
  171. package/lib/locales/common/svSE.js +6 -0
  172. package/lib/locales/common/thTH.js +6 -0
  173. package/lib/locales/common/trTR.js +6 -0
  174. package/lib/locales/common/ukUA.js +6 -0
  175. package/lib/locales/common/viVN.js +6 -0
  176. package/lib/locales/common/zhCN.js +6 -0
  177. package/lib/locales/common/zhTW.js +6 -0
  178. package/lib/pagination/src/Pagination.d.ts +0 -22
  179. package/lib/pagination/styles/light.d.ts +0 -2
  180. package/lib/select/src/Select.d.ts +0 -20
  181. package/lib/select/styles/light.d.ts +0 -2
  182. package/lib/status/src/Status.d.ts +14 -13
  183. package/lib/status/src/Status.js +9 -12
  184. package/lib/status/src/interface.d.ts +5 -1
  185. package/lib/status/src/styles/index.cssr.js +1 -1
  186. package/lib/status/styles/light.d.ts +1 -1
  187. package/lib/status/styles/light.js +3 -3
  188. package/lib/steps/src/Step.js +1 -5
  189. package/lib/steps/src/styles/index.cssr.js +2 -1
  190. package/lib/tabs/src/Tab.js +7 -2
  191. package/lib/tabs/src/Tabs.js +2 -1
  192. package/lib/tabs/src/interface.d.ts +1 -0
  193. package/lib/tag/src/Tag.d.ts +4 -409
  194. package/lib/tag/src/Tag.js +3 -0
  195. package/lib/tag/src/common-props.d.ts +1 -1
  196. package/lib/tag/styles/light.d.ts +0 -45
  197. package/lib/tag/styles/light.js +2 -58
  198. package/lib/tree-select/src/TreeSelect.d.ts +0 -20
  199. package/lib/tree-select/styles/light.d.ts +0 -2
  200. package/lib/upload/src/useUploadActionsRender.js +1 -1
  201. package/lib/version.d.ts +1 -1
  202. package/lib/version.js +1 -1
  203. package/package.json +1 -1
  204. package/web-types.json +58 -19
@@ -9,35 +9,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { h, defineComponent, inject, computed, ref, watch, nextTick, onMounted, Fragment } from 'vue';
11
11
  import { ArrowHookUpRight20Filled, PersonNote20Regular, Attach16Filled } from '@vicons/fluent';
12
- import { CheckmarkDoneSharp, Refresh } from '@vicons/ionicons5';
13
- import { MdTime } from '@vicons/ionicons4';
14
12
  import { MessageStatus, ChatMessageType, chatInjectionKey } from '../interface';
15
13
  import { UInput } from '../../../input';
16
14
  import { UButton } from '../../../button';
17
15
  import { UIcon } from '../../../icon';
18
16
  import { UScrollbar } from '../../../scrollbar';
19
- import { UUpload, UUploadTrigger, UUploadFileList } from '../../../upload';
17
+ import { UUpload, UUploadTrigger } from '../../../upload';
20
18
  import { UFlex } from '../../../flex';
21
19
  import { resolveSlot } from '../../../_utils';
22
20
  import { UText } from '../../../typography';
23
- const initChatGlobalState = () => {
24
- var _a, _b;
25
- if (typeof window === 'undefined') {
26
- return {
27
- notificationsShown: new Set(),
28
- openedChats: new Set()
29
- };
30
- }
31
- if (!((_a = window.__chatGlobalState) === null || _a === void 0 ? void 0 : _a.notificationsShown) ||
32
- !((_b = window.__chatGlobalState) === null || _b === void 0 ? void 0 : _b.openedChats)) {
33
- window.__chatGlobalState = {
34
- notificationsShown: new Set(),
35
- openedChats: new Set()
36
- };
37
- }
38
- return window.__chatGlobalState;
39
- };
40
- const getChatGlobalState = () => initChatGlobalState();
21
+ import { USkeleton } from '../../../skeleton';
22
+ import { CheckmarkDoneSharp, Refresh, MdTime } from '../../../_internal/icons';
23
+ import { ChatGlobalState } from '../ChatGlobalState';
24
+ import ChatAttachmentComponent from './ChatAttachment';
25
+ const SCROLL_DELAY = 50;
26
+ const SENDING_DELAY = 100;
27
+ const getChatGlobalState = () => ChatGlobalState.getInstance();
41
28
  const statusIconMapper = {
42
29
  [MessageStatus.READ]: CheckmarkDoneSharp,
43
30
  [MessageStatus.PENDING]: MdTime,
@@ -47,7 +34,7 @@ const statusIconMapper = {
47
34
  export default defineComponent({
48
35
  name: 'ChatMainArea',
49
36
  setup(_, { slots }) {
50
- const { mergedClsPrefixRef, selectedChatRef, messagesRef, typingChatIdsRef, messagesLoadingRef, headerButtonPropsRef, headerIconPropsRef, messageUploadPropsRef, footerInputPropsRef, footerButtonPropsRef, footerUploadPropsRef, footerIconPropsRef, retryTextRef, typingTextRef, closeButtonTextRef, handleMessageSend, handleMessageRetry, onChatClose, onChatShare, onUserProfile
37
+ const { mergedClsPrefixRef, selectedChatRef, messagesRef, typingChatIdsRef, messagesLoadingRef, messagesLoadingCountRef, headerButtonPropsRef, headerIconPropsRef, messageUploadPropsRef, footerInputPropsRef, footerButtonPropsRef, footerUploadPropsRef, footerIconPropsRef, inputPlaceholderRef, retryTextRef, typingTextRef, closeButtonTextRef, handleMessageSend, handleMessageRetry, onChatClose, onChatShare, onUserProfile
51
38
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
52
39
  } = inject(chatInjectionKey);
53
40
  const messagesBodyRef = ref();
@@ -68,12 +55,12 @@ export default defineComponent({
68
55
  inputValue.value = chatInputs.value[newChat.id] || '';
69
56
  unreadCountOnOpen.value = unreadMessagesCount.value;
70
57
  const globalState = getChatGlobalState();
71
- globalState.openedChats.add(newChat.id);
58
+ globalState.markChatOpened(newChat.id);
72
59
  if (unreadCountOnOpen.value > 0 &&
73
- !globalState.notificationsShown.has(newChat.id)) {
60
+ !globalState.hasNotificationShown(newChat.id)) {
74
61
  hasUnreadMessages.value = true;
75
62
  showNotificationManually.value = true;
76
- globalState.notificationsShown.add(newChat.id);
63
+ globalState.markNotificationShown(newChat.id);
77
64
  }
78
65
  else {
79
66
  hasUnreadMessages.value = false;
@@ -90,7 +77,7 @@ export default defineComponent({
90
77
  newMessages.length > oldMessages.length) {
91
78
  if (selectedChatRef.value) {
92
79
  const globalState = getChatGlobalState();
93
- if (globalState.notificationsShown.has(selectedChatRef.value.id)) {
80
+ if (globalState.hasNotificationShown(selectedChatRef.value.id)) {
94
81
  showNotificationManually.value = false;
95
82
  }
96
83
  }
@@ -116,19 +103,20 @@ export default defineComponent({
116
103
  });
117
104
  });
118
105
  const scrollToBottom = () => {
119
- var _a;
120
- if (messagesBodyRef.value) {
121
- if (typeof messagesBodyRef.value.scrollTo === 'function') {
122
- messagesBodyRef.value.scrollTo({ top: 999999, behavior: 'smooth' });
123
- }
124
- else if ((_a = messagesBodyRef.value) === null || _a === void 0 ? void 0 : _a.$el) {
125
- const scrollContainer = messagesBodyRef.value.$el.querySelector('.u-scrollbar-content') ||
126
- messagesBodyRef.value.$el;
127
- scrollContainer.scrollTop = scrollContainer.scrollHeight;
128
- }
129
- else {
130
- messagesBodyRef.value.scrollTop = messagesBodyRef.value.scrollHeight;
131
- }
106
+ const el = messagesBodyRef.value;
107
+ if (!el)
108
+ return;
109
+ if ('scrollTo' in el && typeof el.scrollTo === 'function') {
110
+ el.scrollTo({ top: 999999, behavior: 'smooth' });
111
+ return;
112
+ }
113
+ if ('$el' in el && el.$el instanceof HTMLElement) {
114
+ const scrollContainer = el.$el.querySelector('.u-scrollbar-content') || el.$el;
115
+ scrollContainer.scrollTop = scrollContainer.scrollHeight;
116
+ return;
117
+ }
118
+ if ('scrollTop' in el && 'scrollHeight' in el) {
119
+ el.scrollTop = el.scrollHeight;
132
120
  }
133
121
  };
134
122
  const renderUnreadNotification = () => {
@@ -165,23 +153,6 @@ export default defineComponent({
165
153
  ? message.attachment
166
154
  : [message.attachment]
167
155
  : [];
168
- const fileList = attachments.map((att, index) => {
169
- var _a, _b;
170
- return ({
171
- id: `${String(message.id)}-attachment-${index}`,
172
- name: att.name,
173
- status: att.status || 'finished',
174
- percentage: (_a = att.percentage) !== null && _a !== void 0 ? _a : null,
175
- url: (_b = att.url) !== null && _b !== void 0 ? _b : null,
176
- thumbnailUrl: typeof att.preview === 'string'
177
- ? att.preview
178
- : typeof att.thumbnail === 'string'
179
- ? att.thumbnail
180
- : null,
181
- file: null,
182
- batchId: null
183
- });
184
- });
185
156
  return (h("div", { key: message.id, class: [
186
157
  `${mergedClsPrefixRef.value}-chat-main__message`,
187
158
  isOwn
@@ -195,42 +166,16 @@ export default defineComponent({
195
166
  ? `${mergedClsPrefixRef.value}-chat-main__message-bubble--own`
196
167
  : `${mergedClsPrefixRef.value}-chat-main__message-bubble--other`
197
168
  ] },
198
- attachments.length > 0 &&
199
- (slots.messageAttachment ? (slots.messageAttachment(message)) : (h("div", { style: { padding: '2px' } },
200
- h(UUpload, Object.assign({ abstract: true, fileList: fileList, fileListStyle: {
201
- display: 'flex',
202
- flexDirection: 'column',
203
- gap: '2px',
204
- marginTop: '0'
205
- }, showRemoveButton: false, showDownloadButton: attachments.some((att) => att.status === 'finished'), showRetryButton: attachments.some((att) => att.status === 'error') }, messageUploadPropsRef.value),
206
- h(UUploadFileList, null, {
207
- 'upload-file-title': slots.messageAttachmentTitle
208
- ? ({ file }) => { var _a; return (_a = slots.messageAttachmentTitle) === null || _a === void 0 ? void 0 : _a.call(slots, file); }
209
- : undefined,
210
- 'upload-file-subtitle': slots.messageAttachmentSubtitle
211
- ? ({ file }) => { var _a; return (_a = slots.messageAttachmentSubtitle) === null || _a === void 0 ? void 0 : _a.call(slots, file); }
212
- : ({ file }) => {
213
- var _a;
214
- const att = attachments.find((a) => a.name === file.name);
215
- return (h("span", { style: {
216
- fontSize: '12px',
217
- color: '#999'
218
- } }, (att === null || att === void 0 ? void 0 : att.size) || ((_a = file.file) === null || _a === void 0 ? void 0 : _a.size)));
219
- }
220
- }))))),
221
- message.content && (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-text` }, message.content)))) : attachments.length === 1 ? (slots.messageAttachment ? (slots.messageAttachment(message)) : (h(UUpload, Object.assign({ abstract: true, fileList: fileList, showRemoveButton: false, showDownloadButton: attachments.some((att) => att.status === 'finished'), showRetryButton: attachments.some((att) => att.status === 'error') }, messageUploadPropsRef.value),
222
- h(UUploadFileList, null, {
223
- 'upload-file-title': slots.messageAttachmentTitle
224
- ? ({ file }) => { var _a; return (_a = slots.messageAttachmentTitle) === null || _a === void 0 ? void 0 : _a.call(slots, file); }
225
- : undefined,
169
+ attachments.length > 0 && (h(ChatAttachmentComponent, { message: message, attachments: attachments, uploadProps: messageUploadPropsRef.value, withPadding: true }, {
170
+ default: slots.messageAttachment,
171
+ 'upload-file-title': slots.messageAttachmentTitle,
226
172
  'upload-file-subtitle': slots.messageAttachmentSubtitle
227
- ? ({ file }) => { var _a; return (_a = slots.messageAttachmentSubtitle) === null || _a === void 0 ? void 0 : _a.call(slots, file); }
228
- : ({ file }) => {
229
- var _a;
230
- const att = attachments.find((a) => a.name === file.name);
231
- 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)));
232
- }
233
- })))) : null,
173
+ })),
174
+ message.content && (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-text` }, message.content)))) : attachments.length === 1 ? (h(ChatAttachmentComponent, { message: message, attachments: attachments, uploadProps: messageUploadPropsRef.value }, {
175
+ default: slots.messageAttachment,
176
+ 'upload-file-title': slots.messageAttachmentTitle,
177
+ 'upload-file-subtitle': slots.messageAttachmentSubtitle
178
+ })) : null,
234
179
  h("div", { class: [
235
180
  `${mergedClsPrefixRef.value}-chat-main__message-meta`,
236
181
  isOwn
@@ -268,16 +213,43 @@ export default defineComponent({
268
213
  ] },
269
214
  h("span", { class: `${mergedClsPrefixRef.value}-chat-main__message-time` }, typingTextRef.value)))));
270
215
  };
216
+ const renderSkeletonMessage = (isOwn, index) => {
217
+ return (h("div", { key: `skeleton-${index}`, class: [
218
+ `${mergedClsPrefixRef.value}-chat-main__message`,
219
+ isOwn
220
+ ? `${mergedClsPrefixRef.value}-chat-main__message--own`
221
+ : `${mergedClsPrefixRef.value}-chat-main__message--other`
222
+ ] },
223
+ h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-wrapper` },
224
+ h("div", { class: [
225
+ `${mergedClsPrefixRef.value}-chat-main__message-bubble`,
226
+ isOwn
227
+ ? `${mergedClsPrefixRef.value}-chat-main__message-bubble--own`
228
+ : `${mergedClsPrefixRef.value}-chat-main__message-bubble--other`
229
+ ] },
230
+ h("div", { class: `${mergedClsPrefixRef.value}-chat-main__message-text` },
231
+ h("div", { style: { width: '376px', height: '20px' } }))),
232
+ h("div", { class: [
233
+ `${mergedClsPrefixRef.value}-chat-main__message-meta`,
234
+ isOwn
235
+ ? `${mergedClsPrefixRef.value}-chat-main__message-meta--own`
236
+ : `${mergedClsPrefixRef.value}-chat-main__message-meta--other`
237
+ ] },
238
+ h(USkeleton, { style: { width: '36px', height: '20px', borderRadius: '4px' } })))));
239
+ };
271
240
  const renderMessages = () => {
272
241
  var _a, _b;
273
242
  if (messagesLoadingRef.value) {
274
- return (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__loading` }, "Loading messages..."));
243
+ return (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__messages` }, Array.from({ length: messagesLoadingCountRef.value || 5 }).map((_, index) => {
244
+ const isOwn = index % 2 === 0;
245
+ return renderSkeletonMessage(isOwn, index);
246
+ })));
275
247
  }
276
248
  const messagesWithDates = [];
277
249
  let currentDate = '';
278
250
  let unreadNotificationInserted = false;
279
251
  (_a = messagesRef.value) === null || _a === void 0 ? void 0 : _a.forEach((message, index) => {
280
- const messageDate = message.date || '12 августа';
252
+ const messageDate = message.date || '';
281
253
  if (messageDate !== currentDate) {
282
254
  messagesWithDates.push({
283
255
  type: 'date-separator',
@@ -318,17 +290,36 @@ export default defineComponent({
318
290
  if (isSending.value) {
319
291
  return;
320
292
  }
321
- if (inputValue.value.trim() &&
293
+ const hasContent = inputValue.value.trim();
294
+ const hasAttachments = attachmentFileList.value.length > 0;
295
+ if ((hasContent || hasAttachments) &&
322
296
  selectedChatRef.value &&
323
297
  handleMessageSend) {
324
298
  isSending.value = true;
325
299
  try {
326
- handleMessageSend(inputValue.value.trim());
300
+ const attachments = attachmentFileList.value.length > 0
301
+ ? attachmentFileList.value.map((file) => {
302
+ var _a, _b, _c;
303
+ return ({
304
+ id: file.id,
305
+ type: ChatMessageType.FILE,
306
+ name: file.name,
307
+ url: file.url ||
308
+ (file.file ? URL.createObjectURL(file.file) : '#'),
309
+ size: (_a = file.file) === null || _a === void 0 ? void 0 : _a.size,
310
+ thumbnail: (_b = file.thumbnailUrl) !== null && _b !== void 0 ? _b : undefined,
311
+ status: file.status,
312
+ percentage: (_c = file.percentage) !== null && _c !== void 0 ? _c : undefined
313
+ });
314
+ })
315
+ : undefined;
316
+ handleMessageSend(inputValue.value.trim(), attachments);
327
317
  inputValue.value = '';
318
+ attachmentFileList.value = [];
328
319
  chatInputs.value[selectedChatRef.value.id] = '';
329
320
  const globalState = getChatGlobalState();
330
- if (globalState.notificationsShown.has(selectedChatRef.value.id)) {
331
- globalState.notificationsShown.delete(selectedChatRef.value.id);
321
+ if (globalState.hasNotificationShown(selectedChatRef.value.id)) {
322
+ globalState.markNotificationShown(selectedChatRef.value.id);
332
323
  showNotificationManually.value = false;
333
324
  hasUnreadMessages.value = false;
334
325
  }
@@ -337,39 +328,54 @@ export default defineComponent({
337
328
  });
338
329
  setTimeout(() => {
339
330
  scrollToBottom();
340
- }, 50);
331
+ }, SCROLL_DELAY);
341
332
  }
342
333
  finally {
343
334
  setTimeout(() => {
344
335
  isSending.value = false;
345
- }, 100);
336
+ }, SENDING_DELAY);
346
337
  }
347
338
  }
348
339
  });
340
+ let fileUploadTimer = null;
341
+ const pendingFiles = ref([]);
349
342
  const handleFileListUpdate = (fileList) => {
350
- const newFiles = fileList.filter((file) => !attachmentFileList.value.some((existing) => existing.id === file.id));
351
- if (newFiles.length > 0 && handleMessageSend) {
352
- const attachments = newFiles.map((file) => {
353
- var _a, _b, _c;
354
- return ({
355
- id: file.id,
356
- type: ChatMessageType.FILE,
357
- name: file.name,
358
- url: file.url || (file.file ? URL.createObjectURL(file.file) : '#'),
359
- size: (_a = file.file) === null || _a === void 0 ? void 0 : _a.size,
360
- thumbnail: (_b = file.thumbnailUrl) !== null && _b !== void 0 ? _b : undefined,
361
- status: file.status,
362
- percentage: (_c = file.percentage) !== null && _c !== void 0 ? _c : undefined
363
- });
364
- });
365
- handleMessageSend('', attachments);
366
- attachmentFileList.value = [];
367
- void nextTick(() => {
368
- scrollToBottom();
369
- });
370
- setTimeout(() => {
371
- scrollToBottom();
372
- }, 50);
343
+ const newFiles = fileList.filter((file) => !attachmentFileList.value.some((existing) => existing.id === file.id) &&
344
+ !pendingFiles.value.some((existing) => existing.id === file.id));
345
+ if (newFiles.length > 0) {
346
+ pendingFiles.value = [...pendingFiles.value, ...newFiles];
347
+ if (fileUploadTimer) {
348
+ clearTimeout(fileUploadTimer);
349
+ }
350
+ fileUploadTimer = setTimeout(() => {
351
+ if (pendingFiles.value.length > 0 && handleMessageSend) {
352
+ const hasError = pendingFiles.value.some((file) => file.status === 'error');
353
+ const batchStatus = hasError ? 'error' : 'finished';
354
+ const attachments = pendingFiles.value.map((file) => {
355
+ var _a, _b, _c;
356
+ return ({
357
+ id: file.id,
358
+ type: ChatMessageType.FILE,
359
+ name: file.name,
360
+ url: file.url ||
361
+ (file.file ? URL.createObjectURL(file.file) : '#'),
362
+ size: (_a = file.file) === null || _a === void 0 ? void 0 : _a.size,
363
+ thumbnail: (_b = file.thumbnailUrl) !== null && _b !== void 0 ? _b : undefined,
364
+ status: batchStatus,
365
+ percentage: (_c = file.percentage) !== null && _c !== void 0 ? _c : undefined
366
+ });
367
+ });
368
+ handleMessageSend('', attachments);
369
+ pendingFiles.value = [];
370
+ attachmentFileList.value = [];
371
+ void nextTick(() => {
372
+ scrollToBottom();
373
+ });
374
+ setTimeout(() => {
375
+ scrollToBottom();
376
+ }, SCROLL_DELAY);
377
+ }
378
+ }, SENDING_DELAY);
373
379
  }
374
380
  };
375
381
  const renderFooter = () => {
@@ -381,7 +387,7 @@ export default defineComponent({
381
387
  h(UIcon, Object.assign({ size: 24 }, footerIconPropsRef.value),
382
388
  h(Attach16Filled, null))))
383
389
  }),
384
- h(UInput, Object.assign({ ref: "inputRef", value: inputValue.value, placeholder: "\u041D\u0430\u043F\u0438\u0441\u0430\u0442\u044C \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435...", class: `${mergedClsPrefixRef.value}-chat-main__input` }, footerInputPropsRef.value, { onUpdateValue: (value) => {
390
+ h(UInput, Object.assign({ ref: "inputRef", value: inputValue.value, placeholder: inputPlaceholderRef.value, class: `${mergedClsPrefixRef.value}-chat-main__input` }, footerInputPropsRef.value, { onUpdateValue: (value) => {
385
391
  inputValue.value = value;
386
392
  if (selectedChatRef.value) {
387
393
  chatInputs.value[selectedChatRef.value.id] = value;
@@ -1,7 +1,6 @@
1
1
  import { h, defineComponent, inject } from 'vue';
2
- import { CheckmarkDoneSharp, Refresh } from '@vicons/ionicons5';
3
- import { MdTime } from '@vicons/ionicons4';
4
2
  import { chatInjectionKey, MessageStatus } from '../interface';
3
+ import { ChatGlobalState } from '../ChatGlobalState';
5
4
  import { UFlex } from '../../../flex';
6
5
  import { UEmpty } from '../../../empty';
7
6
  import { UAvatar } from '../../../avatar';
@@ -9,6 +8,7 @@ import { USelect } from '../../../select';
9
8
  import { UListItem, UList } from '../../../list';
10
9
  import { UBadge } from '../../../badge';
11
10
  import { UIcon } from '../../../icon';
11
+ import { CheckmarkDoneSharp, MdTime, PersonOutline, Refresh } from '../../../_internal/icons';
12
12
  const statusIconMapper = {
13
13
  [MessageStatus.READ]: CheckmarkDoneSharp,
14
14
  [MessageStatus.PENDING]: MdTime,
@@ -23,7 +23,7 @@ export default defineComponent({
23
23
  render() {
24
24
  var _a, _b;
25
25
  const { slots } = this;
26
- const { mergedClsPrefixRef, chatItemsRef, chatItemsLoadingRef, listEmptyPropsRef, selectedChatIdRef, typingChatIdsRef, listItemAvatarPropsRef, listItemBadgePropsRef, handleChatSelect
26
+ const { mergedClsPrefixRef, chatItemsRef, chatItemsLoadingRef, chatItemsLoadingCountRef, listEmptyPropsRef, selectedChatIdRef, typingChatIdsRef, typingTextRef, listItemAvatarPropsRef, listItemBadgePropsRef, handleChatSelect
27
27
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
28
28
  } = inject(chatInjectionKey);
29
29
  const renderListHeader = () => {
@@ -65,23 +65,16 @@ export default defineComponent({
65
65
  minWidth: 0,
66
66
  maxWidth: '100%'
67
67
  } }, isTyping
68
- ? 'Печатает...'
69
- : typeof item.subtitle === 'function'
70
- ? item.subtitle()
71
- : item.subtitle)),
68
+ ? typingTextRef.value
69
+ : typeof item.subtitle === 'string'
70
+ ? item.subtitle
71
+ : typeof item.subtitle === 'function'
72
+ ? item.subtitle()
73
+ : item.subtitle)),
72
74
  suffix: () => {
73
- const getChatGlobalState = () => {
74
- var _a;
75
- if (typeof window === 'undefined') {
76
- return { openedChats: new Set() };
77
- }
78
- if (!((_a = window.__chatGlobalState) === null || _a === void 0 ? void 0 : _a.openedChats)) {
79
- return { openedChats: new Set() };
80
- }
81
- return window.__chatGlobalState;
82
- };
75
+ const getChatGlobalState = () => ChatGlobalState.getInstance();
83
76
  const globalState = getChatGlobalState();
84
- const wasOpened = globalState.openedChats.has(item.id);
77
+ const wasOpened = globalState.isChatOpened(item.id);
85
78
  const displayUnreadCount = wasOpened ? 0 : item.unreadCount || 0;
86
79
  const hasUnreadIncoming = displayUnreadCount > 0;
87
80
  const lastMessageIsOwn = item.lastMessageIsOwn;
@@ -100,6 +93,6 @@ export default defineComponent({
100
93
  };
101
94
  return (h("div", { class: `${mergedClsPrefixRef.value}-chat-sidebar` },
102
95
  renderListHeader(),
103
- h("div", { class: `${mergedClsPrefixRef.value}-chat-sidebar__content` }, chatItemsLoadingRef.value ? (h("div", { class: `${mergedClsPrefixRef.value}-chat-main__loading` }, "Loading chats...")) : ((_a = chatItemsRef.value) === null || _a === void 0 ? void 0 : _a.length) ? (h(UList, { showIcon: false }, (_b = chatItemsRef.value) === null || _b === void 0 ? void 0 : _b.map((item) => renderChatItem(item)))) : (h(UEmpty, Object.assign({ description: "No chats" }, listEmptyPropsRef.value))))));
96
+ h("div", { class: `${mergedClsPrefixRef.value}-chat-sidebar__content` }, chatItemsLoadingRef.value ? (h(UList, { loading: true }, Array.from({ length: chatItemsLoadingCountRef.value || 10 }).map((_, index) => (h(UListItem, { key: index, avatar: { icon: PersonOutline }, description: { text: 'Loading...' }, header: { text: 'Loading...' } }))))) : ((_a = chatItemsRef.value) === null || _a === void 0 ? void 0 : _a.length) ? (h(UList, { showIcon: false }, (_b = chatItemsRef.value) === null || _b === void 0 ? void 0 : _b.map((item) => renderChatItem(item)))) : (h(UEmpty, Object.assign({}, listEmptyPropsRef.value))))));
104
97
  }
105
98
  });
@@ -147,7 +147,9 @@ export interface ChatProps {
147
147
  typingText?: string;
148
148
  closeButtonText?: string;
149
149
  chatItemsLoading?: boolean;
150
+ chatItemsLoadingCount?: number;
150
151
  messagesLoading?: boolean;
152
+ messagesLoadingCount?: number;
151
153
  onChatSelect?: OnChatSelect;
152
154
  onMessageSend?: OnMessageSend;
153
155
  onMessageRetry?: (message: ChatMessageData) => void;
@@ -244,7 +246,9 @@ export declare const chatInjectionKey: InjectionKey<{
244
246
  messagesRef: Ref<ChatMessageData[]>;
245
247
  typingChatIdsRef: Ref<Array<string | number | symbol> | undefined>;
246
248
  chatItemsLoadingRef: Ref<boolean | undefined>;
249
+ chatItemsLoadingCountRef: Ref<number | undefined>;
247
250
  messagesLoadingRef: Ref<boolean | undefined>;
251
+ messagesLoadingCountRef: Ref<number | undefined>;
248
252
  listEmptyPropsRef: Ref<Partial<EmptyProps> | undefined>;
249
253
  listHeaderTitleRef: Ref<string | (() => VNodeChild) | undefined>;
250
254
  listHeaderActionsRef: Ref<Array<() => VNodeChild> | undefined>;
@@ -261,9 +265,10 @@ export declare const chatInjectionKey: InjectionKey<{
261
265
  footerUploadPropsRef: Ref<Partial<UploadProps> | undefined>;
262
266
  footerUploadTriggerPropsRef: Ref<Record<string, any> | undefined>;
263
267
  footerIconPropsRef: Ref<Partial<IconProps> | undefined>;
264
- retryTextRef: Ref<string | undefined>;
265
- typingTextRef: Ref<string | undefined>;
266
- closeButtonTextRef: Ref<string | undefined>;
268
+ inputPlaceholderRef: Ref<string>;
269
+ retryTextRef: Ref<string>;
270
+ typingTextRef: Ref<string>;
271
+ closeButtonTextRef: Ref<string>;
267
272
  handleChatSelect: (chatId: ChatId) => void;
268
273
  handleMessageSend: (content: string, attachments?: ChatAttachment[]) => void;
269
274
  handleMessageRetry: (message: ChatMessageData) => void;
@@ -246,6 +246,9 @@ export default cB('chat', `
246
246
  min-width: 300px;
247
247
  height: 44px;
248
248
  padding: 12px 16px;
249
+ `), cM('skeleton', `
250
+ min-width: 376px;
251
+ height: 44px;
249
252
  `)]), cE('message-text', `
250
253
  padding: 12px 16px;
251
254
  `), cE('message-attachment', `
@@ -282,6 +285,10 @@ export default cB('chat', `
282
285
  justify-content: flex-end;
283
286
  `), cM('other', `
284
287
  justify-content: flex-start;
288
+ `), cM('skeleton', `
289
+ width: 36px;
290
+ height: 20px;
291
+ border-radius: 4px;
285
292
  `)]), cE('message-time', `
286
293
  font-size: 11px;
287
294
  color: var(--u-message-time-color);
@@ -201,9 +201,7 @@ declare const chatDark: import("../../_mixins").Theme<"Chat", {
201
201
  clearColorPressed: string;
202
202
  caretColorSecondary: string;
203
203
  filterCounterTextColor: string;
204
- filterCounterSeparatorColor: string;
205
204
  filterCounterTextColorDisabled: string;
206
- filterCounterSeparatorColorDisabled: string;
207
205
  arrowColorSecondary: string;
208
206
  clearColorSecondary: string;
209
207
  colorSecondary: string;
@@ -239,9 +239,7 @@ declare const chatLight: import("../../_mixins").Theme<"Chat", {
239
239
  clearColorPressed: string;
240
240
  caretColorSecondary: string;
241
241
  filterCounterTextColor: string;
242
- filterCounterSeparatorColor: string;
243
242
  filterCounterTextColorDisabled: string;
244
- filterCounterSeparatorColorDisabled: string;
245
243
  arrowColorSecondary: string;
246
244
  clearColorSecondary: string;
247
245
  colorSecondary: string;
@@ -644,9 +644,7 @@ declare const _default: import("vue").DefineComponent<{
644
644
  clearColorPressed: string;
645
645
  caretColorSecondary: string;
646
646
  filterCounterTextColor: string;
647
- filterCounterSeparatorColor: string;
648
647
  filterCounterTextColorDisabled: string;
649
- filterCounterSeparatorColorDisabled: string;
650
648
  arrowColorSecondary: string;
651
649
  clearColorSecondary: string;
652
650
  colorSecondary: string;
@@ -1562,9 +1560,7 @@ declare const _default: import("vue").DefineComponent<{
1562
1560
  clearColorPressed: string;
1563
1561
  caretColorSecondary: string;
1564
1562
  filterCounterTextColor: string;
1565
- filterCounterSeparatorColor: string;
1566
1563
  filterCounterTextColorDisabled: string;
1567
- filterCounterSeparatorColorDisabled: string;
1568
1564
  arrowColorSecondary: string;
1569
1565
  clearColorSecondary: string;
1570
1566
  colorSecondary: string;
@@ -2480,9 +2476,7 @@ declare const _default: import("vue").DefineComponent<{
2480
2476
  clearColorPressed: string;
2481
2477
  caretColorSecondary: string;
2482
2478
  filterCounterTextColor: string;
2483
- filterCounterSeparatorColor: string;
2484
2479
  filterCounterTextColorDisabled: string;
2485
- filterCounterSeparatorColorDisabled: string;
2486
2480
  arrowColorSecondary: string;
2487
2481
  clearColorSecondary: string;
2488
2482
  colorSecondary: string;
@@ -3421,9 +3415,7 @@ declare const _default: import("vue").DefineComponent<{
3421
3415
  clearColorPressed: string;
3422
3416
  caretColorSecondary: string;
3423
3417
  filterCounterTextColor: string;
3424
- filterCounterSeparatorColor: string;
3425
3418
  filterCounterTextColorDisabled: string;
3426
- filterCounterSeparatorColorDisabled: string;
3427
3419
  arrowColorSecondary: string;
3428
3420
  clearColorSecondary: string;
3429
3421
  colorSecondary: string;
@@ -3908,9 +3900,7 @@ declare const _default: import("vue").DefineComponent<{
3908
3900
  clearColorPressed: string;
3909
3901
  caretColorSecondary: string;
3910
3902
  filterCounterTextColor: string;
3911
- filterCounterSeparatorColor: string;
3912
3903
  filterCounterTextColorDisabled: string;
3913
- filterCounterSeparatorColorDisabled: string;
3914
3904
  arrowColorSecondary: string;
3915
3905
  clearColorSecondary: string;
3916
3906
  colorSecondary: string;
@@ -4922,9 +4912,7 @@ declare const _default: import("vue").DefineComponent<{
4922
4912
  clearColorPressed: string;
4923
4913
  caretColorSecondary: string;
4924
4914
  filterCounterTextColor: string;
4925
- filterCounterSeparatorColor: string;
4926
4915
  filterCounterTextColorDisabled: string;
4927
- filterCounterSeparatorColorDisabled: string;
4928
4916
  arrowColorSecondary: string;
4929
4917
  clearColorSecondary: string;
4930
4918
  colorSecondary: string;
@@ -5840,9 +5828,7 @@ declare const _default: import("vue").DefineComponent<{
5840
5828
  clearColorPressed: string;
5841
5829
  caretColorSecondary: string;
5842
5830
  filterCounterTextColor: string;
5843
- filterCounterSeparatorColor: string;
5844
5831
  filterCounterTextColorDisabled: string;
5845
- filterCounterSeparatorColorDisabled: string;
5846
5832
  arrowColorSecondary: string;
5847
5833
  clearColorSecondary: string;
5848
5834
  colorSecondary: string;
@@ -6758,9 +6744,7 @@ declare const _default: import("vue").DefineComponent<{
6758
6744
  clearColorPressed: string;
6759
6745
  caretColorSecondary: string;
6760
6746
  filterCounterTextColor: string;
6761
- filterCounterSeparatorColor: string;
6762
6747
  filterCounterTextColorDisabled: string;
6763
- filterCounterSeparatorColorDisabled: string;
6764
6748
  arrowColorSecondary: string;
6765
6749
  clearColorSecondary: string;
6766
6750
  colorSecondary: string;
@@ -546,9 +546,7 @@ declare const _default: import("vue").DefineComponent<{
546
546
  clearColorPressed: string;
547
547
  caretColorSecondary: string;
548
548
  filterCounterTextColor: string;
549
- filterCounterSeparatorColor: string;
550
549
  filterCounterTextColorDisabled: string;
551
- filterCounterSeparatorColorDisabled: string;
552
550
  arrowColorSecondary: string;
553
551
  clearColorSecondary: string;
554
552
  colorSecondary: string;
@@ -1033,9 +1031,7 @@ declare const _default: import("vue").DefineComponent<{
1033
1031
  clearColorPressed: string;
1034
1032
  caretColorSecondary: string;
1035
1033
  filterCounterTextColor: string;
1036
- filterCounterSeparatorColor: string;
1037
1034
  filterCounterTextColorDisabled: string;
1038
- filterCounterSeparatorColorDisabled: string;
1039
1035
  arrowColorSecondary: string;
1040
1036
  clearColorSecondary: string;
1041
1037
  colorSecondary: string;
@@ -571,9 +571,7 @@ declare const _default: import("vue").DefineComponent<{
571
571
  clearColorPressed: string;
572
572
  caretColorSecondary: string;
573
573
  filterCounterTextColor: string;
574
- filterCounterSeparatorColor: string;
575
574
  filterCounterTextColorDisabled: string;
576
- filterCounterSeparatorColorDisabled: string;
577
575
  arrowColorSecondary: string;
578
576
  clearColorSecondary: string;
579
577
  colorSecondary: string;
@@ -1058,9 +1056,7 @@ declare const _default: import("vue").DefineComponent<{
1058
1056
  clearColorPressed: string;
1059
1057
  caretColorSecondary: string;
1060
1058
  filterCounterTextColor: string;
1061
- filterCounterSeparatorColor: string;
1062
1059
  filterCounterTextColorDisabled: string;
1063
- filterCounterSeparatorColorDisabled: string;
1064
1060
  arrowColorSecondary: string;
1065
1061
  clearColorSecondary: string;
1066
1062
  colorSecondary: string;