@webitel/ui-chats 0.0.18 → 0.0.19

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-chats",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Reusable Webitel Frontend Code for Chats UI",
5
5
  "workspaces": [
6
6
  "../../",
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <wt-textarea
3
3
  ref="chatTextFieldInput"
4
+ class="chat-text-field"
4
5
  :model-value="textModel"
5
6
  :size="size"
6
7
  autoresize
@@ -48,3 +49,12 @@ function insertAtCursor(text: string) {
48
49
  }
49
50
  </script>
50
51
 
52
+ <style scoped>
53
+ .chat-text-field :deep(textarea) {
54
+ /* https://webitel.atlassian.net/browse/WTEL-7388
55
+ fixed styles after component migrated on vuetify */
56
+ max-height: 100%;
57
+ min-height: auto;
58
+ overflow: auto !important;
59
+ }
60
+ </style>
@@ -3,6 +3,7 @@ export const ChatAction = {
3
3
  AttachFiles: "attachFiles",
4
4
  EmojiPicker: "emojiPicker",
5
5
  QuickReplies: "quickReplies",
6
+ LoadNextMessages: "loadNextMessages",
6
7
  } as const;
7
8
 
8
9
  export type ChatAction = (typeof ChatAction)[keyof typeof ChatAction];
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div class="chat-observer">
3
+ <wt-intersection-observer
4
+ :can-load-more="props.next"
5
+ :loading="props.isLoading"
6
+ @next="emit(ChatAction.LoadNextMessages)"
7
+ />
8
+ </div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { ChatAction } from "../../chat-footer/modules/user-input/enums/ChatAction.enum";
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ next?: boolean;
17
+ isLoading?: boolean;
18
+ }>(),
19
+ {
20
+ next: false,
21
+ isLoading: false,
22
+ },
23
+ );
24
+
25
+ const emit = defineEmits<(e: typeof ChatAction.LoadNextMessages) => void>();
26
+ </script>
27
+
28
+ <style scoped>
29
+ /* @author ye.pohranichna */
30
+ /* reserve height for the loader to avoid unnecessary chat height changes https://webitel.atlassian.net/browse/WTEL-5366 */
31
+ .chat-observer {
32
+ /* observer loader height @author ye.pohranichna */
33
+ min-height: calc(var(--spacing-lg)*2 + var(--icon-md-size));
34
+ /* @author ye.pohranichna */
35
+ /* to place observer at the bottom of observer wrapper (closer to messages) */
36
+ display: flex;
37
+ align-items: flex-end;
38
+ }
39
+ </style>
@@ -9,6 +9,12 @@
9
9
  @scroll="handleChatScroll"
10
10
  @resize="handleChatResize"
11
11
  >
12
+ <chat-observer
13
+ v-if="props.next"
14
+ :next="props.next"
15
+ :loading="props.isLoading"
16
+ @next="emit(ChatAction.LoadNextMessages)"
17
+ />
12
18
  <chat-message
13
19
  v-for="(message, index) of props.messages"
14
20
  :key="message.id"
@@ -37,6 +43,7 @@
37
43
  import type { Emitter } from "mitt";
38
44
  import { computed, inject, nextTick, onMounted, useTemplateRef } from "vue";
39
45
 
46
+ import { ChatAction } from "../../chat-footer/modules/user-input/enums/ChatAction.enum";
40
47
  import type { UiChatsEmitterEvents } from "../../utils/emitter";
41
48
  import { useChatScroll } from "../composables/useChatScroll";
42
49
  import ChatMessage from "../modules/message/components/chat-message.vue";
@@ -44,6 +51,7 @@ import { useChatMessages } from "../modules/message/composables/useChatMessage";
44
51
  import { MessageAction } from "../modules/message/enums/MessageAction.enum";
45
52
  import type { ChatMessageType } from "../types/ChatMessage.types";
46
53
  import ChatDateDivider from "./chat-date-divider.vue";
54
+ import ChatObserver from "./chat-observer.vue";
47
55
  import ScrollToBottomBtn from "./scroll-to-bottom-btn.vue";
48
56
 
49
57
  const uiChatsEmitter = inject<Emitter<UiChatsEmitterEvents>>("uiChatsEmitter");
@@ -51,13 +59,19 @@ const uiChatsEmitter = inject<Emitter<UiChatsEmitterEvents>>("uiChatsEmitter");
51
59
  const props = withDefaults(
52
60
  defineProps<{
53
61
  messages: ChatMessageType[];
62
+ next?: boolean;
63
+ isLoading?: boolean;
54
64
  withoutAvatars?: boolean;
55
65
  }>(),
56
66
  {
67
+ next: false,
68
+ isLoading: false,
57
69
  withoutAvatars: false,
58
70
  },
59
71
  );
60
72
 
73
+ const emit = defineEmits<(e: typeof ChatAction.LoadNextMessages) => void>();
74
+
61
75
  const messagesContainer = useTemplateRef("messages-container");
62
76
 
63
77
  const { showAvatar, showChatDate } = useChatMessages(props.messages);
@@ -110,4 +124,5 @@ onMounted(() => {
110
124
  scrollbar-gutter: stable both-edges;
111
125
  gap: var(--spacing-xs);
112
126
  }
127
+
113
128
  </style>
@@ -10,7 +10,7 @@
10
10
 
11
11
  <div class="chat-message__content">
12
12
  <div
13
- v-if="withoutAvatars"
13
+ v-if="!props.withoutAvatars"
14
14
  class="chat-message__avatar-wrapper"
15
15
  >
16
16
  <message-avatar
@@ -12,7 +12,10 @@
12
12
  />
13
13
  <chat-messages-container
14
14
  :messages="props.messages"
15
+ :next="props.canLoadNextMessages"
16
+ :is-loading="props.isNextMessagesLoading"
15
17
  :without-avatars="props.withoutAvatars"
18
+ @[ChatAction.LoadNextMessages]="emit(ChatAction.LoadNextMessages)"
16
19
  @[ChatAction.AttachFiles]="sendFile"
17
20
  />
18
21
  </slot>
@@ -68,6 +71,8 @@ const props = withDefaults(
68
71
  messages: ChatMessageType[];
69
72
  chatActions?: ChatAction[];
70
73
  size?: ComponentSize;
74
+ canLoadNextMessages?: boolean; // 'next'
75
+ isNextMessagesLoading?: boolean;
71
76
  withoutAvatars?: boolean;
72
77
  }>(),
73
78
  {
@@ -76,6 +81,8 @@ const props = withDefaults(
76
81
  chatActions: () => [
77
82
  ChatAction.SendMessage,
78
83
  ],
84
+ canLoadNextMessages: false,
85
+ isNextMessagesLoading: false,
79
86
  },
80
87
  );
81
88
 
@@ -90,6 +97,7 @@ const emit = defineEmits<{
90
97
  files: File[],
91
98
  options: ResultCallbacks,
92
99
  ): void;
100
+ (e: typeof ChatAction.LoadNextMessages): void;
93
101
  (e: typeof MessageAction.ClickOnImage, message: ChatMessageType): void;
94
102
  }>();
95
103
 
@@ -0,0 +1,14 @@
1
+ type __VLS_Props = {
2
+ next?: boolean;
3
+ isLoading?: boolean;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ loadNextMessages: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onLoadNextMessages?: () => any;
9
+ }>, {
10
+ next: boolean;
11
+ isLoading: boolean;
12
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
@@ -1,10 +1,18 @@
1
1
  import type { ChatMessageType } from "../types/ChatMessage.types";
2
2
  type __VLS_Props = {
3
3
  messages: ChatMessageType[];
4
+ next?: boolean;
5
+ isLoading?: boolean;
4
6
  withoutAvatars?: boolean;
5
7
  };
6
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
+ loadNextMessages: () => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ onLoadNextMessages?: () => any;
12
+ }>, {
7
13
  withoutAvatars: boolean;
14
+ next: boolean;
15
+ isLoading: boolean;
8
16
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
17
  declare const _default: typeof __VLS_export;
10
18
  export default _default;