@bcc-code/vue-bcc-chat-ui 1.3.0 → 1.3.2
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/dist/chat/connection.d.ts +7 -8
- package/dist/chat/data.d.ts +2 -2
- package/dist/chat/index.d.ts +11 -5
- package/dist/chat/login.d.ts +9 -0
- package/dist/chat/token.d.ts +1 -3
- package/dist/chat/uiKit.d.ts +1 -0
- package/dist/vue-bcc-chat-ui.js +21479 -21949
- package/package.json +5 -4
- package/src/components/BccChatMessageList.vue +105 -84
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@bcc-code/vue-bcc-chat-ui",
|
|
3
3
|
"author": "bcc-code",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "1.3.
|
|
5
|
+
"version": "1.3.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
"vue": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/
|
|
25
|
+
"@types/lodash-es": "^4.17.12",
|
|
26
|
+
"@types/node": "^20.11.25",
|
|
26
27
|
"@vitejs/plugin-vue": "^4.6.2",
|
|
27
28
|
"path": "^0.12.7",
|
|
28
29
|
"sass": "^1.71.1",
|
|
29
|
-
"typescript": "^5.
|
|
30
|
-
"vite": "^5.1.
|
|
30
|
+
"typescript": "^5.4.2",
|
|
31
|
+
"vite": "^5.1.5",
|
|
31
32
|
"vite-plugin-dts": "^3.7.3",
|
|
32
33
|
"vue": "^3.4.21"
|
|
33
34
|
},
|
|
@@ -1,79 +1,83 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onBeforeMount, onUnmounted, ref } from
|
|
3
|
-
import chat from
|
|
4
|
-
import {
|
|
2
|
+
import { onBeforeMount, onUnmounted, ref } from "vue";
|
|
3
|
+
import chat from "../chat";
|
|
4
|
+
import { connect, disconnect } from "../chat/connection";
|
|
5
|
+
import { loggedIn } from "../chat/login";
|
|
6
|
+
|
|
7
|
+
import {
|
|
5
8
|
CometChatMessages,
|
|
6
9
|
CometChatMessageTemplate,
|
|
7
10
|
CometChatUIKit,
|
|
8
11
|
ImageBubbleStyle,
|
|
9
12
|
MessageBubbleAlignment,
|
|
10
13
|
} from "@cometchat/chat-uikit-vue";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
import {
|
|
15
|
+
MessageListConfiguration,
|
|
16
|
+
MessageComposerConfiguration,
|
|
17
|
+
} from "@cometchat/uikit-shared";
|
|
18
|
+
import { CometChatTheme } from "@cometchat/uikit-resources";
|
|
19
|
+
import { BaseMessage, Group, User } from "@cometchat/chat-sdk-javascript";
|
|
20
|
+
import { watch, Ref } from "vue";
|
|
15
21
|
|
|
16
22
|
//import { ThreadedMessagesStyle } from '@cometchat/uikit-shared';
|
|
17
23
|
|
|
18
24
|
const props = defineProps({
|
|
19
|
-
chatUid:
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const componentId = ref(`component-${Math.random().toString(36).substring(2, 11)}`);
|
|
23
|
-
const chatGroup = ref<Group>();
|
|
24
|
-
|
|
25
|
-
onBeforeMount(async() => {
|
|
26
|
-
try {
|
|
27
|
-
await connect();
|
|
28
|
-
await loadData();
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error('Failed to connect when mounting chat component', error);
|
|
31
|
-
}
|
|
25
|
+
chatUid: { type: String, required: true },
|
|
32
26
|
});
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
28
|
+
const componentId = ref(
|
|
29
|
+
`component-${Math.random().toString(36).substring(2, 11)}`
|
|
30
|
+
);
|
|
31
|
+
const chatGroup = ref<Group | null>(null);
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
33
|
+
onBeforeMount(async () => {
|
|
34
|
+
await connect(componentId.value);
|
|
35
|
+
await loadData();
|
|
44
36
|
});
|
|
45
37
|
|
|
46
38
|
onUnmounted(async () => {
|
|
47
|
-
await disconnect();
|
|
39
|
+
await disconnect(componentId.value);
|
|
48
40
|
});
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const connect = async() => {
|
|
57
|
-
await chat.connection.connect(componentId.value);
|
|
58
|
-
};
|
|
42
|
+
watch(
|
|
43
|
+
[loggedIn, chat.connection.connected, chat.initialized, () => props.chatUid],
|
|
44
|
+
() => {
|
|
45
|
+
loadData();
|
|
46
|
+
}
|
|
47
|
+
);
|
|
59
48
|
|
|
60
49
|
// Loads data if chat is connected
|
|
61
|
-
const loadData = async () => {
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
const loadData = async () => {
|
|
51
|
+
if (
|
|
52
|
+
loggedIn.value &&
|
|
53
|
+
chat.initialized.value &&
|
|
54
|
+
chat.connection.connected.value
|
|
55
|
+
) {
|
|
56
|
+
initTemplates();
|
|
57
|
+
if (props.chatUid) {
|
|
58
|
+
// Retreive group
|
|
64
59
|
chatGroup.value = await chat.data.getGroup(props.chatUid);
|
|
65
|
-
|
|
60
|
+
|
|
61
|
+
// Clear group chat count - assume user is viewing chat
|
|
62
|
+
if (chatGroup.value) {
|
|
63
|
+
await chat.data.clearGroupChatCount(props.chatUid);
|
|
64
|
+
}
|
|
66
65
|
} else {
|
|
67
|
-
chatGroup.value =
|
|
66
|
+
chatGroup.value = null;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if (!loggedIn.value) {
|
|
70
|
+
chatGroup.value = null;
|
|
68
71
|
}
|
|
72
|
+
}
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
const messageComposerConfiguration = new MessageComposerConfiguration({
|
|
72
76
|
hideLiveReaction: true,
|
|
73
|
-
hideVoiceRecording: true
|
|
77
|
+
hideVoiceRecording: true,
|
|
74
78
|
});
|
|
75
|
-
const messageListConfiguration:Ref<any> = ref(null);
|
|
76
|
-
|
|
79
|
+
const messageListConfiguration: Ref<any> = ref(null);
|
|
80
|
+
|
|
77
81
|
// Templates cannot be initialized before CometChat is initiazlied
|
|
78
82
|
// CometChatUIKit.getDataSource().getAllMessageTemplates() will return null before cometchat is initialized
|
|
79
83
|
// So we postpone overriding the templates until cometchat is connected
|
|
@@ -88,16 +92,25 @@ const initTemplates = () => {
|
|
|
88
92
|
|
|
89
93
|
// Override message list configuration
|
|
90
94
|
function getMessageListConfiguration(): MessageListConfiguration {
|
|
91
|
-
let templates = CometChatUIKit.getDataSource()
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
let templates = CometChatUIKit.getDataSource()
|
|
96
|
+
.getAllMessageTemplates()
|
|
97
|
+
.map((template: CometChatMessageTemplate) => {
|
|
98
|
+
// Override options
|
|
99
|
+
template.options = (
|
|
100
|
+
loggedInUser: User,
|
|
101
|
+
message: BaseMessage,
|
|
102
|
+
theme: CometChatTheme,
|
|
103
|
+
group: Group | undefined
|
|
104
|
+
) => {
|
|
105
|
+
return getOptionsView(loggedInUser, message, theme, group);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Override image styling
|
|
109
|
+
if (template.category === "message" && template.type === "image") {
|
|
110
|
+
template.contentView = getImageMessageContentView;
|
|
111
|
+
}
|
|
112
|
+
return template;
|
|
113
|
+
});
|
|
101
114
|
|
|
102
115
|
function getImageMessageContentView(
|
|
103
116
|
message: CometChat.BaseMessage,
|
|
@@ -120,41 +133,49 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
120
133
|
}),
|
|
121
134
|
},
|
|
122
135
|
};
|
|
123
|
-
}
|
|
136
|
+
}
|
|
124
137
|
|
|
125
|
-
const getOptionsView = (
|
|
126
|
-
|
|
127
|
-
|
|
138
|
+
const getOptionsView = (
|
|
139
|
+
loggedInUser: User,
|
|
140
|
+
message: BaseMessage,
|
|
141
|
+
theme: any,
|
|
142
|
+
group: Group | undefined
|
|
143
|
+
) => {
|
|
144
|
+
const optionsData = CometChatUIKit.getDataSource().getMessageOptions(
|
|
145
|
+
loggedInUser,
|
|
146
|
+
message,
|
|
147
|
+
theme,
|
|
148
|
+
group
|
|
149
|
+
);
|
|
150
|
+
const customOptionsView = optionsData.filter(
|
|
151
|
+
(ele) => ele.id !== "sendMessagePrivately"
|
|
152
|
+
);
|
|
128
153
|
return customOptionsView;
|
|
129
|
-
}
|
|
130
|
-
|
|
154
|
+
};
|
|
131
155
|
|
|
132
156
|
return new MessageListConfiguration({
|
|
133
157
|
scrollToBottomOnNewMessages: true,
|
|
134
|
-
templates: templates
|
|
158
|
+
templates: templates,
|
|
135
159
|
});
|
|
136
160
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
161
|
</script>
|
|
140
162
|
|
|
141
163
|
<template>
|
|
142
164
|
<div v-if="chatGroup" class="bcc-chat-message-list">
|
|
143
|
-
<CometChatMessages
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
165
|
+
<CometChatMessages
|
|
166
|
+
v-if="chatGroup"
|
|
167
|
+
:hideMessageHeader="true"
|
|
168
|
+
:disableSoundForMessages="true"
|
|
169
|
+
:messageComposerConfiguration="messageComposerConfiguration"
|
|
170
|
+
:messageListConfiguration="messageListConfiguration"
|
|
171
|
+
:hideMessageComposer="false"
|
|
172
|
+
:hideDetails="true"
|
|
173
|
+
:group="chatGroup"
|
|
174
|
+
/>
|
|
153
175
|
</div>
|
|
154
176
|
</template>
|
|
155
177
|
|
|
156
|
-
<style lang="scss"
|
|
157
|
-
|
|
178
|
+
<style lang="scss">
|
|
158
179
|
.bcc-chat-message-list {
|
|
159
180
|
height: 100%;
|
|
160
181
|
/* 1. Wrapper for Messages component */
|
|
@@ -169,13 +190,14 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
169
190
|
}
|
|
170
191
|
}
|
|
171
192
|
|
|
172
|
-
.cc-messagecomposer__emojikeyboard {
|
|
173
|
-
|
|
193
|
+
.cc-messagecomposer__emojikeyboard {
|
|
194
|
+
display: none;
|
|
174
195
|
}
|
|
175
196
|
|
|
176
197
|
// Hide emoji keyboard
|
|
177
|
-
.cc-messagecomposer__emojikeyboard {
|
|
178
|
-
|
|
198
|
+
.cc-messagecomposer__emojikeyboard {
|
|
199
|
+
display: none;
|
|
200
|
+
}
|
|
179
201
|
|
|
180
202
|
.cc-threadedmessages-wrapper__bubbleview::-webkit-scrollbar,
|
|
181
203
|
.cc__message-list::-webkit-scrollbar {
|
|
@@ -188,5 +210,4 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
188
210
|
background: rgb(232, 229, 229);
|
|
189
211
|
border-radius: 8px;
|
|
190
212
|
}
|
|
191
|
-
|
|
192
|
-
</style>
|
|
213
|
+
</style>
|