@bcc-code/vue-bcc-chat-ui 1.1.0 → 1.1.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 +11 -4
- package/dist/chat/data.d.ts +2 -2
- package/dist/chat/index.d.ts +15 -3
- package/dist/components/BccChatMessageList.vue.d.ts +0 -8
- package/dist/style.css +1 -1
- package/dist/vue-bcc-chat-ui.js +11794 -11664
- package/package.json +10 -10
- package/src/components/BccChatMessageList.vue +90 -18
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.1.
|
|
5
|
+
"version": "1.1.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"vue": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^20.11.
|
|
26
|
-
"@vitejs/plugin-vue": "^4.
|
|
25
|
+
"@types/node": "^20.11.22",
|
|
26
|
+
"@vitejs/plugin-vue": "^4.6.2",
|
|
27
27
|
"path": "^0.12.7",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"vite
|
|
31
|
-
"
|
|
32
|
-
"
|
|
28
|
+
"sass": "^1.71.1",
|
|
29
|
+
"typescript": "^5.3.3",
|
|
30
|
+
"vite": "^5.1.4",
|
|
31
|
+
"vite-plugin-dts": "^3.7.3",
|
|
32
|
+
"vue": "^3.4.21"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@cometchat/chat-sdk-javascript": "^4.0.3",
|
|
36
|
-
"@cometchat/chat-uikit-vue": "^4.2.
|
|
36
|
+
"@cometchat/chat-uikit-vue": "^4.2.1",
|
|
37
37
|
"@cometchat/uikit-resources": "^4.2.2",
|
|
38
|
-
"@cometchat/uikit-shared": "^4.2.
|
|
38
|
+
"@cometchat/uikit-shared": "^4.2.2"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"dev": "vite",
|
|
@@ -1,39 +1,111 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onUnmounted, ref
|
|
2
|
+
import { onBeforeMount, onUnmounted, ref } from 'vue'
|
|
3
3
|
import chat from '../chat';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CometChatMessages,
|
|
6
|
+
CometChatMessageTemplate,
|
|
7
|
+
CometChatUIKit,
|
|
8
|
+
ImageBubbleStyle,
|
|
9
|
+
MessageBubbleAlignment,
|
|
10
|
+
} from "@cometchat/chat-uikit-vue";
|
|
11
|
+
import { MessageListConfiguration } from "@cometchat/uikit-shared";
|
|
5
12
|
import { Group } from '@cometchat/chat-sdk-javascript';
|
|
13
|
+
import { watch, Ref } from 'vue';
|
|
6
14
|
//import { ThreadedMessagesStyle } from '@cometchat/uikit-shared';
|
|
7
15
|
|
|
8
16
|
const props = defineProps({
|
|
9
|
-
accessToken: {type: String, required: true},
|
|
10
17
|
chatUid: {type: String, required: true},
|
|
11
18
|
})
|
|
12
19
|
|
|
13
|
-
const
|
|
20
|
+
const componentId = ref(`component-${Math.random().toString(36).substring(2, 11)}`);
|
|
14
21
|
const chatGroup = ref<Group>();
|
|
15
|
-
const user = ref();
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
onBeforeMount(async() => {
|
|
24
|
+
await connnect();
|
|
25
|
+
await loadData();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
watch(chat.connection.connected, async () => {
|
|
29
|
+
if (chat.connection.connected.value) {
|
|
30
|
+
await loadData();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
24
33
|
|
|
25
34
|
onUnmounted(async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
await disconnect();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Disconnects from chat server
|
|
39
|
+
const disconnect = async () => {
|
|
40
|
+
await chat.connection.disconnect(componentId.value);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Connect to chat server
|
|
44
|
+
const connnect = async() => {
|
|
45
|
+
await chat.connection.connect(componentId.value);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Loads data if chat is connected
|
|
49
|
+
const loadData = async () => {
|
|
50
|
+
if (chat.connection.connected.value && props.chatUid) {
|
|
51
|
+
initTemplates();
|
|
52
|
+
chatGroup.value = await chat.data.getGroup(props.chatUid);
|
|
53
|
+
} else {
|
|
54
|
+
chatGroup.value = undefined;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const messageListConfiguration:Ref<any> = ref(null);
|
|
59
|
+
let templatesInitialized = false;
|
|
60
|
+
const initTemplates = () => {
|
|
61
|
+
if (templatesInitialized) {
|
|
62
|
+
return;
|
|
29
63
|
}
|
|
30
|
-
|
|
64
|
+
templatesInitialized = true;
|
|
65
|
+
let definedTemplates = CometChatUIKit.getDataSource().getAllMessageTemplates();
|
|
66
|
+
definedTemplates.map((template: CometChatMessageTemplate) => {
|
|
67
|
+
if (template.category === "message" && template.type === "image") {
|
|
68
|
+
template.contentView = (
|
|
69
|
+
message: CometChat.BaseMessage,
|
|
70
|
+
_alignment: MessageBubbleAlignment
|
|
71
|
+
) => getImageMessageContentView(message, _alignment);
|
|
72
|
+
}
|
|
73
|
+
return template;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const getImageMessageContentView = (
|
|
77
|
+
message: CometChat.BaseMessage,
|
|
78
|
+
_alignment: MessageBubbleAlignment
|
|
79
|
+
) => {
|
|
80
|
+
console.log("my image", message.getData());
|
|
81
|
+
return {
|
|
82
|
+
componentName: "CometChatImageBubble",
|
|
83
|
+
props: {
|
|
84
|
+
src: message.getData().url,
|
|
85
|
+
imageStyle: new ImageBubbleStyle({
|
|
86
|
+
// you can adjust image styles here
|
|
87
|
+
width: "100%",
|
|
88
|
+
height: "100%",
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
messageListConfiguration.value = new MessageListConfiguration({
|
|
95
|
+
templates: definedTemplates,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
31
103
|
|
|
32
104
|
</script>
|
|
33
105
|
|
|
34
106
|
<template>
|
|
35
|
-
<div v-if="
|
|
36
|
-
<CometChatMessages :hideMessageHeader="true" :hideMessageComposer="false" :hideDetails="true" :group="chatGroup"></CometChatMessages>
|
|
107
|
+
<div v-if="chatGroup" class="bcc-chat-message-list">
|
|
108
|
+
<CometChatMessages v-if="chatGroup" :hideMessageHeader="true" :messageListConfiguration="messageListConfiguration" :hideMessageComposer="false" :hideDetails="true" :group="chatGroup"></CometChatMessages>
|
|
37
109
|
</div>
|
|
38
110
|
</template>
|
|
39
111
|
|