@bcc-code/vue-bcc-chat-ui 1.4.0 → 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 -11
- package/dist/chat/mobileView.d.ts +9 -0
- package/dist/chat/token.d.ts +3 -1
- package/dist/chat/uiKit.d.ts +0 -1
- package/dist/vue-bcc-chat-ui.js +70352 -69835
- package/package.json +4 -5
- package/src/components/BccChatMessageList.vue +95 -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,83 +1,91 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onBeforeMount, onUnmounted, ref } from "vue";
|
|
3
|
-
import chat from
|
|
4
|
-
import {
|
|
5
|
-
import { loggedIn } from "../chat/login";
|
|
6
|
-
|
|
7
|
-
import {
|
|
2
|
+
import { onBeforeMount, onMounted, onUnmounted, ref, nextTick, watch, Ref } from "vue";
|
|
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 "
|
|
18
|
-
import { CometChatTheme } from "@cometchat/uikit-resources";
|
|
19
|
-
import { BaseMessage, Group, User } from "@cometchat/chat-sdk-javascript";
|
|
20
|
-
import { watch, Ref } from "vue";
|
|
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';
|
|
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:
|
|
19
|
+
chatUid: {type: String, required: true},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const componentId = ref(`component-${Math.random().toString(36).substring(2, 11)}`);
|
|
23
|
+
const chatGroup = ref<Group>();
|
|
24
|
+
|
|
25
|
+
watch(chatGroup, (exists: any) => {
|
|
26
|
+
if (!exists) return;
|
|
27
|
+
nextTick(() => {
|
|
28
|
+
watchAndApplyStyle(
|
|
29
|
+
".bcc-chat-message-list",
|
|
30
|
+
".cc__imageviewer__close-button",
|
|
31
|
+
{ "padding-top": "env(safe-area-inset-top)" },
|
|
32
|
+
'cometchat-full-screen-viewer'
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
|
|
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
|
+
}
|
|
26
44
|
});
|
|
27
45
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
|
|
46
|
+
watch(chat.connection.connected, async () => {
|
|
47
|
+
if (chat.connection.connected.value) {
|
|
48
|
+
await loadData();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
32
51
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
watch(() => props.chatUid, async () => {
|
|
53
|
+
if (chat.connection.connected.value) {
|
|
54
|
+
await loadData();
|
|
55
|
+
}
|
|
36
56
|
});
|
|
37
57
|
|
|
38
58
|
onUnmounted(async () => {
|
|
39
|
-
await disconnect(
|
|
59
|
+
await disconnect();
|
|
40
60
|
});
|
|
41
61
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
()
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
};
|
|
48
71
|
|
|
49
72
|
// Loads data if chat is connected
|
|
50
|
-
const loadData = async () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
chat.initialized.value &&
|
|
54
|
-
chat.connection.connected.value
|
|
55
|
-
) {
|
|
56
|
-
initTemplates();
|
|
57
|
-
if (props.chatUid) {
|
|
58
|
-
// Retreive group
|
|
73
|
+
const loadData = async () => {
|
|
74
|
+
if (chat.connection.connected.value && props.chatUid) {
|
|
75
|
+
initTemplates();
|
|
59
76
|
chatGroup.value = await chat.data.getGroup(props.chatUid);
|
|
60
|
-
|
|
61
|
-
// Clear group chat count - assume user is viewing chat
|
|
62
|
-
if (chatGroup.value) {
|
|
63
|
-
await chat.data.clearGroupChatCount(props.chatUid);
|
|
64
|
-
}
|
|
77
|
+
await chat.data.clearGroupChatCount(props.chatUid);
|
|
65
78
|
} else {
|
|
66
|
-
chatGroup.value =
|
|
79
|
+
chatGroup.value = undefined;
|
|
67
80
|
}
|
|
68
|
-
} else {
|
|
69
|
-
if (!loggedIn.value) {
|
|
70
|
-
chatGroup.value = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
81
|
};
|
|
74
82
|
|
|
75
83
|
const messageComposerConfiguration = new MessageComposerConfiguration({
|
|
76
84
|
hideLiveReaction: true,
|
|
77
|
-
hideVoiceRecording: true
|
|
85
|
+
hideVoiceRecording: true
|
|
78
86
|
});
|
|
79
|
-
const messageListConfiguration:
|
|
80
|
-
|
|
87
|
+
const messageListConfiguration:Ref<any> = ref(null);
|
|
88
|
+
|
|
81
89
|
// Templates cannot be initialized before CometChat is initiazlied
|
|
82
90
|
// CometChatUIKit.getDataSource().getAllMessageTemplates() will return null before cometchat is initialized
|
|
83
91
|
// So we postpone overriding the templates until cometchat is connected
|
|
@@ -92,25 +100,16 @@ const initTemplates = () => {
|
|
|
92
100
|
|
|
93
101
|
// Override message list configuration
|
|
94
102
|
function getMessageListConfiguration(): MessageListConfiguration {
|
|
95
|
-
let templates = CometChatUIKit.getDataSource()
|
|
96
|
-
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
});
|
|
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
|
+
});
|
|
114
113
|
|
|
115
114
|
function getImageMessageContentView(
|
|
116
115
|
message: CometChat.BaseMessage,
|
|
@@ -133,49 +132,40 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
133
132
|
}),
|
|
134
133
|
},
|
|
135
134
|
};
|
|
136
|
-
}
|
|
135
|
+
};
|
|
137
136
|
|
|
138
|
-
const getOptionsView = (
|
|
139
|
-
loggedInUser
|
|
140
|
-
|
|
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
|
-
);
|
|
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");
|
|
153
140
|
return customOptionsView;
|
|
154
|
-
}
|
|
141
|
+
}
|
|
142
|
+
|
|
155
143
|
|
|
156
144
|
return new MessageListConfiguration({
|
|
157
145
|
scrollToBottomOnNewMessages: true,
|
|
158
|
-
templates: templates
|
|
146
|
+
templates: templates
|
|
159
147
|
});
|
|
160
148
|
}
|
|
149
|
+
|
|
150
|
+
|
|
161
151
|
</script>
|
|
162
152
|
|
|
163
153
|
<template>
|
|
164
154
|
<div v-if="chatGroup" class="bcc-chat-message-list">
|
|
165
|
-
<CometChatMessages
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/>
|
|
155
|
+
<CometChatMessages
|
|
156
|
+
:hideMessageHeader="true"
|
|
157
|
+
:disableSoundForMessages="true"
|
|
158
|
+
:messageComposerConfiguration="messageComposerConfiguration"
|
|
159
|
+
:messageListConfiguration="messageListConfiguration"
|
|
160
|
+
:hideMessageComposer="false"
|
|
161
|
+
:hideDetails="true"
|
|
162
|
+
:group="chatGroup"
|
|
163
|
+
/>
|
|
175
164
|
</div>
|
|
176
165
|
</template>
|
|
177
166
|
|
|
178
|
-
<style lang="scss">
|
|
167
|
+
<style lang="scss" >
|
|
168
|
+
|
|
179
169
|
.bcc-chat-message-list {
|
|
180
170
|
height: 100%;
|
|
181
171
|
/* 1. Wrapper for Messages component */
|
|
@@ -190,14 +180,13 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
190
180
|
}
|
|
191
181
|
}
|
|
192
182
|
|
|
193
|
-
.cc-messagecomposer__emojikeyboard {
|
|
194
|
-
|
|
183
|
+
.cc-messagecomposer__emojikeyboard {
|
|
184
|
+
display: none;
|
|
195
185
|
}
|
|
196
186
|
|
|
197
187
|
// Hide emoji keyboard
|
|
198
|
-
.cc-messagecomposer__emojikeyboard {
|
|
199
|
-
|
|
200
|
-
}
|
|
188
|
+
.cc-messagecomposer__emojikeyboard { display: none; }
|
|
189
|
+
|
|
201
190
|
|
|
202
191
|
.cc-threadedmessages-wrapper__bubbleview::-webkit-scrollbar,
|
|
203
192
|
.cc__message-list::-webkit-scrollbar {
|
|
@@ -210,4 +199,5 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
210
199
|
background: rgb(232, 229, 229);
|
|
211
200
|
border-radius: 8px;
|
|
212
201
|
}
|
|
213
|
-
|
|
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;
|