@webitel/ui-chats 0.1.42 → 0.1.44
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/package.json +2 -2
- package/src/ui/messaging/composables/useChatScroll.ts +12 -1
- package/src/ui/messaging/modules/message/components/chat-message.vue +54 -39
- package/src/ui/messaging/modules/message/components/details/chat-message-blocked-error.vue +0 -3
- package/src/ui/messaging/modules/message/components/details/chat-message-size-exceeded-error.vue +0 -4
- package/src/vite-env.d.ts +1 -0
- package/types/.tsbuildinfo +1 -0
- package/types/ui/messaging/composables/useChatScroll.d.ts +7 -1
- package/types/ui/messaging/modules/message/components/chat-message.vue.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-chats",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"description": "Reusable Webitel Frontend Code for Chats UI",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"../../",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "vite",
|
|
12
|
-
"build:types": "vue-tsc -
|
|
12
|
+
"build:types": "vue-tsc -b tsconfig.build.json",
|
|
13
13
|
"typecheck": "vue-tsc --noEmit -p ./tsconfig.typecheck.json",
|
|
14
14
|
"lint:fix": "npx biome check --write ./src",
|
|
15
15
|
"biome:ci:gh": "biome ci ./src --reporter=github",
|
|
@@ -23,6 +23,12 @@ export interface UseChatScrollOptions {
|
|
|
23
23
|
onBeforeStart?: (options: {
|
|
24
24
|
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
25
25
|
}) => void;
|
|
26
|
+
/**
|
|
27
|
+
* @author ye-pohranichna
|
|
28
|
+
* Fired when the viewer is at the bottom and has therefore seen the
|
|
29
|
+
* latest messages
|
|
30
|
+
*/
|
|
31
|
+
onSeen?: () => void;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
export const useChatScroll = ({
|
|
@@ -35,6 +41,7 @@ export const useChatScroll = ({
|
|
|
35
41
|
onBeforeStart = (options) => {
|
|
36
42
|
options.scrollToBottom();
|
|
37
43
|
},
|
|
44
|
+
onSeen,
|
|
38
45
|
}: UseChatScrollOptions) => {
|
|
39
46
|
const { arrivedState } = useScroll(chatContainer);
|
|
40
47
|
|
|
@@ -82,6 +89,7 @@ export const useChatScroll = ({
|
|
|
82
89
|
newUnseenMessagesCount.value = 0;
|
|
83
90
|
|
|
84
91
|
resetScrollToBottomBtn();
|
|
92
|
+
onSeen?.();
|
|
85
93
|
};
|
|
86
94
|
const getTopMessageEl = () => {
|
|
87
95
|
// help to fix chat viewing position when new messages was loaded
|
|
@@ -237,7 +245,10 @@ export const useChatScroll = ({
|
|
|
237
245
|
watch(
|
|
238
246
|
() => arrivedState.bottom,
|
|
239
247
|
(bottom) => {
|
|
240
|
-
if (bottom)
|
|
248
|
+
if (bottom) {
|
|
249
|
+
newUnseenMessagesCount.value = 0;
|
|
250
|
+
onSeen?.();
|
|
251
|
+
}
|
|
241
252
|
},
|
|
242
253
|
);
|
|
243
254
|
|
|
@@ -21,49 +21,53 @@
|
|
|
21
21
|
/>
|
|
22
22
|
</div>
|
|
23
23
|
<!-- click.stop prevents focus on textarea and allows to select the message-new text -->
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
:self-side="isSelfSide"
|
|
24
|
+
<div
|
|
25
|
+
class="chat-message__body"
|
|
26
|
+
:class="{ 'chat-message__body--malware': isFileMalware }"
|
|
28
27
|
@click.stop
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
:size="size"
|
|
36
|
-
@initialized="handlePlayerInitialize"
|
|
37
|
-
/>
|
|
38
|
-
<message-image
|
|
39
|
-
v-else-if="image"
|
|
40
|
-
:file="image"
|
|
41
|
-
@open="emit(MessageAction.ClickOnImage)"
|
|
42
|
-
/>
|
|
43
|
-
<message-document
|
|
44
|
-
v-else-if="document"
|
|
45
|
-
:file="document"
|
|
46
|
-
:self-side="isSelfSide"
|
|
47
|
-
/>
|
|
48
|
-
<div
|
|
49
|
-
v-if="props.message?.text"
|
|
50
|
-
class="chat-message-text-wrapper"
|
|
51
|
-
>
|
|
52
|
-
<message-text
|
|
53
|
-
:text="props.message.text"
|
|
54
|
-
:with-timestamp-spacer="true"
|
|
28
|
+
>
|
|
29
|
+
<template v-if="hasFileError">
|
|
30
|
+
<message-blocked-error v-if="isFileMalware" />
|
|
31
|
+
<message-size-exceeded-error
|
|
32
|
+
v-else-if="isFileSizeExceeded"
|
|
33
|
+
:self-side="isSelfSide"
|
|
55
34
|
/>
|
|
56
35
|
<message-time :date="props.message.createdAt" />
|
|
57
|
-
</
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
</template>
|
|
37
|
+
<template v-else>
|
|
38
|
+
<message-player
|
|
39
|
+
v-if="media"
|
|
40
|
+
:file="media"
|
|
41
|
+
:type="media.mime"
|
|
42
|
+
:size="size"
|
|
43
|
+
@initialized="handlePlayerInitialize"
|
|
44
|
+
/>
|
|
45
|
+
<message-image
|
|
46
|
+
v-else-if="image"
|
|
47
|
+
:file="image"
|
|
48
|
+
@open="emit(MessageAction.ClickOnImage)"
|
|
49
|
+
/>
|
|
50
|
+
<message-document
|
|
51
|
+
v-else-if="document"
|
|
52
|
+
:file="document"
|
|
53
|
+
:self-side="isSelfSide"
|
|
54
|
+
/>
|
|
55
|
+
<div
|
|
56
|
+
v-if="props.message?.text"
|
|
57
|
+
class="chat-message-text-wrapper"
|
|
58
|
+
>
|
|
59
|
+
<message-text
|
|
60
|
+
:text="props.message.text"
|
|
61
|
+
:with-timestamp-spacer="true"
|
|
62
|
+
/>
|
|
63
|
+
<message-time :date="props.message.createdAt" />
|
|
64
|
+
</div>
|
|
65
|
+
<message-time
|
|
66
|
+
v-else
|
|
67
|
+
:date="props.message.createdAt"
|
|
68
|
+
/>
|
|
69
|
+
</template>
|
|
62
70
|
</div>
|
|
63
|
-
<message-time
|
|
64
|
-
v-if="message.file?.malware || isFileSizeExceeded"
|
|
65
|
-
:date="props.message.createdAt"
|
|
66
|
-
/>
|
|
67
71
|
</div>
|
|
68
72
|
|
|
69
73
|
<slot name="after-message" />
|
|
@@ -112,6 +116,12 @@ const isFileSizeExceeded = computed<boolean>(
|
|
|
112
116
|
() => !!props.message.file && !props.message.file?.size,
|
|
113
117
|
);
|
|
114
118
|
|
|
119
|
+
const isFileMalware = computed<boolean>(() => !!props.message.file?.malware);
|
|
120
|
+
|
|
121
|
+
const hasFileError = computed<boolean>(
|
|
122
|
+
() => isFileMalware.value || isFileSizeExceeded.value,
|
|
123
|
+
);
|
|
124
|
+
|
|
115
125
|
const isInternalMember = computed(
|
|
116
126
|
() => props.message.member?.type === 'webitel',
|
|
117
127
|
);
|
|
@@ -192,6 +202,11 @@ function handlePlayerInitialize(player) {
|
|
|
192
202
|
place-self: flex-start;
|
|
193
203
|
}
|
|
194
204
|
|
|
205
|
+
.chat-message__body--malware,
|
|
206
|
+
.chat-message--right .chat-message__body--malware {
|
|
207
|
+
background: var(--p-error-highlight-color);
|
|
208
|
+
}
|
|
209
|
+
|
|
195
210
|
.chat-message-time {
|
|
196
211
|
margin-top: var(--p-player-chat-message-gap);
|
|
197
212
|
}
|
|
@@ -19,9 +19,6 @@ const { t } = useI18n();
|
|
|
19
19
|
</script>
|
|
20
20
|
<style scoped lang="scss">
|
|
21
21
|
.chat-message-blocked-error {
|
|
22
|
-
background: var(--p-error-highlight-color);
|
|
23
|
-
border-radius: var(--spacing-xs);
|
|
24
|
-
padding: var(--spacing-xs);
|
|
25
22
|
display: flex;
|
|
26
23
|
flex-direction: column;
|
|
27
24
|
align-items: center;
|
package/src/ui/messaging/modules/message/components/details/chat-message-size-exceeded-error.vue
CHANGED
|
@@ -31,9 +31,6 @@ withDefaults(defineProps<IChatMessageSizeExceededErrorProps>(), {
|
|
|
31
31
|
|
|
32
32
|
<style scoped lang="scss">
|
|
33
33
|
.chat-message-size-exceeded-error {
|
|
34
|
-
background: var(--primary-light-color);
|
|
35
|
-
border-radius: var(--spacing-xs);
|
|
36
|
-
padding: var(--spacing-xs);
|
|
37
34
|
display: flex;
|
|
38
35
|
flex-direction: column;
|
|
39
36
|
align-items: center;
|
|
@@ -42,7 +39,6 @@ withDefaults(defineProps<IChatMessageSizeExceededErrorProps>(), {
|
|
|
42
39
|
text-align: center;
|
|
43
40
|
|
|
44
41
|
&--right {
|
|
45
|
-
background: var(--secondary-light-color);
|
|
46
42
|
color: var(--secondary-on-color);
|
|
47
43
|
place-self: flex-end;
|
|
48
44
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|