@bcc-code/vue-bcc-chat-ui 4.4.6 → 4.4.8

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": "4.4.6",
5
+ "version": "4.4.8",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -51,7 +51,7 @@
51
51
  "vue": "^3.4.38"
52
52
  },
53
53
  "dependencies": {
54
- "@bcc-code/design-library-vue": "^2.6.3",
54
+ "@bcc-code/design-library-vue": "^2.9.2",
55
55
  "@bcc-code/icons-vue": "^1.4.0",
56
56
  "@cometchat/chat-sdk-javascript": "4.0.10",
57
57
  "@cometchat/chat-uikit-vue": "4.3.17",
@@ -1,13 +1,17 @@
1
1
  <script setup lang="ts">
2
2
  import chat from "../chat";
3
3
  import { Group } from "@cometchat/chat-sdk-javascript";
4
- import { computed, inject, nextTick, onMounted, Ref, ref, watch, watchEffect } from 'vue';
4
+ import { computed, inject, nextTick, onMounted, onUnmounted, Ref, ref, watch, watchEffect } from 'vue';
5
5
  import { ChatInstance } from '../chat/types';
6
6
  import BccAttachmentBox from "./BccAttachmentBox.vue";
7
7
  import BccChatSendButton from "./BccChatSendButton.vue";
8
8
  import { getMessageComposerConfiguration, getMessageListConfiguration, getThreadedMessagesConfiguration } from "../chat/uiKit";
9
9
  import { CometChatMessages } from "../chat/cometChatPatches";
10
10
  import { MessageComposerConfiguration } from "@cometchat/uikit-shared";
11
+ import { sendScheduledMessage } from "../chat/scheduledMessage";
12
+ import BccScheduledMessageModal from "./BccScheduledMessageModal.vue";
13
+ import { BccAlert } from "@bcc-code/design-library-vue";
14
+ import { localize } from "@cometchat/uikit-resources";
11
15
 
12
16
  const props = defineProps({
13
17
  chatUid: { type: String, required: true },
@@ -27,7 +31,7 @@ threadedMessagesConfiguration.messageComposerConfiguration = getThreadedMessageC
27
31
 
28
32
  onMounted(async () => {
29
33
  chatGroup.value = props.chatGroup
30
- // attachEventlisteners();
34
+ attachEventlisteners();
31
35
 
32
36
  messageComposerConfiguration.value.text = chatInstance?.value.userInput ?? '';
33
37
 
@@ -38,9 +42,9 @@ onMounted(async () => {
38
42
  }
39
43
  })
40
44
 
41
- // onUnmounted(() => {
42
- // detachEventlisteners();
43
- // })
45
+ onUnmounted(() => {
46
+ detachEventlisteners();
47
+ })
44
48
 
45
49
  watch(() => props.chatGroup,
46
50
  (group) => {
@@ -63,8 +67,8 @@ watchEffect(() => {
63
67
  chatUid: props.chatUid
64
68
  }
65
69
  };
66
- // detachEventlisteners()
67
- // attachEventlisteners()
70
+ detachEventlisteners()
71
+ attachEventlisteners()
68
72
  } else {
69
73
  if (chatInstance && chatInstance.value.replyToMessage) {
70
74
  messageComposerConfiguration.value.headerView = {
@@ -87,91 +91,91 @@ function getThreadedMessageComposerConfig(): MessageComposerConfiguration {
87
91
  }
88
92
 
89
93
  // Holding functionality temporarily disabled due to some bugs
90
- //
91
- // function attachEventlisteners() {
92
- // const interval = setInterval(() => {
93
- // const btns = document.querySelectorAll('.cc-messagecomposer-wrapper__sendbutton');
94
- // const sendButton = btns[btns.length - 1]
95
- // document.querySelector("body")?.addEventListener("contextmenu", (event) => event.preventDefault());
96
-
97
- // if (sendButton) {
98
- // sendButton.addEventListener("pointerdown", onMouseDown);
99
- // sendButton.addEventListener("pointerup", clearTimer);
100
- // sendButton.addEventListener("mouseleave", clearTimer);
101
- // sendButton.addEventListener("contextmenu", onContextMenu);
102
- // clearInterval(interval)
103
- // }
104
- // }, 500);
105
- // }
106
-
107
- // function detachEventlisteners() {
108
- // const btns = document.querySelectorAll('.cc-messagecomposer-wrapper__sendbutton');
109
- // const sendButton = btns[btns.length - 1]
110
-
111
- // if (sendButton) {
112
- // sendButton.removeEventListener("pointerdown", onMouseDown);
113
- // sendButton.removeEventListener("pointerup", clearTimer);
114
- // sendButton.removeEventListener("mouseleave", clearTimer);
115
- // sendButton.removeEventListener("contextmenu", onContextMenu);
116
- // }
117
- // }
118
-
119
- // function closeModal() {
120
- // showModal.value = false;
121
- // }
122
-
123
- // const showModal = ref(false);
124
- // let timerId: string | number | NodeJS.Timeout | null | undefined;
125
- // const duration = 500;
126
- // let longPressDetected = false;
127
-
128
- // const openPopup = () => {
129
- // showModal.value = true;
130
- // }
131
-
132
- // const onMouseDown = (event: Event) => {
133
- // const userInput = document.querySelector(".messageinput-input")?.innerText;
134
- // event.preventDefault();
135
- // event.stopPropagation();
136
- // if (userInput) {
137
- // // Only handle long press when there is user input
138
- // timerId = setTimeout(() => {
139
- // longPressDetected = true;
140
- // openPopup();
141
- // }, duration); // assuming duration is 500ms for long press
142
- // }
143
- // };
144
-
145
- // const onContextMenu = (event: Event) => {
146
- // if (longPressDetected) {
147
- // // Prevent context menu only when long press is detected
148
- // event.preventDefault();
149
- // event.stopPropagation();
150
- // }
151
- // };
152
-
153
- // const clearTimer = (event: Event) => {
154
- // event.preventDefault();
155
- // event.stopPropagation();
156
- // if (timerId !== null) {
157
- // clearTimeout(timerId);
158
- // timerId = null;
159
- // }
160
- // }
161
-
162
- const showAlert = ref<boolean>(false)
163
-
164
- // function scheduleMessage(scheduleDate?: string) {
165
- // if (scheduleDate && chatInstance) {
166
- // sendScheduledMessage(scheduleDate, props.chatUid, chatInstance).then((msgSuccessful) => {
167
- // if (!msgSuccessful) {
168
- // showModal.value = false
169
- // showAlert.value = true
170
- // setTimeout(() => showAlert.value = false, 3000)
171
- // }
172
- // })
173
- // }
174
- // }
94
+
95
+ function attachEventlisteners() {
96
+ const interval = setInterval(() => {
97
+ const btns = document.querySelectorAll('.cc-messagecomposer-wrapper__sendbutton');
98
+ const sendButton = btns[btns.length - 1]
99
+ document.querySelector("body")?.addEventListener("contextmenu", (event) => event.preventDefault());
100
+
101
+ if (sendButton) {
102
+ sendButton.addEventListener("pointerdown", onMouseDown);
103
+ sendButton.addEventListener("pointerup", clearTimer);
104
+ sendButton.addEventListener("mouseleave", clearTimer);
105
+ sendButton.addEventListener("contextmenu", onContextMenu);
106
+ clearInterval(interval)
107
+ }
108
+ }, 500);
109
+ }
110
+
111
+ function detachEventlisteners() {
112
+ const btns = document.querySelectorAll('.cc-messagecomposer-wrapper__sendbutton');
113
+ const sendButton = btns[btns.length - 1]
114
+
115
+ if (sendButton) {
116
+ sendButton.removeEventListener("pointerdown", onMouseDown);
117
+ sendButton.removeEventListener("pointerup", clearTimer);
118
+ sendButton.removeEventListener("mouseleave", clearTimer);
119
+ sendButton.removeEventListener("contextmenu", onContextMenu);
120
+ }
121
+ }
122
+
123
+ function closeModal() {
124
+ showModal.value = false;
125
+ }
126
+
127
+ const showModal = ref(false);
128
+ let timerId: string | number | NodeJS.Timeout | null | undefined;
129
+ const duration = 500;
130
+ let longPressDetected = false;
131
+
132
+ const openPopup = () => {
133
+ showModal.value = true;
134
+ }
135
+
136
+ const onMouseDown = (event: Event) => {
137
+ const userInput = document.querySelector(".messageinput-input")?.innerText;
138
+ event.preventDefault();
139
+ event.stopPropagation();
140
+ if (userInput) {
141
+ // Only handle long press when there is user input
142
+ timerId = setTimeout(() => {
143
+ longPressDetected = true;
144
+ openPopup();
145
+ }, duration); // assuming duration is 500ms for long press
146
+ }
147
+ };
148
+
149
+ const showAlert = ref<boolean>(false);
150
+
151
+ const onContextMenu = (event: Event) => {
152
+ if (longPressDetected) {
153
+ // Prevent context menu only when long press is detected
154
+ event.preventDefault();
155
+ event.stopPropagation();
156
+ }
157
+ };
158
+
159
+ const clearTimer = (event: Event) => {
160
+ event.preventDefault();
161
+ event.stopPropagation();
162
+ if (timerId !== null) {
163
+ clearTimeout(timerId);
164
+ timerId = null;
165
+ }
166
+ }
167
+
168
+ function scheduleMessage(scheduleDate?: string) {
169
+ if (scheduleDate && chatInstance) {
170
+ sendScheduledMessage(scheduleDate, props.chatUid, chatInstance).then((msgSuccessful) => {
171
+ if (!msgSuccessful) {
172
+ showModal.value = false
173
+ showAlert.value = true
174
+ setTimeout(() => showAlert.value = false, 3000)
175
+ }
176
+ })
177
+ }
178
+ }
175
179
 
176
180
  function isChannel(): boolean {
177
181
  return (props.chatGroup.getMetadata() as any)?.isChannel;
@@ -198,11 +202,11 @@ function isParticipant(): boolean {
198
202
  <span v-if="isOffline">Waiting for network...</span>
199
203
  <span v-else>Connecting... </span>
200
204
  </div>
201
- <!-- <BccScheduledMessageModal v-if="showModal" @close="closeModal()" @send="scheduleMessage">
205
+ <BccScheduledMessageModal v-if="showModal" @close="closeModal()" @send="scheduleMessage" :closeOnOutsideClick="false">
202
206
  </BccScheduledMessageModal>
203
207
  <BccAlert class="absolute top-0 w-[97%] mx-2 mt-1" icon closeButton context="danger" :open="showAlert"
204
208
  @close="showAlert = false">
205
209
  {{ localize("ERROR_SENDING_SCHEDULED_MESSAGE") }}
206
- </BccAlert> -->
210
+ </BccAlert>
207
211
  </div>
208
212
  </template>
@@ -1,14 +1,15 @@
1
1
  <script lang="ts" setup>
2
2
  import { BccButton, BccFormMessage, BccModal } from '@bcc-code/design-library-vue';
3
3
  import { localize } from '@cometchat/uikit-resources';
4
- import { computed, onMounted, ref } from 'vue';
4
+ import { computed, onMounted, ref, watch } from 'vue';
5
5
 
6
6
  const props = defineProps({
7
- isReschedule: { type: Boolean, default: false }
7
+ isReschedule: { type: Boolean, default: false },
8
+ closeOnOutsideClick: { type: Boolean, default: true }
8
9
  })
9
10
 
10
11
  const title = props.isReschedule ? localize("RESCHEDULE") : localize("SCHEDULE_MESSAGE")
11
-
12
+ const closeOnOutsideClick = ref<boolean>(props.closeOnOutsideClick);
12
13
  const emit = defineEmits(['close', 'schedule', 'reschedule']);
13
14
 
14
15
  const dateInput = ref<string>();
@@ -32,6 +33,8 @@ onMounted(() => {
32
33
  const hours = String(now.getHours()).padStart(2, '0');
33
34
  const minutes = String(now.getMinutes()).padStart(2, '0');
34
35
  timeInput.value = `${hours}:${minutes}`;
36
+
37
+ setTimeout(() => closeOnOutsideClick.value = true, 500);
35
38
  })
36
39
 
37
40
  function close() {
@@ -47,11 +50,12 @@ function scheduleMessage() {
47
50
  </script>
48
51
 
49
52
  <template>
50
- <BccModal class="modal" :title="title" :open="true" @close="close()" :closeButton="true">
53
+ <BccModal class="modal" :title="title" :open="true" @close="close()" :closeOnOutsideClick="closeOnOutsideClick"
54
+ :closeButton="true">
51
55
  <div class="flex flex-col w-full">
52
56
  <div class="flex flex-row w-full justify-between">
53
57
  <input class="input" type="date" v-model="dateInput" required>
54
- <p class="at">at</p>
58
+ <p class="at">{{ localize("AT") }}</p>
55
59
  <input class="input" type="time" v-model="timeInput" required>
56
60
  </div>
57
61
  <BccFormMessage class="text-center mt-2 mb-0 text-red-500" v-if="!isDateInFuture" state="error">{{