@webitel/ui-chats 0.0.4 → 0.0.6
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 +1 -1
- package/src/ui/chat-footer/modules/user-input/components/actions/send-message-action.vue +2 -1
- package/src/ui/chat-footer/modules/user-input/components/chat-input-actions-bar.vue +4 -3
- package/src/ui/chat-footer/modules/user-input/components/chat-text-field.vue +2 -2
- package/src/ui/index.ts +1 -1
- package/src/ui/messaging/components/chat-date-divider.vue +34 -0
- package/src/ui/messaging/components/scroll-to-bottom-btn.vue +60 -0
- package/src/ui/messaging/components/the-chat-messages-container.vue +89 -0
- package/src/ui/messaging/composebles/useChatScroll.ts +34 -29
- package/src/ui/messaging/modules/message/composables/useChatMessage.ts +43 -0
- package/src/ui/{chat-container.vue → the-chat-container.vue} +13 -6
- package/types/ui/chat-container.vue.d.ts +44 -19
- package/types/ui/index.d.ts +1 -1
- package/types/ui/messaging/components/chat-date-divider.vue.d.ts +6 -0
- package/types/ui/messaging/components/chat-messages-container.vue.d.ts +23 -2
- package/types/ui/messaging/components/scroll-to-bottom-btn.vue.d.ts +12 -0
- package/types/ui/messaging/components/the-chat-messages-container.vue.d.ts +10 -0
- package/types/ui/messaging/modules/message/composables/useChatMessage.d.ts +12 -0
- package/types/ui/the-chat-container.vue.d.ts +33 -0
- package/src/ui/messaging/components/chat-messages-container.vue +0 -19
package/package.json
CHANGED
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
13
|
import type { ComponentSize } from "@webitel/ui-sdk/enums";
|
|
14
14
|
import { inject } from "vue";
|
|
15
|
+
|
|
15
16
|
import type { ChatAction } from "../../types/ChatAction.types";
|
|
16
17
|
|
|
17
18
|
const _size = inject<ComponentSize>("size");
|
|
18
19
|
|
|
19
20
|
const _emit = defineEmits<(e: typeof ChatAction.SendMessage) => void>();
|
|
20
|
-
</script>
|
|
21
|
+
</script>
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
<component
|
|
10
10
|
:is="actionComponent"
|
|
11
11
|
:size="size"
|
|
12
|
-
@
|
|
13
|
-
@
|
|
12
|
+
@send-message="emit(ChatAction.SendMessage)"
|
|
13
|
+
@attach-files="emit(ChatAction.AttachFiles, $event)"
|
|
14
14
|
/>
|
|
15
15
|
</slot>
|
|
16
16
|
</section>
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
<script setup lang="ts">
|
|
20
20
|
import type { ComponentSize } from "@webitel/ui-sdk/enums";
|
|
21
21
|
import { computed, inject } from "vue";
|
|
22
|
+
|
|
22
23
|
import { ChatAction, type SharedActionSlots } from "../types/ChatAction.types";
|
|
23
24
|
import AttachFilesAction from "./actions/attach-files-action.vue";
|
|
24
25
|
import EmojiPickerAction from "./actions/emoji-picker-action.vue";
|
|
@@ -71,4 +72,4 @@ const _ShownActionComponentsList = computed(() => {
|
|
|
71
72
|
flex: 1;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
</style>
|
|
75
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<wt-textarea
|
|
3
|
-
v-model="textModel"
|
|
4
3
|
ref="chatTextFieldInput"
|
|
4
|
+
v-model="textModel"
|
|
5
5
|
:size="size"
|
|
6
6
|
autoresize
|
|
7
7
|
/>
|
|
@@ -41,4 +41,4 @@ function insertAtCursor(text: string) {
|
|
|
41
41
|
focus();
|
|
42
42
|
insertTextAtCursor(textareaEl.value!, text);
|
|
43
43
|
}
|
|
44
|
-
</script>
|
|
44
|
+
</script>
|
package/src/ui/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as ChatContainerComponent } from "./chat-container.vue";
|
|
2
1
|
export { ChatAction } from "./chat-footer/modules/user-input/types/ChatAction.types";
|
|
3
2
|
export type { ChatMessageType } from "./messaging/types/ChatMessage.types";
|
|
3
|
+
export { default as ChatContainer } from "./the-chat-container.vue";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chat-date-divider">
|
|
3
|
+
{{ formattedDate }}
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { FormatDateMode } from "@webitel/ui-sdk/enums";
|
|
9
|
+
import { formatDate } from "@webitel/ui-sdk/utils";
|
|
10
|
+
import { computed } from "vue";
|
|
11
|
+
import { useI18n } from "vue-i18n";
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
date: number | string;
|
|
15
|
+
}>();
|
|
16
|
+
|
|
17
|
+
const { t } = useI18n();
|
|
18
|
+
|
|
19
|
+
const _formattedDate = computed<Date>(() => {
|
|
20
|
+
const chatDate = formatDate(+props.date, FormatDateMode.DATE);
|
|
21
|
+
const today = formatDate(Date.now(), FormatDateMode.DATE);
|
|
22
|
+
|
|
23
|
+
return chatDate === today ? t("reusable.today") : chatDate;
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<style lang="scss" scoped>
|
|
28
|
+
.chat-date-divider {
|
|
29
|
+
@extend %typo-subtitle-1;
|
|
30
|
+
width: 100%;
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="scroll-to-bottom-btn">
|
|
3
|
+
|
|
4
|
+
<div
|
|
5
|
+
v-show="props.newMessageCount"
|
|
6
|
+
class="scroll-to-bottom-btn__messages-counter"
|
|
7
|
+
>
|
|
8
|
+
{{ props.newMessageCount }}
|
|
9
|
+
</div>
|
|
10
|
+
<wt-rounded-action
|
|
11
|
+
icon="arrow-down"
|
|
12
|
+
rounded
|
|
13
|
+
@click="emit('scroll')"
|
|
14
|
+
/>
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { defineEmits } from "vue";
|
|
21
|
+
|
|
22
|
+
const _props = withDefaults(
|
|
23
|
+
defineProps<{
|
|
24
|
+
newMessageCount?: number;
|
|
25
|
+
}>(),
|
|
26
|
+
{
|
|
27
|
+
newMessageCount: 0,
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const _emit = defineEmits<{
|
|
32
|
+
scroll: [];
|
|
33
|
+
}>();
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<style lang="scss" scoped>
|
|
37
|
+
|
|
38
|
+
.scroll-to-bottom-btn {
|
|
39
|
+
position: absolute;
|
|
40
|
+
bottom: 0;
|
|
41
|
+
right: calc(var(--scrollbar-width) + var(--spacing-2xs));
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: var(--spacing-2xs);
|
|
46
|
+
|
|
47
|
+
&__messages-counter {
|
|
48
|
+
@extend %typo-body-2;
|
|
49
|
+
width: 24px;
|
|
50
|
+
height: 24px;
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
background: var(--success-color);
|
|
55
|
+
border-radius: 50%;
|
|
56
|
+
color: var(--text-on-brand-color);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="the-chat-messages-container" @click="focusOnInput">
|
|
3
|
+
<div
|
|
4
|
+
ref="messages-container"
|
|
5
|
+
class="the-chat-messages-container__wrapper"
|
|
6
|
+
@scroll="handleChatScroll"
|
|
7
|
+
@resize="handleChatResize"
|
|
8
|
+
>
|
|
9
|
+
<chat-message-component
|
|
10
|
+
v-for="(message, index) of props.messages"
|
|
11
|
+
:key="message.id"
|
|
12
|
+
:message="message"
|
|
13
|
+
:show-avatar="!props.hideAvatars && showAvatar(index)"
|
|
14
|
+
>
|
|
15
|
+
<template #before-message>
|
|
16
|
+
<chat-date
|
|
17
|
+
v-if="showChatDate(index)"
|
|
18
|
+
:date="message.createdAt"
|
|
19
|
+
/>
|
|
20
|
+
</template>
|
|
21
|
+
</chat-message-component>
|
|
22
|
+
</div>
|
|
23
|
+
<scroll-to-bottom-btn
|
|
24
|
+
v-if="showScrollToBottomBtn"
|
|
25
|
+
:new-message-count="newUnseenMessages"
|
|
26
|
+
@scroll="scrollToBottom('smooth')"
|
|
27
|
+
/>
|
|
28
|
+
</section>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import type { Emitter } from "mitt";
|
|
33
|
+
import { inject, useTemplateRef } from "vue";
|
|
34
|
+
|
|
35
|
+
import type { UiChatsEmitterEvents } from "../../utils/emitter";
|
|
36
|
+
import { useChatScroll } from "../composebles/useChatScroll";
|
|
37
|
+
import { useChatMessages } from "../modules/message/composables/useChatMessage";
|
|
38
|
+
import type { ChatMessageType } from "../types/ChatMessage.types";
|
|
39
|
+
|
|
40
|
+
const uiChatsEmitter = inject<Emitter<UiChatsEmitterEvents>>("uiChatsEmitter");
|
|
41
|
+
|
|
42
|
+
const props = withDefaults(
|
|
43
|
+
defineProps<{
|
|
44
|
+
messages: ChatMessageType[];
|
|
45
|
+
hideAvatars?: boolean;
|
|
46
|
+
}>(),
|
|
47
|
+
{
|
|
48
|
+
hideAvatars: false,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const messagesContainer = useTemplateRef("messages-container");
|
|
53
|
+
|
|
54
|
+
const { showAvatar, showChatDate } = useChatMessages(props.messages);
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
showScrollToBottomBtn,
|
|
58
|
+
newUnseenMessages,
|
|
59
|
+
scrollToBottom,
|
|
60
|
+
handleChatScroll,
|
|
61
|
+
handleChatResize,
|
|
62
|
+
} = useChatScroll(messagesContainer, props.messages);
|
|
63
|
+
|
|
64
|
+
function _focusOnInput() {
|
|
65
|
+
uiChatsEmitter?.on("focusOnTextField", focus);
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<style scoped lang="scss">
|
|
70
|
+
.the-chat-messages-container {
|
|
71
|
+
position: relative;
|
|
72
|
+
display: flex;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
height: inherit;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.the-chat-messages-container__wrapper {
|
|
78
|
+
@extend %wt-scrollbar;
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
overflow-x: hidden;
|
|
83
|
+
overflow-y: auto;
|
|
84
|
+
width: 100%;
|
|
85
|
+
padding-right: var(--scrollbar-width); // scrollbar offset
|
|
86
|
+
scrollbar-gutter: stable both-edges;
|
|
87
|
+
gap: var(--spacing-xs);
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -26,26 +26,23 @@ export const useChatScroll = (
|
|
|
26
26
|
Boolean(lastMessage.value?.member?.self),
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
element.value
|
|
31
|
-
|
|
32
|
-
behavior: behavior === "instant" ? "auto" : behavior,
|
|
33
|
-
});
|
|
29
|
+
const handleChatScroll = () => {
|
|
30
|
+
const wrapper = element.value;
|
|
31
|
+
if (!wrapper) return;
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
handleShowScrollToBottomBtn(wrapper);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleChatResize = () => {
|
|
37
|
+
const wrapper = element.value;
|
|
38
|
+
if (!wrapper) return;
|
|
39
|
+
|
|
40
|
+
updateThreshold(wrapper);
|
|
41
|
+
handleShowScrollToBottomBtn(wrapper);
|
|
37
42
|
};
|
|
38
43
|
|
|
39
44
|
const handleShowScrollToBottomBtn = (el: HTMLElement) => {
|
|
40
|
-
|
|
41
|
-
/* @author ye.pohranichna
|
|
42
|
-
hide the btn and reset new messages count, when we scroll to the bottom without btn */
|
|
43
|
-
newUnseenMessages.value = 0;
|
|
44
|
-
showScrollToBottomBtn.value = false;
|
|
45
|
-
/* @author ye.pohranichna
|
|
46
|
-
quit the function because we are already at the bottom */
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
45
|
+
resetScrollToBottomBtn();
|
|
49
46
|
|
|
50
47
|
const { scrollTop, scrollHeight, clientHeight } = el;
|
|
51
48
|
const distanceFromBottom = scrollHeight - (scrollTop + clientHeight);
|
|
@@ -54,11 +51,23 @@ export const useChatScroll = (
|
|
|
54
51
|
|
|
55
52
|
const updateThreshold = (el: HTMLElement) => {
|
|
56
53
|
/* @author ye.pohranichna
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
need to update if clientHeight was changed
|
|
55
|
+
https://webitel.atlassian.net/browse/WTEL-7136 */
|
|
59
56
|
threshold.value = Math.max(defaultThreshold, el.clientHeight * 0.3);
|
|
60
57
|
};
|
|
61
58
|
|
|
59
|
+
const resetScrollToBottomBtn = (): void => {
|
|
60
|
+
if (arrivedState.bottom && newUnseenMessages.value) {
|
|
61
|
+
/* @author ye.pohranichna
|
|
62
|
+
hide the btn and reset new messages count, when we scroll to the bottom without btn */
|
|
63
|
+
newUnseenMessages.value = 0;
|
|
64
|
+
showScrollToBottomBtn.value = false;
|
|
65
|
+
/* @author ye.pohranichna
|
|
66
|
+
quit the function because we are already at the bottom */
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
62
71
|
const scrollToBottomAfterNewMessage = () => {
|
|
63
72
|
if (arrivedState.bottom || isLastMessageIsMy.value) {
|
|
64
73
|
scrollToBottom("smooth");
|
|
@@ -66,19 +75,15 @@ export const useChatScroll = (
|
|
|
66
75
|
newUnseenMessages.value += 1;
|
|
67
76
|
}
|
|
68
77
|
};
|
|
69
|
-
const handleChatScroll = () => {
|
|
70
|
-
const wrapper = element.value;
|
|
71
|
-
if (!wrapper) return;
|
|
72
|
-
|
|
73
|
-
handleShowScrollToBottomBtn(wrapper);
|
|
74
|
-
};
|
|
75
78
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
const scrollToBottom = (behavior: ScrollBehavior = "instant") => {
|
|
80
|
+
element?.value.scrollTo({
|
|
81
|
+
top: element?.value.scrollHeight,
|
|
82
|
+
behavior: behavior === "instant" ? "auto" : behavior,
|
|
83
|
+
});
|
|
79
84
|
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
newUnseenMessages.value = 0;
|
|
86
|
+
showScrollToBottomBtn.value = false;
|
|
82
87
|
};
|
|
83
88
|
|
|
84
89
|
watch(
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FormatDateMode } from "@webitel/ui-sdk/enums";
|
|
2
|
+
import { formatDate } from "@webitel/ui-sdk/utils";
|
|
3
|
+
import { type Ref, ref } from "vue";
|
|
4
|
+
|
|
5
|
+
import type { ChatMessageType } from "../../../types/ChatMessage.types";
|
|
6
|
+
|
|
7
|
+
interface GetMessageResult {
|
|
8
|
+
prevMessage?: ChatMessageType;
|
|
9
|
+
message?: ChatMessageType;
|
|
10
|
+
nextMessage?: ChatMessageType;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useChatMessages = (chatMessages: ChatMessageType[]) => {
|
|
14
|
+
const messages: Ref<ChatMessageType[]> = ref(chatMessages);
|
|
15
|
+
|
|
16
|
+
function showChatDate(index: number): boolean {
|
|
17
|
+
const { prevMessage, message } = getMessage(index);
|
|
18
|
+
return (
|
|
19
|
+
!!prevMessage &&
|
|
20
|
+
formatDate(+prevMessage?.createdAt, FormatDateMode.DATE) !==
|
|
21
|
+
formatDate(+message?.createdAt, FormatDateMode.DATE)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const showAvatar = (index: number): boolean => {
|
|
26
|
+
const { prevMessage, message } = getMessage(index);
|
|
27
|
+
return index === 0 || message?.member?.type !== prevMessage?.member?.type;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function getMessage(index: number): GetMessageResult {
|
|
31
|
+
return {
|
|
32
|
+
prevMessage: messages.value[index - 1],
|
|
33
|
+
message: messages.value[index],
|
|
34
|
+
nextMessage: messages.value[index + 1],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
showAvatar,
|
|
40
|
+
getMessage,
|
|
41
|
+
showChatDate,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
header goes here
|
|
5
5
|
</slot> -->
|
|
6
6
|
<slot name="main">
|
|
7
|
-
<chat-messages-container
|
|
7
|
+
<chat-messages-container
|
|
8
|
+
:messages="props.messages"
|
|
9
|
+
:hide-avatars="props.hideAvatars"
|
|
10
|
+
/>
|
|
8
11
|
</slot>
|
|
9
12
|
<slot name="footer">
|
|
10
13
|
<chat-footer-wrapper>
|
|
@@ -17,10 +20,10 @@
|
|
|
17
20
|
@[ChatAction.SendMessage]="sendMessage"
|
|
18
21
|
@[ChatAction.AttachFiles]="sendFile"
|
|
19
22
|
>
|
|
20
|
-
<template
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
<template
|
|
24
|
+
v-for="action in slottedChatActions"
|
|
25
|
+
:key="action"
|
|
26
|
+
#[action]="{ size }"
|
|
24
27
|
>
|
|
25
28
|
<slot
|
|
26
29
|
:name="`action:${action}`"
|
|
@@ -37,6 +40,7 @@
|
|
|
37
40
|
<script setup lang="ts">
|
|
38
41
|
import { ComponentSize } from "@webitel/ui-sdk/enums";
|
|
39
42
|
import { computed, provide, ref } from "vue";
|
|
43
|
+
|
|
40
44
|
import {
|
|
41
45
|
ChatAction,
|
|
42
46
|
type SharedActionSlots,
|
|
@@ -50,9 +54,11 @@ const props = withDefaults(
|
|
|
50
54
|
messages: ChatMessageType[];
|
|
51
55
|
chatActions?: ChatAction[];
|
|
52
56
|
size?: ComponentSize;
|
|
57
|
+
hideAvatars?: boolean;
|
|
53
58
|
}>(),
|
|
54
59
|
{
|
|
55
60
|
size: ComponentSize.MD,
|
|
61
|
+
hideAvatars: false,
|
|
56
62
|
chatActions: () => [
|
|
57
63
|
ChatAction.SendMessage,
|
|
58
64
|
],
|
|
@@ -107,5 +113,6 @@ function _sendFile(files: File[]) {
|
|
|
107
113
|
.chat-container {
|
|
108
114
|
display: flex;
|
|
109
115
|
flex-direction: column;
|
|
116
|
+
height: 100%;
|
|
110
117
|
}
|
|
111
|
-
</style>
|
|
118
|
+
</style>
|
|
@@ -1,31 +1,56 @@
|
|
|
1
1
|
import { ComponentSize } from "@webitel/ui-sdk/enums";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ChatAction,
|
|
4
|
+
type SharedActionSlots,
|
|
5
|
+
} from "./chat-footer/modules/user-input/types/ChatAction.types";
|
|
3
6
|
import type { ChatMessageType } from "./messaging/types/ChatMessage.types";
|
|
4
7
|
import type { ResultCallbacks } from "./utils/ResultCallbacks.types";
|
|
5
8
|
type __VLS_Props = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
messages: ChatMessageType[];
|
|
10
|
+
chatActions?: ChatAction[];
|
|
11
|
+
size?: ComponentSize;
|
|
9
12
|
};
|
|
10
13
|
type __VLS_Slots = {
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
main: () => any;
|
|
15
|
+
footer: () => any;
|
|
13
16
|
} & SharedActionSlots;
|
|
14
|
-
declare const __VLS_base: import("vue").DefineComponent<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
declare const __VLS_base: import("vue").DefineComponent<
|
|
18
|
+
__VLS_Props,
|
|
19
|
+
{},
|
|
20
|
+
{},
|
|
21
|
+
{},
|
|
22
|
+
{},
|
|
23
|
+
import("vue").ComponentOptionsMixin,
|
|
24
|
+
import("vue").ComponentOptionsMixin,
|
|
25
|
+
{} & {
|
|
26
|
+
"action:sendMessage": (text: string, options: ResultCallbacks) => any;
|
|
27
|
+
"action:attachFiles": (files: File[], options: ResultCallbacks) => any;
|
|
28
|
+
},
|
|
29
|
+
string,
|
|
30
|
+
import("vue").PublicProps,
|
|
31
|
+
Readonly<__VLS_Props> &
|
|
32
|
+
Readonly<{
|
|
33
|
+
"onAction:sendMessage"?: (text: string, options: ResultCallbacks) => any;
|
|
34
|
+
"onAction:attachFiles"?: (files: File[], options: ResultCallbacks) => any;
|
|
35
|
+
}>,
|
|
36
|
+
{
|
|
37
|
+
chatActions: ChatAction[];
|
|
38
|
+
size: ComponentSize;
|
|
39
|
+
},
|
|
40
|
+
{},
|
|
41
|
+
{},
|
|
42
|
+
{},
|
|
43
|
+
string,
|
|
44
|
+
import("vue").ComponentProvideOptions,
|
|
45
|
+
false,
|
|
46
|
+
{},
|
|
47
|
+
any
|
|
48
|
+
>;
|
|
24
49
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
50
|
declare const _default: typeof __VLS_export;
|
|
26
51
|
export default _default;
|
|
27
52
|
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
new (): {
|
|
54
|
+
$slots: S;
|
|
55
|
+
};
|
|
31
56
|
};
|
package/types/ui/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as ChatContainerComponent } from "./chat-container.vue";
|
|
2
1
|
export { ChatAction } from "./chat-footer/modules/user-input/types/ChatAction.types";
|
|
3
2
|
export type { ChatMessageType } from "./messaging/types/ChatMessage.types";
|
|
3
|
+
export { default as ChatContainer } from "./the-chat-container.vue";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
date: number | string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import type { ChatMessageType } from "../types/ChatMessage.types";
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
|
|
3
|
+
messages: ChatMessageType[];
|
|
4
4
|
};
|
|
5
|
-
declare const __VLS_export: import("vue").DefineComponent<
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<
|
|
6
|
+
__VLS_Props,
|
|
7
|
+
{},
|
|
8
|
+
{},
|
|
9
|
+
{},
|
|
10
|
+
{},
|
|
11
|
+
import("vue").ComponentOptionsMixin,
|
|
12
|
+
import("vue").ComponentOptionsMixin,
|
|
13
|
+
{},
|
|
14
|
+
string,
|
|
15
|
+
import("vue").PublicProps,
|
|
16
|
+
Readonly<__VLS_Props> & Readonly<{}>,
|
|
17
|
+
{},
|
|
18
|
+
{},
|
|
19
|
+
{},
|
|
20
|
+
{},
|
|
21
|
+
string,
|
|
22
|
+
import("vue").ComponentProvideOptions,
|
|
23
|
+
false,
|
|
24
|
+
{},
|
|
25
|
+
any
|
|
26
|
+
>;
|
|
6
27
|
declare const _default: typeof __VLS_export;
|
|
7
28
|
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
newMessageCount?: number;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
scroll: () => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
7
|
+
onScroll?: () => any;
|
|
8
|
+
}>, {
|
|
9
|
+
newMessageCount: number;
|
|
10
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChatMessageType } from "../types/ChatMessage.types";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
messages: ChatMessageType[];
|
|
4
|
+
hideAvatars?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
7
|
+
hideAvatars: boolean;
|
|
8
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChatMessageType } from "../../../types/ChatMessage.types";
|
|
2
|
+
interface GetMessageResult {
|
|
3
|
+
prevMessage?: ChatMessageType;
|
|
4
|
+
message?: ChatMessageType;
|
|
5
|
+
nextMessage?: ChatMessageType;
|
|
6
|
+
}
|
|
7
|
+
export declare const useChatMessages: (chatMessages: ChatMessageType[]) => {
|
|
8
|
+
showAvatar: (index: number) => boolean;
|
|
9
|
+
getMessage: (index: number) => GetMessageResult;
|
|
10
|
+
showChatDate: (index: number) => boolean;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentSize } from "@webitel/ui-sdk/enums";
|
|
2
|
+
import { ChatAction, type SharedActionSlots } from "./chat-footer/modules/user-input/types/ChatAction.types";
|
|
3
|
+
import type { ChatMessageType } from "./messaging/types/ChatMessage.types";
|
|
4
|
+
import type { ResultCallbacks } from "./utils/ResultCallbacks.types";
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
messages: ChatMessageType[];
|
|
7
|
+
chatActions?: ChatAction[];
|
|
8
|
+
size?: ComponentSize;
|
|
9
|
+
hideAvatars?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = {
|
|
12
|
+
main: () => any;
|
|
13
|
+
footer: () => any;
|
|
14
|
+
} & SharedActionSlots;
|
|
15
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
16
|
+
"action:sendMessage": (text: string, options: ResultCallbacks) => any;
|
|
17
|
+
"action:attachFiles": (files: File[], options: ResultCallbacks) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
"onAction:sendMessage"?: (text: string, options: ResultCallbacks) => any;
|
|
20
|
+
"onAction:attachFiles"?: (files: File[], options: ResultCallbacks) => any;
|
|
21
|
+
}>, {
|
|
22
|
+
chatActions: ChatAction[];
|
|
23
|
+
size: ComponentSize;
|
|
24
|
+
hideAvatars: boolean;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
29
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
30
|
+
new (): {
|
|
31
|
+
$slots: S;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<section class="chat-messages-container">
|
|
3
|
-
<!-- <chat-message-component
|
|
4
|
-
v-for="message in messages"
|
|
5
|
-
:key="message.id"
|
|
6
|
-
:message="message"
|
|
7
|
-
/> -->
|
|
8
|
-
</section>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup lang="ts">
|
|
12
|
-
import type { ChatMessageType } from "../types/ChatMessage.types";
|
|
13
|
-
|
|
14
|
-
// import ChatMessageComponent from '../modules/message/components/chat-message.vue';
|
|
15
|
-
|
|
16
|
-
const _props = defineProps<{
|
|
17
|
-
messages: ChatMessageType[];
|
|
18
|
-
}>();
|
|
19
|
-
</script>
|