@webitel/ui-chats 0.0.17 → 0.0.18
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/index.ts +1 -0
- package/src/ui/messaging/components/the-chat-messages-container.vue +6 -0
- package/src/ui/messaging/modules/message/components/chat-message.vue +5 -6
- package/src/ui/messaging/modules/message/enums/MessageAction.enum.ts +6 -0
- package/src/ui/the-chat-container.vue +5 -0
- package/src/ui/utils/emitter.ts +3 -0
- package/types/ui/chat-footer/modules/user-input/enums/ChatAction.enum.d.ts +5 -5
- package/types/ui/messaging/modules/message/components/chat-message.vue.d.ts +5 -5
- package/types/ui/messaging/modules/message/enums/MessageAction.enum.d.ts +5 -0
- package/types/ui/messaging/types/ChatMessage.types.d.ts +32 -32
- package/types/ui/the-chat-container.vue.d.ts +46 -21
- package/types/ui/utils/emitter.d.ts +2 -0
package/package.json
CHANGED
package/src/ui/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ChatAction } from "./chat-footer/modules/user-input/enums/ChatAction.enum";
|
|
2
|
+
export { MessageAction } from "./messaging/modules/message/enums/MessageAction.enum";
|
|
2
3
|
export type { ChatMessageType } from "./messaging/types/ChatMessage.types";
|
|
3
4
|
export { default as ChatContainer } from "./the-chat-container.vue";
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
:message="message"
|
|
16
16
|
:show-avatar="showAvatar(index)"
|
|
17
17
|
:without-avatars="props.withoutAvatars"
|
|
18
|
+
@[MessageAction.ClickOnImage]="clickOnImage(message)"
|
|
18
19
|
>
|
|
19
20
|
<template #before-message>
|
|
20
21
|
<chat-date-divider
|
|
@@ -40,6 +41,7 @@ import type { UiChatsEmitterEvents } from "../../utils/emitter";
|
|
|
40
41
|
import { useChatScroll } from "../composables/useChatScroll";
|
|
41
42
|
import ChatMessage from "../modules/message/components/chat-message.vue";
|
|
42
43
|
import { useChatMessages } from "../modules/message/composables/useChatMessage";
|
|
44
|
+
import { MessageAction } from "../modules/message/enums/MessageAction.enum";
|
|
43
45
|
import type { ChatMessageType } from "../types/ChatMessage.types";
|
|
44
46
|
import ChatDateDivider from "./chat-date-divider.vue";
|
|
45
47
|
import ScrollToBottomBtn from "./scroll-to-bottom-btn.vue";
|
|
@@ -75,6 +77,10 @@ function focusOnInput() {
|
|
|
75
77
|
uiChatsEmitter?.on("focusOnTextField", focus);
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
function clickOnImage(message: ChatMessageType) {
|
|
81
|
+
uiChatsEmitter!.emit("clickChatMessageImage", message);
|
|
82
|
+
}
|
|
83
|
+
|
|
78
84
|
onMounted(() => {
|
|
79
85
|
nextTick(() => {
|
|
80
86
|
scrollToBottom();
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
<message-image
|
|
33
33
|
v-else-if="image"
|
|
34
34
|
:file="image"
|
|
35
|
-
@open="emit(
|
|
35
|
+
@open="emit(MessageAction.ClickOnImage)"
|
|
36
36
|
/>
|
|
37
37
|
<message-document
|
|
38
38
|
v-else-if="document"
|
|
@@ -58,6 +58,7 @@ import { computed, defineEmits, defineProps, inject } from "vue";
|
|
|
58
58
|
|
|
59
59
|
import type { ChatMessageType } from "../../../types/ChatMessage.types";
|
|
60
60
|
import { useChatMessageFile } from "../composables/useChatMessageFile";
|
|
61
|
+
import { MessageAction } from "../enums/MessageAction.enum";
|
|
61
62
|
import MessageAvatar from "./details/chat-message-avatar.vue";
|
|
62
63
|
import MessageBlockedError from "./details/chat-message-blocked-error.vue";
|
|
63
64
|
import MessageDocument from "./details/chat-message-document.vue";
|
|
@@ -81,10 +82,8 @@ const props = withDefaults(
|
|
|
81
82
|
);
|
|
82
83
|
|
|
83
84
|
const emit = defineEmits<{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
object,
|
|
87
|
-
];
|
|
85
|
+
(e: typeof MessageAction.ClickOnImage): void;
|
|
86
|
+
(e: typeof MessageAction.InitializedPlayer, player: object): void;
|
|
88
87
|
}>();
|
|
89
88
|
|
|
90
89
|
const size = inject<ComponentSize>("size");
|
|
@@ -108,7 +107,7 @@ const getClientUsername = computed<string>(() => {
|
|
|
108
107
|
});
|
|
109
108
|
|
|
110
109
|
function handlePlayerInitialize(player) {
|
|
111
|
-
emit(
|
|
110
|
+
emit(MessageAction.InitializedPlayer, {
|
|
112
111
|
player,
|
|
113
112
|
});
|
|
114
113
|
}
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
import Dropzone from "./messaging/components/dropzone.vue";
|
|
59
59
|
import ChatMessagesContainer from "./messaging/components/the-chat-messages-container.vue";
|
|
60
60
|
import { useDropzoneHandlers } from "./messaging/composables/useDropzoneHandlers";
|
|
61
|
+
import { MessageAction } from "./messaging/modules/message/enums/MessageAction.enum";
|
|
61
62
|
import type { ChatMessageType } from "./messaging/types/ChatMessage.types";
|
|
62
63
|
import { createUiChatsEmitter } from "./utils/emitter";
|
|
63
64
|
import type { ResultCallbacks } from "./utils/ResultCallbacks.types";
|
|
@@ -89,6 +90,7 @@ const emit = defineEmits<{
|
|
|
89
90
|
files: File[],
|
|
90
91
|
options: ResultCallbacks,
|
|
91
92
|
): void;
|
|
93
|
+
(e: typeof MessageAction.ClickOnImage, message: ChatMessageType): void;
|
|
92
94
|
}>();
|
|
93
95
|
|
|
94
96
|
const slots = defineSlots<
|
|
@@ -103,6 +105,9 @@ const uiChatsEmitter = createUiChatsEmitter();
|
|
|
103
105
|
provide("size", props.size);
|
|
104
106
|
provide("uiChatsEmitter", uiChatsEmitter);
|
|
105
107
|
|
|
108
|
+
uiChatsEmitter?.on("clickChatMessageImage", (message) => {
|
|
109
|
+
emit(MessageAction.ClickOnImage, message);
|
|
110
|
+
});
|
|
106
111
|
const { isDropzoneVisible, handleDragLeave } = useDropzoneHandlers();
|
|
107
112
|
|
|
108
113
|
const draft = ref<string>("");
|
package/src/ui/utils/emitter.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import mitt from "mitt";
|
|
2
2
|
|
|
3
|
+
import { ChatMessageType } from "../../../types/ui";
|
|
4
|
+
|
|
3
5
|
export type UiChatsEmitterEvents = {
|
|
4
6
|
insertAtCursor: {
|
|
5
7
|
text: string;
|
|
6
8
|
};
|
|
7
9
|
focusOnTextField: undefined;
|
|
10
|
+
clickChatMessageImage: ChatMessageType;
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
export const createUiChatsEmitter = () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const ChatAction: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
readonly SendMessage: "sendMessage";
|
|
3
|
+
readonly AttachFiles: "attachFiles";
|
|
4
|
+
readonly EmojiPicker: "emojiPicker";
|
|
5
|
+
readonly QuickReplies: "quickReplies";
|
|
6
6
|
};
|
|
7
7
|
export type ChatAction = (typeof ChatAction)[keyof typeof ChatAction];
|
|
8
8
|
export type SharedActionSlots = {
|
|
9
|
-
|
|
9
|
+
[key in `action:${ChatAction}`]?: () => any;
|
|
10
10
|
};
|
|
@@ -11,12 +11,12 @@ type __VLS_Slots = {} & {
|
|
|
11
11
|
} & {
|
|
12
12
|
'after-message'?: (props: typeof __VLS_44) => any;
|
|
13
13
|
};
|
|
14
|
-
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
15
|
+
clickOnImage: () => any;
|
|
16
|
+
initializedPlayer: (player: object) => any;
|
|
17
17
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
onClickOnImage?: () => any;
|
|
19
|
+
onInitializedPlayer?: (player: object) => any;
|
|
20
20
|
}>, {
|
|
21
21
|
username: string;
|
|
22
22
|
showAvatar: boolean;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
export interface ChatMessageType {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
id: number;
|
|
3
|
+
date?: number;
|
|
4
|
+
file?: ChatMessageFile;
|
|
5
|
+
member: ChatMember;
|
|
6
|
+
peer?: ChatMember;
|
|
7
|
+
chat?: ChatMessageChatInfo;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
channelId?: string;
|
|
10
|
+
updatedAt?: number;
|
|
11
|
+
contact?: null | ContactInfo;
|
|
12
|
+
text?: string;
|
|
13
13
|
}
|
|
14
14
|
export type ContactInfo = {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string;
|
|
17
17
|
};
|
|
18
18
|
export type ChatMessageFile = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
id?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
size?: string;
|
|
22
|
+
mime?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
streamUrl?: string;
|
|
25
25
|
};
|
|
26
26
|
export type ChatMember = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
id: number;
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
userId?: number;
|
|
31
|
+
externalId?: string;
|
|
32
|
+
via?: ChatVia;
|
|
33
|
+
self?: boolean;
|
|
34
34
|
};
|
|
35
35
|
export type ChatMessageChatInfo = {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
id: string;
|
|
37
|
+
via: ChatVia;
|
|
38
38
|
};
|
|
39
39
|
export type ChatVia = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
id: number;
|
|
41
|
+
name: string;
|
|
42
|
+
type: string;
|
|
43
|
+
messenger?: string;
|
|
44
44
|
};
|
|
@@ -1,33 +1,58 @@
|
|
|
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/enums/ChatAction.enum";
|
|
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
|
-
|
|
9
|
+
messages: ChatMessageType[];
|
|
10
|
+
chatActions?: ChatAction[];
|
|
11
|
+
size?: ComponentSize;
|
|
12
|
+
withoutAvatars?: boolean;
|
|
10
13
|
};
|
|
11
14
|
type __VLS_Slots = {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
main: () => any;
|
|
16
|
+
footer: () => any;
|
|
14
17
|
} & SharedActionSlots;
|
|
15
|
-
declare const __VLS_base: import("vue").DefineComponent<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
declare const __VLS_base: import("vue").DefineComponent<
|
|
19
|
+
__VLS_Props,
|
|
20
|
+
{},
|
|
21
|
+
{},
|
|
22
|
+
{},
|
|
23
|
+
{},
|
|
24
|
+
import("vue").ComponentOptionsMixin,
|
|
25
|
+
import("vue").ComponentOptionsMixin,
|
|
26
|
+
{} & {
|
|
27
|
+
"action:sendMessage": (text: string, options: ResultCallbacks) => any;
|
|
28
|
+
"action:attachFiles": (files: File[], options: ResultCallbacks) => any;
|
|
29
|
+
},
|
|
30
|
+
string,
|
|
31
|
+
import("vue").PublicProps,
|
|
32
|
+
Readonly<__VLS_Props> &
|
|
33
|
+
Readonly<{
|
|
34
|
+
"onAction:sendMessage"?: (text: string, options: ResultCallbacks) => any;
|
|
35
|
+
"onAction:attachFiles"?: (files: File[], options: ResultCallbacks) => any;
|
|
36
|
+
}>,
|
|
37
|
+
{
|
|
38
|
+
size: ComponentSize;
|
|
39
|
+
withoutAvatars: boolean;
|
|
40
|
+
chatActions: ChatAction[];
|
|
41
|
+
},
|
|
42
|
+
{},
|
|
43
|
+
{},
|
|
44
|
+
{},
|
|
45
|
+
string,
|
|
46
|
+
import("vue").ComponentProvideOptions,
|
|
47
|
+
false,
|
|
48
|
+
{},
|
|
49
|
+
any
|
|
50
|
+
>;
|
|
26
51
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
27
52
|
declare const _default: typeof __VLS_export;
|
|
28
53
|
export default _default;
|
|
29
54
|
type __VLS_WithSlots<T, S> = T & {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
new (): {
|
|
56
|
+
$slots: S;
|
|
57
|
+
};
|
|
33
58
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ChatMessageType } from "../../../types/ui";
|
|
1
2
|
export type UiChatsEmitterEvents = {
|
|
2
3
|
insertAtCursor: {
|
|
3
4
|
text: string;
|
|
4
5
|
};
|
|
5
6
|
focusOnTextField: undefined;
|
|
7
|
+
clickChatMessageImage: ChatMessageType;
|
|
6
8
|
};
|
|
7
9
|
export declare const createUiChatsEmitter: () => import("mitt").Emitter<UiChatsEmitterEvents>;
|