@bcc-code/vue-bcc-chat-ui 3.24.0 → 3.26.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/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": "3.24.0",
5
+ "version": "3.26.0",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import {
3
+ PropType,
3
4
  Ref,
4
5
  onBeforeMount,
5
6
  onBeforeUnmount,
@@ -8,6 +9,7 @@ import {
8
9
  provide,
9
10
  ref,
10
11
  watch,
12
+ watchEffect,
11
13
  } from "vue";
12
14
  import chat from "../chat";
13
15
  import { connect, disconnect } from "../chat/connection";
@@ -21,7 +23,10 @@ import BccScheduledMessages from "./BccScheduledMessages.vue";
21
23
  const props = defineProps({
22
24
  chatUid: { type: String, required: true },
23
25
  senderDisplayName: { type: String, required: false },
24
- });
26
+ groupMessageGetter: {
27
+ type: Function as PropType<(guid: string, query: string) => Promise<any>>,
28
+ required: false,
29
+ },});
25
30
 
26
31
  const componentId = ref(
27
32
  `component-${Math.random().toString(36).substring(2, 11)}`
@@ -32,8 +37,10 @@ const chatInstance: Ref<ChatInstance> = ref({
32
37
  componentId: componentId,
33
38
  replyToMessage: null,
34
39
  captionedAttachment: null,
40
+ decoyAttachment: null,
35
41
  showScheduledMessagesChat: false,
36
- showAlert: false
42
+ showAlert: false,
43
+ userInput: null
37
44
  });
38
45
 
39
46
  provide("chatInstance", chatInstance);
@@ -56,10 +63,14 @@ const onMessageSend = CometChatMessageEvents.ccMessageSent.subscribe(({ message,
56
63
  }
57
64
  });
58
65
 
59
- watch([loggedIn, () => props.chatUid, chat.initialized], async ([_loggedIn, _chatUid, _initialized]) => {
66
+ watch([loggedIn, () => props.chatUid, chat.initialized, () => props.groupMessageGetter], async ([_loggedIn, _chatUid, _initialized, _groupMessageGetter]) => {
60
67
  if (_loggedIn && _chatUid && _initialized) {
61
68
  chatGroup.value = (await chat.getGroup(props.chatUid)) ?? undefined;
62
69
 
70
+ if (_groupMessageGetter && !chatGroup.value?.getHasJoined()) {
71
+ chat.updateGetGroupMessages(_groupMessageGetter)
72
+ }
73
+
63
74
  if (chatGroup.value) {
64
75
  watchAndApplyStyle(".bcc-chat-message-list-wrapper", [
65
76
  {
@@ -158,56 +169,6 @@ body {
158
169
  }
159
170
  }
160
171
 
161
- .modal {
162
- background-color: hsl(230, 25%, 15%);
163
- color: white;
164
-
165
- .bcc-modal-content {
166
- display: flex;
167
- justify-content: space-between;
168
- width: 100%;
169
-
170
- .input {
171
- background-color: #758abc;
172
- border-radius: 5px;
173
- color: white;
174
- height: 40px;
175
- padding: 5px;
176
- width: 45%;
177
- }
178
-
179
- .at {
180
- width: 10%;
181
- text-align: center;
182
- margin-top: 7px;
183
- }
184
- }
185
-
186
- .bcc-modal-footer {
187
- background-color: hsl(230, 25%, 15%);
188
-
189
- .bcc-modal-actions {
190
- background-color: hsl(230, 25%, 15%);
191
- display: flex;
192
- width: 100%;
193
- justify-content: space-between;
194
-
195
- .bcc-modal-secondary-action,
196
- .bcc-modal-primary-action {
197
- width: 100%;
198
- background-color: hsl(230, 25%, 15%);
199
-
200
- button {
201
- background-color: #2fb5e9d1 !important;
202
- width: 100%;
203
- border-radius: 5px;
204
- margin-top: -10px;
205
- }
206
- }
207
- }
208
- }
209
- }
210
-
211
172
  .bcc-chat-message-list-wrapper {
212
173
  position: relative;
213
174
  height: 100%;
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import chat from "../chat";
3
3
  import { Group } from "@cometchat/chat-sdk-javascript";
4
- import { inject, onMounted, onUnmounted, Ref, ref, watch, watchEffect } from 'vue';
4
+ import { inject, nextTick, onMounted, onUnmounted, Ref, ref, watch, watchEffect } from 'vue';
5
5
  import { sendScheduledMessage } from '../chat/scheduledMessage';
6
6
  import { ChatInstance } from '../chat/types';
7
7
  import BccAttachmentBox from "./BccAttachmentBox.vue";
@@ -26,9 +26,19 @@ const messageListConfiguration = getMessageListConfiguration(chatInstance, chatG
26
26
  const threadedMessagesConfiguration = getThreadedMessagesConfiguration(chatGroup);
27
27
  threadedMessagesConfiguration.messageComposerConfiguration = getThreadedMessageComposerConfig();
28
28
 
29
- onMounted(() => {
29
+ onMounted(async () => {
30
30
  chatGroup.value = props.chatGroup
31
31
  attachEventlisteners();
32
+
33
+ await nextTick();
34
+ const userInput = document.querySelector('.messageinput-input');
35
+ if (userInput && chatInstance?.value.userInput) {
36
+ userInput.innerHTML = chatInstance.value.userInput;
37
+ }
38
+ if (chatInstance?.value.decoyAttachment) {
39
+ chatInstance.value.captionedAttachment = chatInstance.value.decoyAttachment
40
+ chatInstance.value.decoyAttachment = null
41
+ }
32
42
  })
33
43
 
34
44
  onUnmounted(() => {
@@ -58,7 +68,7 @@ watchEffect(() => {
58
68
  };
59
69
  detachEventlisteners()
60
70
  attachEventlisteners()
61
- } else {
71
+ } else {
62
72
  if (chatInstance && chatInstance.value.replyToMessage) {
63
73
  messageComposerConfiguration.value.headerView = {
64
74
  componentName: "bcc-reply-box",
@@ -74,7 +84,7 @@ watchEffect(() => {
74
84
  });
75
85
 
76
86
  function getThreadedMessageComposerConfig(): MessageComposerConfiguration {
77
- let composerConfig = {...messageComposerConfiguration.value}
87
+ let composerConfig = { ...messageComposerConfiguration.value }
78
88
  composerConfig.auxilaryButtonView = undefined
79
89
  return composerConfig;
80
90
  }
@@ -88,6 +98,9 @@ function attachEventlisteners() {
88
98
  sendButton.addEventListener("pointerdown", onMouseDown);
89
99
  sendButton.addEventListener("pointerup", clearTimer);
90
100
  sendButton.addEventListener("mouseleave", clearTimer);
101
+ sendButton.addEventListener("touchstart", onMouseDown);
102
+ sendButton.addEventListener("touchend", clearTimer);
103
+ sendButton.addEventListener("touchcancel", clearTimer);
91
104
 
92
105
  clearInterval(interval)
93
106
  }
@@ -102,6 +115,9 @@ function detachEventlisteners() {
102
115
  sendButton.removeEventListener("pointerdown", onMouseDown);
103
116
  sendButton.removeEventListener("pointerup", clearTimer);
104
117
  sendButton.removeEventListener("mouseleave", clearTimer);
118
+ sendButton.removeEventListener("touchstart", onMouseDown);
119
+ sendButton.removeEventListener("touchend", clearTimer);
120
+ sendButton.removeEventListener("touchcancel", clearTimer);
105
121
  }
106
122
  }
107
123
 
@@ -175,7 +191,8 @@ const clearTimer = () => {
175
191
  </div>
176
192
  <BccScheduledMessageModal v-if="showModal" @close="closeModal()" @send="scheduleMessage">
177
193
  </BccScheduledMessageModal>
178
- <BccAlert class="absolute top-0 w-[97%] mx-2 mt-1" icon closeButton context="danger" :open="showAlert" @close="showAlert = false">
194
+ <BccAlert class="absolute top-0 w-[97%] mx-2 mt-1" icon closeButton context="danger" :open="showAlert"
195
+ @close="showAlert = false">
179
196
  {{ localize("ERROR_SENDING_SCHEDULED_MESSAGE") }}
180
197
  </BccAlert>
181
198
  </div>
@@ -11,7 +11,7 @@ const sendButtonStyle = {
11
11
  width: "24px",
12
12
  border: "none",
13
13
  borderRadius: "0",
14
- buttonIconTint: "#2fb5e9d1",
14
+ buttonIconTint: "var(--cc__accent500, rgba(98, 116, 174, 0.66))",
15
15
  background: "transparent"
16
16
  }
17
17
 
@@ -34,9 +34,11 @@ async function redirectToScheduledMessagesChat() {
34
34
  }
35
35
  if (schedMsgChat) {
36
36
  chatInstance.value.scheduledMessageChat = schedMsgChat
37
+ chatInstance.value.decoyAttachment = chatInstance.value.captionedAttachment
37
38
  chatInstance.value.captionedAttachment = null
38
39
  chatInstance.value.replyToMessage = null
39
40
  chatInstance.value.showScheduledMessagesChat = true
41
+ chatInstance.value.userInput = document.querySelector(".messageinput-input")?.innerText;
40
42
  }
41
43
  }
42
44
  }
@@ -54,7 +56,7 @@ async function redirectToScheduledMessagesChat() {
54
56
  width: 24px;
55
57
  border: none;
56
58
  border-radius: 0;
57
- color: #2fb5e9d1;
59
+ color: var(--cc__accent500, rgba(98, 116, 174, 0.66));
58
60
  background: transparent;
59
61
  cursor: pointer;
60
62
  margin-right: -10px;
@@ -1,16 +1,18 @@
1
1
  <template>
2
- <BccModal class="modal" title="Schedule Message" :open="true" @close="close()" :closeButton="true">
2
+ <BccModal class="modal" :title=title :open="true" @close="close()" :closeButton="true">
3
3
  <div class="flex flex-col w-full">
4
- <div class="flex flex-row w-full">
5
- <input class="input" type="date" v-model="dateInput" required>
6
- <p class="at">at</p>
7
- <input class="input" type="time" v-model="timeInput" required>
4
+ <div class="flex flex-row w-full justify-between">
5
+ <input class="input w-[45%]" type="date" v-model="dateInput" required>
6
+ <p class="at w-[10%]">at</p>
7
+ <input class="input w-[45%]" type="time" v-model="timeInput" required>
8
8
  </div>
9
- <BccFormMessage class="text-center mt-2 mb-0 text-red-500" v-if="!isDateInFuture" state="error">{{ localize("ERROR_DATE_IN_FUTURE") }}</BccFormMessage>
9
+ <BccFormMessage class="text-center mt-2 mb-0 text-red-500" v-if="!isDateInFuture" state="error">{{
10
+ localize("ERROR_DATE_IN_FUTURE") }}</BccFormMessage>
10
11
  </div>
11
12
 
12
13
  <template #primaryAction>
13
- <BccButton class="button" :disabled="messageSent" @click="scheduleMessage()"> {{ localize("SCHEDULE_MESSAGE") }}</BccButton>
14
+ <BccButton class="button" :disabled="messageSent" @click="scheduleMessage()"> {{
15
+ localize("SCHEDULE_MESSAGE") }}</BccButton>
14
16
  </template>
15
17
  </BccModal>
16
18
  </template>
@@ -19,6 +21,7 @@
19
21
  import { BccButton, BccFormMessage, BccModal } from '@bcc-code/design-library-vue';
20
22
  import { localize } from '@cometchat/uikit-resources';
21
23
  import { computed, onMounted, ref } from 'vue';
24
+
22
25
  const emit = defineEmits(['close', 'send']);
23
26
 
24
27
  const dateInput = ref<string>();
@@ -29,6 +32,8 @@ const localDateTime = computed<string>(() => {
29
32
  return new Date(dateInput.value + "T" + timeInput.value).toISOString()
30
33
  })
31
34
 
35
+ const title = ref(localize("SCHEDULE_MESSAGE"));
36
+
32
37
  const isDateInFuture = computed<boolean>(() => {
33
38
  if (dateInput.value === '' || timeInput.value === '') return false
34
39
  return new Date(localDateTime.value) > new Date();
@@ -54,4 +59,105 @@ function scheduleMessage() {
54
59
  messageSent.value = true;
55
60
  }
56
61
  }
57
- </script>
62
+ </script>
63
+
64
+ <style lang="scss">
65
+ :root {
66
+ --cc__primary: #cfeac8;
67
+ --cc__background: #f3faf7;
68
+ --cc__secondary: white;
69
+ --cc__accent: #004e48;
70
+ --cc__accent50: rgba(62, 142, 117, 0.04);
71
+ --cc__accent100: #ffffff;
72
+ --cc__accent200: rgba(62, 142, 117, 0.15);
73
+ --cc__accent300: rgba(62, 142, 117, 0.24);
74
+ --cc__accent400: rgba(62, 142, 117, 0.33);
75
+ --cc__accent500: rgba(62, 142, 117, 0.46);
76
+ --cc__accent600: #004e48;
77
+ --cc__accent700: #254a40;
78
+ --cc__accent800: rgba(62, 142, 117, 0.82);
79
+ --cc__accent900: #f3faf7;
80
+ --cc__text-color: #000;
81
+ --cc__link-color: #57639e;
82
+
83
+ @media (prefers-color-scheme: dark) {
84
+ --cc__primary: #57639e;
85
+ --cc__background: hsl(230, 25%, 15%);
86
+ --cc__secondary: #111827;
87
+ --cc__accent: #6274ae;
88
+ --cc__accent50: rgba(98, 116, 174, 0.24);
89
+ --cc__accent100: linear-gradient(45deg, #05070b 0%, #0c111c 100%);
90
+ --cc__accent200: rgba(98, 116, 174, 0.35);
91
+ --cc__accent300: rgba(98, 116, 174, 0.44);
92
+ --cc__accent400: rgba(98, 116, 174, 0.53);
93
+ --cc__accent500: rgba(98, 116, 174, 0.66);
94
+ --cc__accent600: #758abc;
95
+ --cc__accent700: #6274ae;
96
+ --cc__accent800: rgba(98, 116, 174, 0.92);
97
+ --cc__accent900: #f3faf7;
98
+ --cc__text-color: #fff;
99
+ --cc__link-color: #cfeac8;
100
+ }
101
+ }
102
+
103
+ .modal {
104
+ position: fixed;
105
+ top: 50%;
106
+ left: 50%;
107
+ transform: translate(-50%, -50%);
108
+ background-color: var(--cc__background);
109
+ color: var(--cc__text-color);
110
+ }
111
+
112
+ .bcc-modal-content {
113
+ display: flex;
114
+ justify-content: space-between;
115
+ width: 100%;
116
+ }
117
+
118
+ .bcc-modal-content .input {
119
+ background-color: var(--cc__primary);
120
+ border-radius: 5px;
121
+ color: var(--cc__text-color);
122
+ height: 40px;
123
+ padding: 5px;
124
+ width: 45%;
125
+ }
126
+
127
+ .bcc-modal-content .at {
128
+ width: 10%;
129
+ text-align: center;
130
+ margin-top: 7px;
131
+ }
132
+
133
+ .bcc-modal-footer {
134
+ background-color: var(--cc__background);
135
+ }
136
+
137
+ .bcc-modal-actions {
138
+ background-color: var(--cc__background);
139
+ display: flex;
140
+ width: 100%;
141
+ justify-content: space-between;
142
+ }
143
+
144
+ .bcc-modal-actions .bcc-modal-secondary-action,
145
+ .bcc-modal-primary-action {
146
+ width: 100%;
147
+ background-color: var(--cc__background);
148
+ }
149
+
150
+ .bcc-modal-secondary-action button,
151
+ .bcc-modal-primary-action button {
152
+ background-color: var(--cc__accent800);
153
+ width: 100%;
154
+ border-radius: 5px;
155
+ margin-top: -10px;
156
+ }
157
+
158
+ .bcc-modal-secondary-action button:hover,
159
+ .bcc-modal-primary-action button:hover {
160
+ background-color: var(--cc__accent700);
161
+ }
162
+
163
+ </style>
@@ -4,7 +4,7 @@ import { Group } from "@cometchat/chat-sdk-javascript";
4
4
  import { CloseIcon } from "@bcc-code/icons-vue";
5
5
  import { CometChatMessages } from "../chat/cometChatPatches";
6
6
  import { getScheduledMessagesComposerConfiguration, getScheduledMessagesListConfiguration } from "../chat/uiKit";
7
- import { inject, onUnmounted, ref, Ref, watchEffect } from "vue";
7
+ import { inject, nextTick, onMounted, onUnmounted, ref, Ref, watchEffect } from "vue";
8
8
  import { ChatInstance } from "../chat/types";
9
9
  import { localize } from "@cometchat/uikit-resources";
10
10
  import { BccAlert } from "@bcc-code/design-library-vue";
@@ -24,6 +24,11 @@ const messageComposerConfiguration = getScheduledMessagesComposerConfiguration(p
24
24
  const messageListConfiguration = getScheduledMessagesListConfiguration(props.originalChatUid, chatInstance, chatGroup);
25
25
 
26
26
  function closeList() {
27
+ if (chatInstance?.value) {
28
+ chatInstance.value.userInput = document.querySelector('.messageinput-input')?.innerHTML ?? null;
29
+ chatInstance.value.decoyAttachment = chatInstance.value.captionedAttachment
30
+ chatInstance.value.captionedAttachment = null
31
+ }
27
32
  emit('close');
28
33
  }
29
34
 
@@ -40,6 +45,19 @@ watchEffect(() => {
40
45
  }
41
46
  })
42
47
 
48
+ onMounted(async () => {
49
+ await nextTick();
50
+ const userInput = document.querySelector('.messageinput-input');
51
+ if (userInput && chatInstance?.value.userInput) {
52
+ userInput.innerHTML = chatInstance.value.userInput;
53
+ }
54
+
55
+ if (chatInstance?.value.decoyAttachment) {
56
+ chatInstance.value.captionedAttachment = chatInstance.value.decoyAttachment
57
+ chatInstance.value.decoyAttachment = null
58
+ }
59
+ })
60
+
43
61
  onUnmounted(() => {
44
62
  if (chatInstance) {
45
63
  chatInstance.value.captionedAttachment = null
@@ -22,7 +22,7 @@ const sendButtonStyle = {
22
22
  width: "24px",
23
23
  border: "none",
24
24
  borderRadius: "0",
25
- buttonIconTint: "#2fb5e9d1",
25
+ buttonIconTint: "var(--cc__accent500, rgba(98, 116, 174, 0.66))",
26
26
  background: "transparent"
27
27
  }
28
28