@uzum-tech/ui 1.7.2 → 1.8.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.
Files changed (93) hide show
  1. package/dist/index.js +1548 -998
  2. package/dist/index.prod.js +3 -3
  3. package/es/chat/index.d.ts +4 -0
  4. package/es/chat/index.js +2 -0
  5. package/es/chat/src/Chat.d.ts +19 -6
  6. package/es/chat/src/Chat.js +53 -14
  7. package/es/chat/src/ChatListItems.d.ts +6027 -0
  8. package/es/chat/src/ChatListItems.js +187 -0
  9. package/es/chat/src/ChatMessages.d.ts +6049 -0
  10. package/es/chat/src/ChatMessages.js +308 -0
  11. package/es/chat/src/ChatParts/ChatAttachment.js +4 -3
  12. package/es/chat/src/ChatParts/MainArea.d.ts +0 -2
  13. package/es/chat/src/ChatParts/MainArea.js +108 -229
  14. package/es/chat/src/ChatParts/Sidebar.js +16 -80
  15. package/es/chat/src/interface.d.ts +6 -1
  16. package/es/chat/src/styles/index.cssr.js +3 -2
  17. package/es/locales/common/arDZ.js +2 -1
  18. package/es/locales/common/deDE.js +2 -1
  19. package/es/locales/common/enGB.js +2 -1
  20. package/es/locales/common/enUS.d.ts +1 -0
  21. package/es/locales/common/enUS.js +2 -1
  22. package/es/locales/common/eo.js +2 -1
  23. package/es/locales/common/esAR.js +2 -1
  24. package/es/locales/common/faIR.js +2 -1
  25. package/es/locales/common/frFR.js +2 -1
  26. package/es/locales/common/idID.js +2 -1
  27. package/es/locales/common/itIT.js +2 -1
  28. package/es/locales/common/jaJP.js +2 -1
  29. package/es/locales/common/koKR.js +2 -1
  30. package/es/locales/common/nbNO.js +2 -1
  31. package/es/locales/common/nlNL.js +2 -1
  32. package/es/locales/common/plPL.js +2 -1
  33. package/es/locales/common/ptBR.js +2 -1
  34. package/es/locales/common/ruRU.js +2 -1
  35. package/es/locales/common/skSK.js +2 -1
  36. package/es/locales/common/svSE.js +2 -1
  37. package/es/locales/common/thTH.js +2 -1
  38. package/es/locales/common/trTR.js +2 -1
  39. package/es/locales/common/ukUA.js +2 -1
  40. package/es/locales/common/viVN.js +2 -1
  41. package/es/locales/common/zhCN.js +2 -1
  42. package/es/locales/common/zhTW.js +2 -1
  43. package/es/version.d.ts +1 -1
  44. package/es/version.js +1 -1
  45. package/lib/chat/index.d.ts +4 -0
  46. package/lib/chat/index.js +5 -1
  47. package/lib/chat/src/Chat.d.ts +19 -6
  48. package/lib/chat/src/Chat.js +52 -13
  49. package/lib/chat/src/ChatListItems.d.ts +6027 -0
  50. package/lib/chat/src/ChatListItems.js +193 -0
  51. package/lib/chat/src/ChatMessages.d.ts +6049 -0
  52. package/lib/chat/src/ChatMessages.js +314 -0
  53. package/lib/chat/src/ChatParts/ChatAttachment.js +4 -3
  54. package/lib/chat/src/ChatParts/MainArea.d.ts +0 -2
  55. package/lib/chat/src/ChatParts/MainArea.js +107 -228
  56. package/lib/chat/src/ChatParts/Sidebar.js +17 -78
  57. package/lib/chat/src/interface.d.ts +6 -1
  58. package/lib/chat/src/styles/index.cssr.js +3 -2
  59. package/lib/locales/common/arDZ.js +2 -1
  60. package/lib/locales/common/deDE.js +2 -1
  61. package/lib/locales/common/enGB.js +2 -1
  62. package/lib/locales/common/enUS.d.ts +1 -0
  63. package/lib/locales/common/enUS.js +2 -1
  64. package/lib/locales/common/eo.js +2 -1
  65. package/lib/locales/common/esAR.js +2 -1
  66. package/lib/locales/common/faIR.js +2 -1
  67. package/lib/locales/common/frFR.js +2 -1
  68. package/lib/locales/common/idID.js +2 -1
  69. package/lib/locales/common/itIT.js +2 -1
  70. package/lib/locales/common/jaJP.js +2 -1
  71. package/lib/locales/common/koKR.js +2 -1
  72. package/lib/locales/common/nbNO.js +2 -1
  73. package/lib/locales/common/nlNL.js +2 -1
  74. package/lib/locales/common/plPL.js +2 -1
  75. package/lib/locales/common/ptBR.js +2 -1
  76. package/lib/locales/common/ruRU.js +2 -1
  77. package/lib/locales/common/skSK.js +2 -1
  78. package/lib/locales/common/svSE.js +2 -1
  79. package/lib/locales/common/thTH.js +2 -1
  80. package/lib/locales/common/trTR.js +2 -1
  81. package/lib/locales/common/ukUA.js +2 -1
  82. package/lib/locales/common/viVN.js +2 -1
  83. package/lib/locales/common/zhCN.js +2 -1
  84. package/lib/locales/common/zhTW.js +2 -1
  85. package/lib/version.d.ts +1 -1
  86. package/lib/version.js +1 -1
  87. package/package.json +1 -1
  88. package/volar.d.ts +2 -0
  89. package/web-types.json +149 -1
  90. package/es/chat/src/ChatGlobalState.d.ts +0 -13
  91. package/es/chat/src/ChatGlobalState.js +0 -32
  92. package/lib/chat/src/ChatGlobalState.d.ts +0 -13
  93. package/lib/chat/src/ChatGlobalState.js +0 -36
@@ -1,2 +1,6 @@
1
1
  export { default as UChat } from './src/Chat';
2
+ export { default as UChatListItems } from './src/ChatListItems';
3
+ export { default as UChatMessages } from './src/ChatMessages';
2
4
  export type { ChatId, MessageStatus, ChatMessageType, ChatMarkType, ChatProps, ChatListItemProps, ChatMessageProps, ChatMarkProps, ChatHeaderProps, ChatFooterProps, ChatListHeaderProps, ChatSlots, ChatListItemSlots, ChatMessageSlots, ChatMarkSlots, ChatHeaderSlots, ChatFooterSlots, ChatListItemData, ChatMessageData, ChatAttachment, OnChatSelect, OnMessageSend, OnAttachmentUpload, OnFilterChange, OnLoadMoreChats, OnNetworkError, OnUploadError, OnSendError, ChatInst, ChatListInst, chatInjectionKey } from './src/interface';
5
+ export type { ChatListItemsProps } from './src/ChatListItems';
6
+ export type { ChatMessagesProps } from './src/ChatMessages';
package/es/chat/index.js CHANGED
@@ -1 +1,3 @@
1
1
  export { default as UChat } from './src/Chat';
2
+ export { default as UChatListItems } from './src/ChatListItems';
3
+ export { default as UChatMessages } from './src/ChatMessages';
@@ -115,6 +115,10 @@ export declare const chatProps: {
115
115
  type: PropType<ChatPropsType["closeButtonText"]>;
116
116
  default: undefined;
117
117
  };
118
+ unreadNotificationText: {
119
+ type: PropType<ChatPropsType["unreadNotificationText"]>;
120
+ default: undefined;
121
+ };
118
122
  chatItemsLoading: {
119
123
  type: PropType<ChatPropsType["chatItemsLoading"]>;
120
124
  default: boolean;
@@ -2241,6 +2245,10 @@ declare const _default: import("vue").DefineComponent<{
2241
2245
  type: PropType<ChatPropsType["closeButtonText"]>;
2242
2246
  default: undefined;
2243
2247
  };
2248
+ unreadNotificationText: {
2249
+ type: PropType<ChatPropsType["unreadNotificationText"]>;
2250
+ default: undefined;
2251
+ };
2244
2252
  chatItemsLoading: {
2245
2253
  type: PropType<ChatPropsType["chatItemsLoading"]>;
2246
2254
  default: boolean;
@@ -5285,6 +5293,10 @@ declare const _default: import("vue").DefineComponent<{
5285
5293
  type: PropType<ChatPropsType["closeButtonText"]>;
5286
5294
  default: undefined;
5287
5295
  };
5296
+ unreadNotificationText: {
5297
+ type: PropType<ChatPropsType["unreadNotificationText"]>;
5298
+ default: undefined;
5299
+ };
5288
5300
  chatItemsLoading: {
5289
5301
  type: PropType<ChatPropsType["chatItemsLoading"]>;
5290
5302
  default: boolean;
@@ -7312,15 +7324,19 @@ declare const _default: import("vue").DefineComponent<{
7312
7324
  typingText: string | undefined;
7313
7325
  retryText: string | undefined;
7314
7326
  closeButtonText: string | undefined;
7327
+ unreadNotificationText: string | undefined;
7315
7328
  maxHeight: string | number;
7316
7329
  emptyProps: Partial<Partial<import("../..").EmptyProps> | undefined>;
7330
+ chatItems: ChatListItemData[] | undefined;
7331
+ selectedChatId: import("./interface").ChatId | undefined;
7332
+ typingChatIds: (string | number | symbol)[];
7333
+ onChatSelect: import("./interface").OnChatSelect | undefined;
7334
+ messages: ChatMessageData[] | undefined;
7335
+ onMessageRetry: ((message: ChatMessageData) => void) | undefined;
7317
7336
  onChatClose: () => void;
7318
7337
  onChatShare: () => void;
7319
7338
  onUserProfile: () => void;
7320
7339
  headerActions: (() => import("vue").VNodeChild)[] | undefined;
7321
- chatItems: ChatListItemData[] | undefined;
7322
- selectedChatId: import("./interface").ChatId | undefined;
7323
- messages: ChatMessageData[] | undefined;
7324
7340
  listEmptyProps: Partial<Partial<import("../..").EmptyProps> | undefined>;
7325
7341
  listHeaderTitle: string | (() => import("vue").VNodeChild) | undefined;
7326
7342
  listHeaderActions: (() => import("vue").VNodeChild)[] | undefined;
@@ -7343,14 +7359,11 @@ declare const _default: import("vue").DefineComponent<{
7343
7359
  chatItemsLoadingCount: number | undefined;
7344
7360
  messagesLoading: boolean | undefined;
7345
7361
  messagesLoadingCount: number | undefined;
7346
- onChatSelect: import("./interface").OnChatSelect | undefined;
7347
- onMessageRetry: ((message: ChatMessageData) => void) | undefined;
7348
7362
  onAttachmentUpload: import("./interface").OnAttachmentUpload | undefined;
7349
7363
  onFilterChange: import("./interface").OnFilterChange | undefined;
7350
7364
  onLoadMoreChats: import("./interface").OnLoadMoreChats | undefined;
7351
7365
  onNetworkError: import("./interface").OnNetworkError | undefined;
7352
7366
  onUploadError: import("./interface").OnUploadError | undefined;
7353
7367
  onSendError: import("./interface").OnSendError | undefined;
7354
- typingChatIds: (string | number | symbol)[];
7355
7368
  }, {}>;
7356
7369
  export default _default;
@@ -1,4 +1,4 @@
1
- import { h, defineComponent, computed, provide, ref, toRef } from 'vue';
1
+ import { h, defineComponent, computed, provide, ref, watch, toRef, Fragment } from 'vue';
2
2
  import { chatInjectionKey } from './interface';
3
3
  import ChatSidebar from './ChatParts/Sidebar';
4
4
  import ChatMainArea from './ChatParts/MainArea';
@@ -91,6 +91,9 @@ export const chatProps = Object.assign(Object.assign({}, useTheme.props), { chat
91
91
  }, closeButtonText: {
92
92
  type: String,
93
93
  default: undefined
94
+ }, unreadNotificationText: {
95
+ type: String,
96
+ default: undefined
94
97
  }, chatItemsLoading: {
95
98
  type: Boolean,
96
99
  default: false
@@ -159,6 +162,11 @@ export default defineComponent({
159
162
  const { mergedClsPrefixRef } = useConfig(props);
160
163
  const themeRef = useTheme('Chat', '-chat', style, chatLight, props, mergedClsPrefixRef);
161
164
  const { localeRef } = useLocale('Chat');
165
+ const notificationsShownSet = ref(new Set());
166
+ const markNotificationShown = (chatId) => {
167
+ notificationsShownSet.value.add(chatId);
168
+ notificationsShownSet.value = new Set(notificationsShownSet.value);
169
+ };
162
170
  const cssVarsRef = computed(() => {
163
171
  const { common: { cubicBezierEaseInOut }, self: { backgroundColor, borderColor, sidebarBackgroundColor, sidebarBorderColor, sidebarItemBackgroundColor, sidebarItemBackgroundColorHover, sidebarItemBackgroundColorSelected, sidebarItemTextColor, sidebarItemTextColorSelected, sidebarItemSubtitleColor, sidebarItemTimeColor, mainBackgroundColor, headerBackgroundColor, headerBorderColor, headerTitleColor, messageBubbleBackgroundColorOwn, messageBubbleBackgroundColorOther, messageBubbleTextColorOwn, messageBubbleTextColorOther, messageTimeColor, messageStatusColor, attachmentBackgroundColorOwn, attachmentBackgroundColorOther, footerBackgroundColor, footerBorderColor, inputBackgroundColor, inputBorderColor, unreadNotificationBackgroundColor, unreadNotificationTextColor, typingIndicatorColor, dateSeparatorColor, dateSeparatorBackgroundColor, borderRadius, errorColor } } = themeRef.value;
164
172
  return {
@@ -226,11 +234,35 @@ export default defineComponent({
226
234
  }
227
235
  return [];
228
236
  });
237
+ const lastUnreadCounts = ref({});
238
+ watch(() => props.chatItems, (chatItems) => {
239
+ if (!chatItems)
240
+ return;
241
+ chatItems.forEach((chatItem) => {
242
+ const chatId = chatItem.id;
243
+ const currentUnreadCount = chatItem.unreadCount || 0;
244
+ const lastUnreadCount = lastUnreadCounts.value[chatId] || 0;
245
+ if (currentUnreadCount > lastUnreadCount) {
246
+ const newSet = new Set(notificationsShownSet.value);
247
+ newSet.delete(chatId);
248
+ notificationsShownSet.value = newSet;
249
+ }
250
+ lastUnreadCounts.value[chatId] = currentUnreadCount;
251
+ });
252
+ }, { deep: true, immediate: true });
253
+ const unreadCountsBeforeRead = ref({});
229
254
  const handleChatSelect = (chatId) => {
230
255
  var _a, _b;
256
+ const previousChatId = uncontrolledSelectedChatIdRef.value;
257
+ if (previousChatId !== undefined && previousChatId !== chatId) {
258
+ emit('mark-messages-read', previousChatId);
259
+ }
260
+ const selectedItem = (_a = props.chatItems) === null || _a === void 0 ? void 0 : _a.find((item) => item.id === chatId);
261
+ const unreadCountBeforeRead = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.unreadCount) || 0;
262
+ unreadCountsBeforeRead.value[chatId] = unreadCountBeforeRead;
231
263
  uncontrolledSelectedChatIdRef.value = chatId;
232
264
  emit('update:selectedChatId', chatId);
233
- const selectedItem = (_a = props.chatItems) === null || _a === void 0 ? void 0 : _a.find((item) => item.id === chatId);
265
+ emit('mark-messages-read', chatId);
234
266
  if (selectedItem) {
235
267
  (_b = props.onChatSelect) === null || _b === void 0 ? void 0 : _b.call(props, chatId, selectedItem);
236
268
  }
@@ -282,6 +314,7 @@ export default defineComponent({
282
314
  const mergedRetryTextRef = computed(() => { var _a; return (_a = props.retryText) !== null && _a !== void 0 ? _a : localeRef.value.retryText; });
283
315
  const mergedTypingTextRef = computed(() => { var _a; return (_a = props.typingText) !== null && _a !== void 0 ? _a : localeRef.value.typingText; });
284
316
  const mergedCloseButtonTextRef = computed(() => { var _a; return (_a = props.closeButtonText) !== null && _a !== void 0 ? _a : localeRef.value.closeButtonText; });
317
+ const mergedUnreadNotificationTextRef = computed(() => { var _a; return (_a = props.unreadNotificationText) !== null && _a !== void 0 ? _a : localeRef.value.unreadNotificationText; });
285
318
  provide(chatInjectionKey, {
286
319
  mergedClsPrefixRef,
287
320
  chatItemsRef: toRef(props, 'chatItems'),
@@ -313,6 +346,10 @@ export default defineComponent({
313
346
  retryTextRef: mergedRetryTextRef,
314
347
  typingTextRef: mergedTypingTextRef,
315
348
  closeButtonTextRef: mergedCloseButtonTextRef,
349
+ unreadNotificationTextRef: mergedUnreadNotificationTextRef,
350
+ notificationsShownSetRef: notificationsShownSet,
351
+ unreadCountsBeforeReadRef: unreadCountsBeforeRead,
352
+ markNotificationShown,
316
353
  handleChatSelect,
317
354
  handleMessageSend,
318
355
  handleMessageRetry,
@@ -346,17 +383,19 @@ export default defineComponent({
346
383
  }
347
384
  : {};
348
385
  return (h("div", { class: [`${this.mergedClsPrefix}-chat`, this.themeClass], style: Object.assign(Object.assign({}, maxHeightStyle), this.cssVars) },
349
- h(UFlex, { wrap: false, size: [20, 20], style: { width: '100%' } },
350
- resolveSlot($slots.sidebar, () => [
351
- h(ChatSidebar, null, {
352
- sidebarHeaderMain: $slots.sidebarHeaderMain,
353
- sidebarHeaderActions: $slots.sidebarHeaderActions
354
- })
355
- ]),
356
- resolveSlot($slots.default, () => [
357
- h(ChatMainArea, null, {
358
- headerActions: $slots.headerActions
359
- })
360
- ]))));
386
+ h(UFlex, { wrap: false, size: [20, 20], style: { width: '100%' } }, {
387
+ default: () => (h(Fragment, null,
388
+ resolveSlot($slots.sidebar, () => [
389
+ h(ChatSidebar, null, {
390
+ sidebarHeaderMain: $slots.sidebarHeaderMain,
391
+ sidebarHeaderActions: $slots.sidebarHeaderActions
392
+ })
393
+ ]),
394
+ resolveSlot($slots.default, () => [
395
+ h(ChatMainArea, null, {
396
+ headerActions: $slots.headerActions
397
+ })
398
+ ])))
399
+ })));
361
400
  }
362
401
  });