@webitel/ui-chats 0.0.23 → 0.0.25
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/chat-text-field.vue +5 -0
- package/src/ui/messaging/components/the-messages-container.vue +12 -3
- package/src/ui/messaging/modules/message/components/chat-message.vue +1 -0
- package/src/ui/messaging/modules/message/composables/useChatMessage.ts +4 -4
- package/src/ui/the-chat-container.vue +1 -0
- package/types/ui/chat-footer/modules/user-input/components/chat-text-field.vue.d.ts +2 -0
- package/types/ui/messaging/modules/message/composables/useChatMessage.d.ts +2 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
:size="size"
|
|
7
7
|
autoresize
|
|
8
8
|
@update:model-value="send"
|
|
9
|
+
@enter="emit('enter')"
|
|
9
10
|
/>
|
|
10
11
|
</template>
|
|
11
12
|
|
|
@@ -28,6 +29,10 @@ const uiChatsEmitter = inject<Emitter<UiChatsEmitterEvents>>("uiChatsEmitter");
|
|
|
28
29
|
uiChatsEmitter!.on("insertAtCursor", ({ text }) => insertAtCursor(text));
|
|
29
30
|
uiChatsEmitter!.on("focusOnTextField", focus);
|
|
30
31
|
|
|
32
|
+
const emit = defineEmits<{
|
|
33
|
+
enter: [];
|
|
34
|
+
}>();
|
|
35
|
+
|
|
31
36
|
const chatTextFieldInputRef =
|
|
32
37
|
useTemplateRef<typeof WtTextarea>("chatTextFieldInput");
|
|
33
38
|
|
|
@@ -41,7 +41,14 @@
|
|
|
41
41
|
|
|
42
42
|
<script setup lang="ts">
|
|
43
43
|
import type { Emitter } from "mitt";
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
computed,
|
|
46
|
+
defineProps,
|
|
47
|
+
inject,
|
|
48
|
+
nextTick,
|
|
49
|
+
onMounted,
|
|
50
|
+
useTemplateRef,
|
|
51
|
+
} from "vue";
|
|
45
52
|
|
|
46
53
|
import { ChatAction } from "../../chat-footer/modules/user-input/enums/ChatAction.enum";
|
|
47
54
|
import type { UiChatsEmitterEvents } from "../../utils/emitter";
|
|
@@ -74,7 +81,9 @@ const emit = defineEmits<(e: typeof ChatAction.LoadNextMessages) => void>();
|
|
|
74
81
|
|
|
75
82
|
const messagesContainer = useTemplateRef("messages-container");
|
|
76
83
|
|
|
77
|
-
const { showAvatar, showChatDate } = useChatMessages(
|
|
84
|
+
const { showAvatar, showChatDate } = useChatMessages(
|
|
85
|
+
computed(() => props.messages),
|
|
86
|
+
); // props values reactivity https://stackoverflow.com/questions/72408463/use-props-in-composables-vue3 @author ye.pohranichna
|
|
78
87
|
|
|
79
88
|
const {
|
|
80
89
|
showScrollToBottomBtn,
|
|
@@ -84,7 +93,7 @@ const {
|
|
|
84
93
|
handleChatResize,
|
|
85
94
|
} = useChatScroll(
|
|
86
95
|
messagesContainer,
|
|
87
|
-
computed(() => props.messages),
|
|
96
|
+
computed(() => props.messages), // props values reactivity https://stackoverflow.com/questions/72408463/use-props-in-composables-vue3 @author ye.pohranichna
|
|
88
97
|
);
|
|
89
98
|
|
|
90
99
|
function focusOnInput() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormatDateMode } from "@webitel/ui-sdk/enums";
|
|
2
2
|
import { formatDate } from "@webitel/ui-sdk/utils";
|
|
3
|
-
import { type
|
|
3
|
+
import { type ComputedRef, type Ref } from "vue";
|
|
4
4
|
|
|
5
5
|
import type { ChatMessageType } from "../../../types/ChatMessage.types";
|
|
6
6
|
|
|
@@ -10,9 +10,9 @@ interface GetMessageResult {
|
|
|
10
10
|
nextMessage?: ChatMessageType;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const useChatMessages = (
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export const useChatMessages = (
|
|
14
|
+
messages: Ref<ChatMessageType[]> | ComputedRef<ChatMessageType[]>,
|
|
15
|
+
) => {
|
|
16
16
|
function showChatDate(index: number): boolean {
|
|
17
17
|
const { prevMessage, message } = getMessage(index);
|
|
18
18
|
const prevDate = +prevMessage?.createdAt || 0;
|
|
@@ -3,8 +3,10 @@ type __VLS_ModelProps = {
|
|
|
3
3
|
"text": MaybeRef<string>;
|
|
4
4
|
};
|
|
5
5
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
enter: () => any;
|
|
6
7
|
"update:text": (value: MaybeRef<string>) => any;
|
|
7
8
|
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
9
|
+
onEnter?: () => any;
|
|
8
10
|
"onUpdate:text"?: (value: MaybeRef<string>) => any;
|
|
9
11
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
12
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from "vue";
|
|
1
2
|
import type { ChatMessageType } from "../../../types/ChatMessage.types";
|
|
2
3
|
interface GetMessageResult {
|
|
3
4
|
prevMessage?: ChatMessageType;
|
|
4
5
|
message?: ChatMessageType;
|
|
5
6
|
nextMessage?: ChatMessageType;
|
|
6
7
|
}
|
|
7
|
-
export declare const useChatMessages: (
|
|
8
|
+
export declare const useChatMessages: (messages: Ref<ChatMessageType[]> | ComputedRef<ChatMessageType[]>) => {
|
|
8
9
|
showAvatar: (index: number) => boolean;
|
|
9
10
|
getMessage: (index: number) => GetMessageResult;
|
|
10
11
|
showChatDate: (index: number) => boolean;
|