@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.
Files changed (97) hide show
  1. package/dist/index.js +1673 -996
  2. package/dist/index.prod.js +3 -3
  3. package/es/chat/index.d.ts +6 -1
  4. package/es/chat/index.js +3 -0
  5. package/es/chat/src/Chat.d.ts +19 -6
  6. package/es/chat/src/Chat.js +54 -14
  7. package/es/chat/src/ChatListItems.d.ts +7782 -0
  8. package/es/chat/src/ChatListItems.js +188 -0
  9. package/es/chat/src/ChatMessages.d.ts +7805 -0
  10. package/es/chat/src/ChatMessages.js +325 -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 +10 -1
  16. package/es/chat/src/styles/index.cssr.js +16 -16
  17. package/es/chat/styles/light.d.ts +1 -1
  18. package/es/chat/styles/light.js +15 -3
  19. package/es/locales/common/arDZ.js +2 -1
  20. package/es/locales/common/deDE.js +2 -1
  21. package/es/locales/common/enGB.js +2 -1
  22. package/es/locales/common/enUS.d.ts +1 -0
  23. package/es/locales/common/enUS.js +2 -1
  24. package/es/locales/common/eo.js +2 -1
  25. package/es/locales/common/esAR.js +2 -1
  26. package/es/locales/common/faIR.js +2 -1
  27. package/es/locales/common/frFR.js +2 -1
  28. package/es/locales/common/idID.js +2 -1
  29. package/es/locales/common/itIT.js +2 -1
  30. package/es/locales/common/jaJP.js +2 -1
  31. package/es/locales/common/koKR.js +2 -1
  32. package/es/locales/common/nbNO.js +2 -1
  33. package/es/locales/common/nlNL.js +2 -1
  34. package/es/locales/common/plPL.js +2 -1
  35. package/es/locales/common/ptBR.js +2 -1
  36. package/es/locales/common/ruRU.js +2 -1
  37. package/es/locales/common/skSK.js +2 -1
  38. package/es/locales/common/svSE.js +2 -1
  39. package/es/locales/common/thTH.js +2 -1
  40. package/es/locales/common/trTR.js +2 -1
  41. package/es/locales/common/ukUA.js +2 -1
  42. package/es/locales/common/viVN.js +2 -1
  43. package/es/locales/common/zhCN.js +2 -1
  44. package/es/locales/common/zhTW.js +2 -1
  45. package/es/version.d.ts +1 -1
  46. package/es/version.js +1 -1
  47. package/lib/chat/index.d.ts +6 -1
  48. package/lib/chat/index.js +9 -1
  49. package/lib/chat/src/Chat.d.ts +19 -6
  50. package/lib/chat/src/Chat.js +53 -13
  51. package/lib/chat/src/ChatListItems.d.ts +7782 -0
  52. package/lib/chat/src/ChatListItems.js +194 -0
  53. package/lib/chat/src/ChatMessages.d.ts +7805 -0
  54. package/lib/chat/src/ChatMessages.js +331 -0
  55. package/lib/chat/src/ChatParts/ChatAttachment.js +4 -3
  56. package/lib/chat/src/ChatParts/MainArea.d.ts +0 -2
  57. package/lib/chat/src/ChatParts/MainArea.js +107 -228
  58. package/lib/chat/src/ChatParts/Sidebar.js +17 -78
  59. package/lib/chat/src/interface.d.ts +10 -1
  60. package/lib/chat/src/styles/index.cssr.js +16 -16
  61. package/lib/chat/styles/light.d.ts +1 -1
  62. package/lib/chat/styles/light.js +15 -3
  63. package/lib/locales/common/arDZ.js +2 -1
  64. package/lib/locales/common/deDE.js +2 -1
  65. package/lib/locales/common/enGB.js +2 -1
  66. package/lib/locales/common/enUS.d.ts +1 -0
  67. package/lib/locales/common/enUS.js +2 -1
  68. package/lib/locales/common/eo.js +2 -1
  69. package/lib/locales/common/esAR.js +2 -1
  70. package/lib/locales/common/faIR.js +2 -1
  71. package/lib/locales/common/frFR.js +2 -1
  72. package/lib/locales/common/idID.js +2 -1
  73. package/lib/locales/common/itIT.js +2 -1
  74. package/lib/locales/common/jaJP.js +2 -1
  75. package/lib/locales/common/koKR.js +2 -1
  76. package/lib/locales/common/nbNO.js +2 -1
  77. package/lib/locales/common/nlNL.js +2 -1
  78. package/lib/locales/common/plPL.js +2 -1
  79. package/lib/locales/common/ptBR.js +2 -1
  80. package/lib/locales/common/ruRU.js +2 -1
  81. package/lib/locales/common/skSK.js +2 -1
  82. package/lib/locales/common/svSE.js +2 -1
  83. package/lib/locales/common/thTH.js +2 -1
  84. package/lib/locales/common/trTR.js +2 -1
  85. package/lib/locales/common/ukUA.js +2 -1
  86. package/lib/locales/common/viVN.js +2 -1
  87. package/lib/locales/common/zhCN.js +2 -1
  88. package/lib/locales/common/zhTW.js +2 -1
  89. package/lib/version.d.ts +1 -1
  90. package/lib/version.js +1 -1
  91. package/package.json +1 -1
  92. package/volar.d.ts +2 -0
  93. package/web-types.json +149 -1
  94. package/es/chat/src/ChatGlobalState.d.ts +0 -13
  95. package/es/chat/src/ChatGlobalState.js +0 -32
  96. package/lib/chat/src/ChatGlobalState.d.ts +0 -13
  97. package/lib/chat/src/ChatGlobalState.js +0 -36
@@ -0,0 +1,188 @@
1
+ import { h, defineComponent, computed, inject } from 'vue';
2
+ import { MessageStatus, chatInjectionKey } from './interface';
3
+ import { UEmpty } from '../../empty';
4
+ import { UAvatar } from '../../avatar';
5
+ import { UListItem, UList } from '../../list';
6
+ import { UBadge } from '../../badge';
7
+ import { UIcon } from '../../icon';
8
+ import style from './styles/index.cssr';
9
+ import { chatLight } from '../styles';
10
+ import { useConfig, useTheme, useThemeClass, useLocale } from '../../_mixins';
11
+ import { CheckmarkDoneSharp, MdTime, PersonOutline, Refresh } from '../../_internal/icons';
12
+ const statusIconMapper = {
13
+ [MessageStatus.READ]: CheckmarkDoneSharp,
14
+ [MessageStatus.PENDING]: MdTime,
15
+ [MessageStatus.RETRY]: Refresh,
16
+ [MessageStatus.UNREAD]: CheckmarkDoneSharp
17
+ };
18
+ export const chatListItemsProps = Object.assign(Object.assign({}, useTheme.props), { chatItems: {
19
+ type: Array,
20
+ default: () => []
21
+ }, selectedChatId: {
22
+ type: [String, Number, Symbol],
23
+ default: undefined
24
+ }, typingChatIds: {
25
+ type: Array,
26
+ default: () => []
27
+ }, typingText: {
28
+ type: String,
29
+ default: undefined
30
+ }, loading: {
31
+ type: Boolean,
32
+ default: false
33
+ }, loadingCount: {
34
+ type: Number,
35
+ default: 10
36
+ }, emptyProps: {
37
+ type: Object,
38
+ default: undefined
39
+ }, avatarProps: {
40
+ type: Object,
41
+ default: undefined
42
+ }, badgeProps: {
43
+ type: Object,
44
+ default: undefined
45
+ }, onChatSelect: {
46
+ type: Function,
47
+ default: undefined
48
+ }, notificationsShown: {
49
+ type: Object,
50
+ default: () => new Set()
51
+ } });
52
+ export default defineComponent({
53
+ name: 'ChatListItems',
54
+ props: chatListItemsProps,
55
+ setup(props, { slots }) {
56
+ var _a;
57
+ const UChat = inject(chatInjectionKey, null);
58
+ const { mergedClsPrefixRef } = useConfig(props);
59
+ const themeRef = (_a = UChat === null || UChat === void 0 ? void 0 : UChat.mergedThemeRef) !== null && _a !== void 0 ? _a : useTheme('Chat', '-chat', style, chatLight, props, mergedClsPrefixRef);
60
+ const { localeRef } = useLocale('Chat');
61
+ const cssVarsRef = computed(() => {
62
+ const { common: { cubicBezierEaseInOut, brandPrimary500, staticGreen, staticRed, textPrimary, textSecondary, textTertiary }, self: { backgroundColor, borderColor, sidebarBackgroundColor, sidebarBorderColor, sidebarItemBackgroundColor, sidebarItemBackgroundColorHover, sidebarItemBackgroundColorSelected, sidebarItemTextColor, sidebarItemTextColorSelected, sidebarItemSubtitleColor, sidebarItemTimeColor, unreadNotificationBackgroundColor, borderRadius } } = themeRef.value;
63
+ return {
64
+ '--u-bezier': cubicBezierEaseInOut,
65
+ '--u-color-primary': brandPrimary500,
66
+ '--u-color-success': staticGreen,
67
+ '--u-color-error': staticRed,
68
+ '--u-text-color-base': textPrimary,
69
+ '--u-text-color-secondary': textSecondary,
70
+ '--u-text-color-disabled': textTertiary,
71
+ '--u-background-color': backgroundColor,
72
+ '--u-border-color': borderColor,
73
+ '--u-sidebar-background-color': sidebarBackgroundColor,
74
+ '--u-sidebar-border-color': sidebarBorderColor,
75
+ '--u-sidebar-item-background-color': sidebarItemBackgroundColor,
76
+ '--u-sidebar-item-background-color-hover': sidebarItemBackgroundColorHover,
77
+ '--u-sidebar-item-background-color-selected': sidebarItemBackgroundColorSelected,
78
+ '--u-sidebar-item-text-color': sidebarItemTextColor,
79
+ '--u-sidebar-item-text-color-selected': sidebarItemTextColorSelected,
80
+ '--u-sidebar-item-subtitle-color': sidebarItemSubtitleColor,
81
+ '--u-sidebar-item-time-color': sidebarItemTimeColor,
82
+ '--u-unread-notification-background-color': unreadNotificationBackgroundColor,
83
+ '--u-border-radius': borderRadius
84
+ };
85
+ });
86
+ const themeClassHandle = useThemeClass('chat-list-items', computed(() => ''), cssVarsRef, props);
87
+ const mergedTypingTextRef = computed(() => { var _a; return (_a = props.typingText) !== null && _a !== void 0 ? _a : localeRef.value.typingText; });
88
+ const handleChatSelect = (chatId) => {
89
+ var _a;
90
+ (_a = props.onChatSelect) === null || _a === void 0 ? void 0 : _a.call(props, chatId);
91
+ };
92
+ const renderChatItem = (item) => {
93
+ var _a, _b;
94
+ const isSelected = props.selectedChatId === item.id;
95
+ const isTyping = (_b = (_a = props.typingChatIds) === null || _a === void 0 ? void 0 : _a.includes(item.id)) !== null && _b !== void 0 ? _b : false;
96
+ return (h(UListItem, { key: item.id, showIcon: false, onClick: () => {
97
+ handleChatSelect(item.id);
98
+ }, class: [
99
+ `${mergedClsPrefixRef.value}-chat-sidebar__item`,
100
+ isSelected &&
101
+ `${mergedClsPrefixRef.value}-chat-sidebar__item--selected`,
102
+ isTyping && `${mergedClsPrefixRef.value}-chat-sidebar__item--typing`
103
+ ] }, {
104
+ prefix: () => (h(UAvatar, Object.assign({ size: "medium", src: typeof item.avatar === 'string' ? item.avatar : undefined }, props.avatarProps, { theme: themeRef.value.peers.Avatar, themeOverrides: themeRef.value.peerOverrides.Avatar }), {
105
+ default: () => {
106
+ var _a;
107
+ return typeof item.avatar === 'function'
108
+ ? item.avatar()
109
+ : typeof item.title === 'string'
110
+ ? (_a = item.title.charAt(0)) === null || _a === void 0 ? void 0 : _a.toUpperCase()
111
+ : '?';
112
+ }
113
+ })),
114
+ header: () => (h("span", { class: `${mergedClsPrefixRef.value}-chat-sidebar__item-title` }, typeof item.title === 'function' ? item.title() : item.title)),
115
+ description: () => (h("span", { class: [
116
+ `${mergedClsPrefixRef.value}-chat-sidebar__item-subtitle`,
117
+ isTyping && 'typing'
118
+ ], style: {
119
+ display: 'block',
120
+ overflow: 'hidden',
121
+ textOverflow: 'ellipsis',
122
+ whiteSpace: 'nowrap',
123
+ minWidth: 0,
124
+ maxWidth: '100%'
125
+ } }, isTyping
126
+ ? mergedTypingTextRef.value
127
+ : typeof item.subtitle === 'string'
128
+ ? item.subtitle
129
+ : typeof item.subtitle === 'function'
130
+ ? item.subtitle()
131
+ : item.subtitle)),
132
+ suffix: () => {
133
+ const displayUnreadCount = item.unreadCount || 0;
134
+ const hasUnreadIncoming = displayUnreadCount > 0;
135
+ const lastMessageIsOwn = item.lastMessageIsOwn;
136
+ return (h("div", { class: `${mergedClsPrefixRef.value}-chat-sidebar__item-indicators` },
137
+ h("div", { class: `${mergedClsPrefixRef.value}-chat-sidebar__item-time` }, item.datetime),
138
+ h("div", { class: `${mergedClsPrefixRef.value}-chat-sidebar__item-status` },
139
+ lastMessageIsOwn &&
140
+ (slots.chatItemStatus ? (slots.chatItemStatus(item)) : item.messageStatus &&
141
+ statusIconMapper[item.messageStatus] ? (h(UIcon, { size: 16, component: statusIconMapper[item.messageStatus], class: [
142
+ `${mergedClsPrefixRef.value}-chat-sidebar__item-status-icon`,
143
+ `${mergedClsPrefixRef.value}-chat-sidebar__item-status-icon--${item.messageStatus}`
144
+ ], theme: themeRef.value.peers.Icon, themeOverrides: themeRef.value.peerOverrides.Icon })) : null),
145
+ !lastMessageIsOwn && hasUnreadIncoming && (h(UBadge, Object.assign({ value: displayUnreadCount }, props.badgeProps, { theme: themeRef.value.peers.Badge, themeOverrides: themeRef.value.peerOverrides.Badge }))))));
146
+ }
147
+ }));
148
+ };
149
+ return {
150
+ mergedClsPrefixRef,
151
+ mergedTheme: themeRef,
152
+ renderChatItem,
153
+ cssVars: cssVarsRef,
154
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
155
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
156
+ };
157
+ },
158
+ render() {
159
+ var _a;
160
+ (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
161
+ const { mergedClsPrefixRef, renderChatItem } = this;
162
+ const content = (() => {
163
+ var _a;
164
+ if (this.loading) {
165
+ return (h(UList, { loading: true, theme: this.mergedTheme.peers.List, themeOverrides: this.mergedTheme.peerOverrides.List }, {
166
+ default: () => Array.from({ length: this.loadingCount || 10 }).map((_, index) => (h(UListItem, { key: index, avatar: { icon: PersonOutline }, description: { text: 'Loading...' }, header: { text: 'Loading...' } })))
167
+ }));
168
+ }
169
+ if ((_a = this.chatItems) === null || _a === void 0 ? void 0 : _a.length) {
170
+ return (h(UList, { showIcon: false, theme: this.mergedTheme.peers.List, themeOverrides: this.mergedTheme.peerOverrides.List }, {
171
+ default: () => { var _a; return (_a = this.chatItems) === null || _a === void 0 ? void 0 : _a.map((item) => renderChatItem(item)); }
172
+ }));
173
+ }
174
+ return (h(UEmpty, Object.assign({}, this.emptyProps, { theme: this.mergedTheme.peers.Empty, themeOverrides: this.mergedTheme.peerOverrides.Empty })));
175
+ })();
176
+ return (h("div", { class: [`${mergedClsPrefixRef}-chat`, this.themeClass], style: this.cssVars },
177
+ h("div", { class: `${mergedClsPrefixRef}-chat-sidebar`, style: {
178
+ border: 'none',
179
+ borderRadius: '0',
180
+ padding: '0',
181
+ maxWidth: '100%',
182
+ background: 'transparent'
183
+ } },
184
+ h("div", { class: `${mergedClsPrefixRef}-chat-sidebar__content`, style: {
185
+ padding: '0'
186
+ } }, content))));
187
+ }
188
+ });