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