@bcc-code/vue-bcc-chat-ui 1.6.2 → 2.0.0
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/README.md +4 -3
- package/dist/chat/data.d.ts +5 -26
- package/dist/chat/environment.d.ts +3 -15
- package/dist/chat/index.d.ts +19 -51
- package/dist/chat/{mobileView.d.ts → styleFix.d.ts} +0 -9
- package/dist/chat/theme.d.ts +181 -14
- package/dist/chat/types.d.ts +27 -0
- package/dist/chat/uiKit.d.ts +4 -8
- package/dist/index.d.ts +3 -2
- package/dist/style.css +1 -1
- package/dist/vue-bcc-chat-ui.js +13914 -14044
- package/package.json +2 -4
- package/src/components/BccChatMessageList.vue +84 -166
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": "
|
|
5
|
+
"version": "2.0.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"vue": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/lodash-es": "^4.17.12",
|
|
26
25
|
"@types/node": "^20.11.25",
|
|
27
26
|
"@vitejs/plugin-vue": "^4.6.2",
|
|
28
27
|
"path": "^0.12.7",
|
|
@@ -37,8 +36,7 @@
|
|
|
37
36
|
"@cometchat/chat-uikit-vue": "^4.2.1",
|
|
38
37
|
"@cometchat/uikit-resources": "^4.2.2",
|
|
39
38
|
"@cometchat/uikit-shared": "^4.2.2",
|
|
40
|
-
"jwt-decode": "^4.0.0"
|
|
41
|
-
"lodash-es": "^4.17.21"
|
|
39
|
+
"jwt-decode": "^4.0.0"
|
|
42
40
|
},
|
|
43
41
|
"scripts": {
|
|
44
42
|
"dev": "vite",
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onBeforeMount, onMounted, onUnmounted, ref,
|
|
2
|
+
import { onBeforeMount, onMounted, onUnmounted, ref, watchEffect } from "vue";
|
|
3
3
|
import chat from "../chat";
|
|
4
4
|
import { connect, disconnect } from "../chat/connection";
|
|
5
5
|
import { loggedIn } from "../chat/login";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
CometChatUIKit,
|
|
11
|
-
ImageBubbleStyle,
|
|
12
|
-
MessageBubbleAlignment,
|
|
13
|
-
} from "@cometchat/chat-uikit-vue";
|
|
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 { watchAndApplyStyle } from "../chat/mobileView";
|
|
6
|
+
import { CometChatMessages } from "@cometchat/chat-uikit-vue";
|
|
7
|
+
import { Group } from "@cometchat/chat-sdk-javascript";
|
|
8
|
+
import { watchAndApplyStyle } from "../chat/styleFix";
|
|
9
|
+
import { messageComposerConfiguration, messageListConfiguration } from "../chat/uiKit";
|
|
21
10
|
|
|
22
11
|
const props = defineProps({
|
|
23
12
|
chatUid: { type: String, required: true },
|
|
@@ -26,172 +15,60 @@ const props = defineProps({
|
|
|
26
15
|
const componentId = ref(
|
|
27
16
|
`component-${Math.random().toString(36).substring(2, 11)}`
|
|
28
17
|
);
|
|
29
|
-
const chatGroup = ref<Group
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
shadowDomSelector: 'link-preview'
|
|
49
|
-
}]
|
|
50
|
-
);
|
|
51
|
-
});
|
|
18
|
+
const chatGroup = ref<Group>();
|
|
19
|
+
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
watchAndApplyStyle(
|
|
22
|
+
".bcc-chat-message-list-wrapper",
|
|
23
|
+
[{
|
|
24
|
+
selector: '.cc__imageviewer__close-button',
|
|
25
|
+
style: { "padding-top": "env(safe-area-inset-top)" },
|
|
26
|
+
shadowDomSelector: 'cometchat-full-screen-viewer'
|
|
27
|
+
}, {
|
|
28
|
+
selector: '.cc__text',
|
|
29
|
+
style: { color: 'var(--cc__text-color)' },
|
|
30
|
+
shadowDomSelector: 'cometchat-text-bubble'
|
|
31
|
+
}, {
|
|
32
|
+
selector: '.cc__linkpreview-title',
|
|
33
|
+
style: { color: 'var(--cc__text-color)' },
|
|
34
|
+
shadowDomSelector: 'link-preview'
|
|
35
|
+
}]
|
|
36
|
+
);
|
|
52
37
|
})
|
|
53
38
|
|
|
54
39
|
onBeforeMount(async () => {
|
|
55
40
|
await connect(componentId.value);
|
|
56
|
-
await loadData();
|
|
57
41
|
});
|
|
58
42
|
|
|
59
43
|
onUnmounted(async () => {
|
|
60
44
|
await disconnect(componentId.value);
|
|
61
45
|
});
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
// Loads data if chat is connected
|
|
71
|
-
const loadData = async () => {
|
|
72
|
-
if (
|
|
73
|
-
loggedIn.value &&
|
|
74
|
-
chat.initialized.value &&
|
|
75
|
-
chat.connection.connected.value
|
|
76
|
-
) {
|
|
77
|
-
initTemplates();
|
|
78
|
-
if (props.chatUid) {
|
|
79
|
-
// Retreive group
|
|
80
|
-
chatGroup.value = await chat.data.getGroup(props.chatUid);
|
|
81
|
-
|
|
82
|
-
// Clear group chat count - assume user is viewing chat
|
|
83
|
-
if (chatGroup.value) {
|
|
84
|
-
await chat.data.clearGroupChatCount(props.chatUid);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
chatGroup.value = null;
|
|
88
|
-
}
|
|
47
|
+
watchEffect(async () => {
|
|
48
|
+
if (loggedIn.value && props.chatUid && chat.initialized.value) {
|
|
49
|
+
chatGroup.value = await chat.getGroup(props.chatUid) ?? undefined;
|
|
50
|
+
await chat.clearGroupChatCount(props.chatUid);
|
|
89
51
|
} else {
|
|
90
|
-
|
|
91
|
-
chatGroup.value = null;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const messageComposerConfiguration = new MessageComposerConfiguration({
|
|
97
|
-
hideLiveReaction: true,
|
|
98
|
-
hideVoiceRecording: true,
|
|
99
|
-
});
|
|
100
|
-
const messageListConfiguration: Ref<any> = ref(null);
|
|
101
|
-
|
|
102
|
-
// Templates cannot be initialized before CometChat is initiazlied
|
|
103
|
-
// CometChatUIKit.getDataSource().getAllMessageTemplates() will return null before cometchat is initialized
|
|
104
|
-
// So we postpone overriding the templates until cometchat is connected
|
|
105
|
-
let templatesInitialized = false;
|
|
106
|
-
const initTemplates = () => {
|
|
107
|
-
if (templatesInitialized) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
templatesInitialized = true;
|
|
111
|
-
messageListConfiguration.value = getMessageListConfiguration();
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// Override message list configuration
|
|
115
|
-
function getMessageListConfiguration(): MessageListConfiguration {
|
|
116
|
-
let templates = CometChatUIKit.getDataSource()
|
|
117
|
-
.getAllMessageTemplates()
|
|
118
|
-
.map((template: CometChatMessageTemplate) => {
|
|
119
|
-
// Override options
|
|
120
|
-
template.options = (
|
|
121
|
-
loggedInUser: User,
|
|
122
|
-
message: BaseMessage,
|
|
123
|
-
theme: CometChatTheme,
|
|
124
|
-
group: Group | undefined
|
|
125
|
-
) => {
|
|
126
|
-
return getOptionsView(loggedInUser, message, theme, group);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// Override image styling
|
|
130
|
-
if (template.category === "message" && template.type === "image") {
|
|
131
|
-
template.contentView = getImageMessageContentView;
|
|
132
|
-
}
|
|
133
|
-
return template;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
function getImageMessageContentView(
|
|
137
|
-
message: CometChat.BaseMessage,
|
|
138
|
-
_alignment: MessageBubbleAlignment
|
|
139
|
-
) {
|
|
140
|
-
if (message.getDeletedAt()) {
|
|
141
|
-
return CometChatUIKit.getDataSource().getDeleteMessageBubble(
|
|
142
|
-
message,
|
|
143
|
-
new CometChatTheme({})
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
componentName: "CometChatImageBubble",
|
|
148
|
-
props: {
|
|
149
|
-
src: message.getData().url,
|
|
150
|
-
imageStyle: new ImageBubbleStyle({
|
|
151
|
-
// you can adjust image styles here
|
|
152
|
-
width: "100%",
|
|
153
|
-
height: "100%",
|
|
154
|
-
}),
|
|
155
|
-
},
|
|
156
|
-
};
|
|
52
|
+
chatGroup.value = undefined;
|
|
157
53
|
}
|
|
54
|
+
})
|
|
158
55
|
|
|
159
|
-
const getOptionsView = (
|
|
160
|
-
loggedInUser: User,
|
|
161
|
-
message: BaseMessage,
|
|
162
|
-
theme: any,
|
|
163
|
-
group: Group | undefined
|
|
164
|
-
) => {
|
|
165
|
-
const optionsData = CometChatUIKit.getDataSource().getMessageOptions(
|
|
166
|
-
loggedInUser,
|
|
167
|
-
message,
|
|
168
|
-
theme,
|
|
169
|
-
group
|
|
170
|
-
);
|
|
171
|
-
const customOptionsView = optionsData.filter(
|
|
172
|
-
(ele) => ele.id !== "sendMessagePrivately"
|
|
173
|
-
);
|
|
174
|
-
return customOptionsView;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
return new MessageListConfiguration({
|
|
178
|
-
scrollToBottomOnNewMessages: true,
|
|
179
|
-
templates: templates,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
56
|
</script>
|
|
183
57
|
|
|
184
58
|
<template>
|
|
185
|
-
<div
|
|
186
|
-
<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
59
|
+
<div class="bcc-chat-message-list-wrapper">
|
|
60
|
+
<div v-if="chatGroup" class="bcc-chat-message-list">
|
|
61
|
+
<CometChatMessages
|
|
62
|
+
:hideMessageHeader="true"
|
|
63
|
+
:disableSoundForMessages="true"
|
|
64
|
+
:messageComposerConfiguration="messageComposerConfiguration"
|
|
65
|
+
:messageListConfiguration="messageListConfiguration"
|
|
66
|
+
:hideMessageComposer="false"
|
|
67
|
+
:hideDetails="true"
|
|
68
|
+
:group="chatGroup"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="bcc-chat-message-list-offline"><span>Waiting for connection...</span></div>
|
|
195
72
|
</div>
|
|
196
73
|
</template>
|
|
197
74
|
|
|
@@ -206,6 +83,11 @@ body {
|
|
|
206
83
|
}
|
|
207
84
|
}
|
|
208
85
|
|
|
86
|
+
.bcc-chat-message-list-wrapper {
|
|
87
|
+
position: relative;
|
|
88
|
+
height: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
209
91
|
/*
|
|
210
92
|
primary: my bubble
|
|
211
93
|
accent: message bar text
|
|
@@ -270,6 +152,42 @@ accent900: text in avatar
|
|
|
270
152
|
border: 1px var(--cc__secondary) solid !important;
|
|
271
153
|
}
|
|
272
154
|
}
|
|
155
|
+
/* 2. Message for Messages Composer when offline */
|
|
156
|
+
.bcc-chat-message-composer-offline {
|
|
157
|
+
position: relative;
|
|
158
|
+
top: -96px;
|
|
159
|
+
height: 96px;
|
|
160
|
+
width: 100%;
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
padding: 16px 14px;
|
|
163
|
+
color: rgb(176, 176, 176);
|
|
164
|
+
font: 700 1rem sans-serif;
|
|
165
|
+
|
|
166
|
+
/* 2.1 Text of Messages Composer offline view */
|
|
167
|
+
span {
|
|
168
|
+
width: 100%;
|
|
169
|
+
height: 100%;
|
|
170
|
+
display: flex;
|
|
171
|
+
justify-content: center;
|
|
172
|
+
align-items: center;
|
|
173
|
+
background: rgba(255,255,255,0.75);
|
|
174
|
+
border-radius: 12px;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.bcc-chat-message-list-offline {
|
|
180
|
+
position: absolute;
|
|
181
|
+
top: 0;
|
|
182
|
+
bottom: 0;
|
|
183
|
+
left: 0;
|
|
184
|
+
right: 0;
|
|
185
|
+
display: flex;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
align-items: center;
|
|
188
|
+
font: 700 22px sans-serif;
|
|
189
|
+
color: #bcbcbc;
|
|
190
|
+
z-index: -1;
|
|
273
191
|
}
|
|
274
192
|
|
|
275
193
|
.cc-messagecomposer__emojikeyboard {
|