@webitel/ui-chats 26.8.3 → 26.8.5
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 +9 -2
- package/src/locale/en/en.ts +3 -0
- package/src/locale/es/es.ts +3 -0
- package/src/locale/kz/kz.ts +3 -0
- package/src/locale/pl/pl.ts +3 -0
- package/src/locale/ro/ro.ts +3 -0
- package/src/locale/ru/ru.ts +3 -0
- package/src/locale/uk/uk.ts +3 -0
- package/src/locale/uz/uz.ts +3 -0
- package/src/locale/vi/vi.ts +3 -0
- package/src/shared/composables/__tests__/useChatScroll.spec.ts +164 -0
- package/src/shared/composables/__tests__/useObserveHeightUntilStable.spec.ts +48 -0
- package/src/{ui/messaging → shared}/composables/useChatScroll.ts +37 -9
- package/src/{ui/messaging → shared}/composables/useObserveHeightUntilStable.ts +2 -0
- package/src/ui/index.ts +2 -2
- package/src/ui/messaging/components/the-messages-container.vue +2 -2
- package/src/v2/index.ts +4 -0
- package/src/v2/locale/en.ts +29 -0
- package/src/v2/locale/es.ts +28 -0
- package/src/v2/locale/kz.ts +28 -0
- package/src/v2/locale/pl.ts +28 -0
- package/src/v2/locale/ro.ts +28 -0
- package/src/v2/locale/ru.ts +27 -0
- package/src/v2/locale/uk.ts +27 -0
- package/src/v2/locale/useChatsV2I18n.ts +14 -0
- package/src/v2/locale/uz.ts +28 -0
- package/src/v2/locale/vi.ts +28 -0
- package/src/v2/scripts/__tests__/attachments.spec.ts +168 -0
- package/src/v2/scripts/__tests__/fixtures.ts +56 -0
- package/src/v2/scripts/__tests__/formatDate.spec.ts +96 -0
- package/src/v2/scripts/__tests__/getMessageStatus.spec.ts +304 -0
- package/src/v2/scripts/__tests__/isContactCentreSide.spec.ts +21 -0
- package/src/v2/scripts/__tests__/resolveSystemNotice.spec.ts +157 -0
- package/src/v2/scripts/__tests__/toHistoryItems.spec.ts +100 -0
- package/src/v2/scripts/attachments.ts +144 -0
- package/src/v2/scripts/formatDate.ts +74 -0
- package/src/v2/scripts/getMessageStatus.ts +59 -0
- package/src/v2/scripts/isContactCentreSide.ts +14 -0
- package/src/v2/scripts/isSelfMessage.ts +29 -0
- package/src/v2/scripts/resolveSystemNotice.ts +119 -0
- package/src/v2/scripts/toHistoryItems.ts +63 -0
- package/src/v2/scripts/toTimestamp.ts +21 -0
- package/src/v2/types/index.ts +74 -0
- package/src/v2/ui/__tests__/mountWithChats.ts +38 -0
- package/src/v2/ui/chat-composer/__tests__/chat-composer.spec.ts +221 -0
- package/src/v2/ui/chat-composer/chat-composer.vue +212 -0
- package/src/v2/ui/chat-history/__tests__/chat-history.spec.ts +334 -0
- package/src/v2/ui/chat-history/chat-history.vue +262 -0
- package/src/v2/ui/chat-history/components/chat-date-divider.vue +36 -0
- package/src/v2/ui/chat-history/components/chat-message.vue +156 -0
- package/src/v2/ui/chat-history/components/chat-system-notice.vue +111 -0
- package/src/v2/ui/chat-history/components/message-attachments.vue +162 -0
- package/src/v2/ui/chat-history/components/message-status.vue +31 -0
- package/src/v2/ui/chat-history/components/message-text.vue +37 -0
- package/src/v2/ui/chat-history/components/scroll-to-bottom-btn.vue +55 -0
- package/src/v2/ui/chat-history/gallery.ts +8 -0
- package/src/v2/ui/chat-thread/__tests__/chat-thread.spec.ts +122 -0
- package/src/v2/ui/chat-thread/chat-thread.vue +111 -0
- package/types/.tsbuildinfo +1 -1
- package/types/locale/en/en.d.ts +25 -0
- package/types/locale/es/es.d.ts +25 -0
- package/types/locale/index.d.ts +225 -0
- package/types/locale/kz/kz.d.ts +25 -0
- package/types/locale/pl/pl.d.ts +25 -0
- package/types/locale/ro/ro.d.ts +25 -0
- package/types/locale/ru/ru.d.ts +25 -0
- package/types/locale/uk/uk.d.ts +25 -0
- package/types/locale/uz/uz.d.ts +25 -0
- package/types/locale/vi/vi.d.ts +25 -0
- package/types/{ui/messaging → shared}/composables/useChatScroll.d.ts +14 -4
- package/types/ui/index.d.ts +2 -2
- package/types/v2/index.d.ts +4 -0
- package/types/v2/locale/en.d.ts +27 -0
- package/types/v2/locale/es.d.ts +26 -0
- package/types/v2/locale/kz.d.ts +26 -0
- package/types/v2/locale/pl.d.ts +26 -0
- package/types/v2/locale/ro.d.ts +26 -0
- package/types/v2/locale/ru.d.ts +26 -0
- package/types/v2/locale/uk.d.ts +26 -0
- package/types/v2/locale/useChatsV2I18n.d.ts +5 -0
- package/types/v2/locale/uz.d.ts +26 -0
- package/types/v2/locale/vi.d.ts +26 -0
- package/types/v2/scripts/__tests__/fixtures.d.ts +7 -0
- package/types/v2/scripts/attachments.d.ts +30 -0
- package/types/v2/scripts/formatDate.d.ts +17 -0
- package/types/v2/scripts/getMessageStatus.d.ts +8 -0
- package/types/v2/scripts/isContactCentreSide.d.ts +8 -0
- package/types/v2/scripts/isSelfMessage.d.ts +10 -0
- package/types/v2/scripts/resolveSystemNotice.d.ts +23 -0
- package/types/v2/scripts/toHistoryItems.d.ts +19 -0
- package/types/v2/scripts/toTimestamp.d.ts +7 -0
- package/types/v2/types/index.d.ts +54 -0
- package/types/v2/ui/__tests__/mountWithChats.d.ts +8 -0
- package/types/v2/ui/chat-composer/chat-composer.vue.d.ts +31 -0
- package/types/v2/ui/chat-history/chat-history.vue.d.ts +11 -0
- package/types/v2/ui/chat-history/components/chat-date-divider.vue.d.ts +6 -0
- package/types/v2/ui/chat-history/components/chat-message.vue.d.ts +10 -0
- package/types/v2/ui/chat-history/components/chat-system-notice.vue.d.ts +9 -0
- package/types/v2/ui/chat-history/components/message-attachments.vue.d.ts +7 -0
- package/types/v2/ui/chat-history/components/message-status.vue.d.ts +7 -0
- package/types/v2/ui/chat-history/components/message-text.vue.d.ts +6 -0
- package/types/v2/ui/chat-history/components/scroll-to-bottom-btn.vue.d.ts +12 -0
- package/types/v2/ui/chat-history/gallery.d.ts +6 -0
- package/types/v2/ui/chat-thread/chat-thread.vue.d.ts +26 -0
- /package/src/{ui/messaging → shared}/composables/useScrollToBottomBtn.ts +0 -0
- /package/types/{ui/messaging → shared}/composables/useObserveHeightUntilStable.d.ts +0 -0
- /package/types/{ui/messaging → shared}/composables/useScrollToBottomBtn.d.ts +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="chat-thread">
|
|
3
|
+
<chat-history
|
|
4
|
+
class="chat-thread__history"
|
|
5
|
+
:thread="props.thread"
|
|
6
|
+
:messages="props.messages"
|
|
7
|
+
:self-member-id="props.selfMemberId"
|
|
8
|
+
:mode="props.mode"
|
|
9
|
+
:has-more="props.hasMore"
|
|
10
|
+
:on-load-more="props.onLoadMore"
|
|
11
|
+
:resolve-avatar-url="props.resolveAvatarUrl"
|
|
12
|
+
@seen="emit('seen', $event)"
|
|
13
|
+
/>
|
|
14
|
+
<!-- keyed by thread: switching chats drops the draft and any pending state -->
|
|
15
|
+
<chat-composer
|
|
16
|
+
v-if="props.mode === ChatThreadMode.Active"
|
|
17
|
+
:key="props.thread.id"
|
|
18
|
+
class="chat-thread__composer"
|
|
19
|
+
:on-send="props.onSend"
|
|
20
|
+
:on-attach="props.onAttach"
|
|
21
|
+
:actions="props.actions"
|
|
22
|
+
:submit-on-enter="props.submitOnEnter"
|
|
23
|
+
:disabled="props.disabled"
|
|
24
|
+
v-bind="draftBinding()"
|
|
25
|
+
>
|
|
26
|
+
<template #actions="slotProps">
|
|
27
|
+
<slot
|
|
28
|
+
name="actions"
|
|
29
|
+
v-bind="slotProps"
|
|
30
|
+
/>
|
|
31
|
+
</template>
|
|
32
|
+
</chat-composer>
|
|
33
|
+
</section>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="ts">
|
|
37
|
+
import { getCurrentInstance } from 'vue';
|
|
38
|
+
|
|
39
|
+
import {
|
|
40
|
+
ChatComposerAction,
|
|
41
|
+
type ChatComposerSlotProps,
|
|
42
|
+
ChatThreadMode,
|
|
43
|
+
type ChatThreadProps,
|
|
44
|
+
type MessageModel,
|
|
45
|
+
} from '../../types';
|
|
46
|
+
import ChatComposer from '../chat-composer/chat-composer.vue';
|
|
47
|
+
import ChatHistory from '../chat-history/chat-history.vue';
|
|
48
|
+
|
|
49
|
+
const props = withDefaults(defineProps<ChatThreadProps>(), {
|
|
50
|
+
mode: ChatThreadMode.Active,
|
|
51
|
+
hasMore: false,
|
|
52
|
+
actions: () => [
|
|
53
|
+
ChatComposerAction.Attach,
|
|
54
|
+
ChatComposerAction.Emoji,
|
|
55
|
+
ChatComposerAction.Send,
|
|
56
|
+
],
|
|
57
|
+
submitOnEnter: true,
|
|
58
|
+
disabled: false,
|
|
59
|
+
draft: undefined,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const emit = defineEmits<{
|
|
63
|
+
seen: [
|
|
64
|
+
message: MessageModel,
|
|
65
|
+
];
|
|
66
|
+
'update:draft': [
|
|
67
|
+
draft: string,
|
|
68
|
+
];
|
|
69
|
+
}>();
|
|
70
|
+
|
|
71
|
+
defineSlots<{
|
|
72
|
+
actions?: (props: ChatComposerSlotProps) => unknown;
|
|
73
|
+
}>();
|
|
74
|
+
|
|
75
|
+
const instance = getCurrentInstance();
|
|
76
|
+
|
|
77
|
+
// Forward the draft only when the app binds v-model:draft; otherwise the
|
|
78
|
+
// composer keeps its own, which the :key above resets per thread. Binding is
|
|
79
|
+
// read from the vnode, not the value: drafts[thread.id] is undefined until
|
|
80
|
+
// the operator types. Called from render, so it follows each parent render.
|
|
81
|
+
function draftBinding() {
|
|
82
|
+
const bound = instance?.vnode.props ?? {};
|
|
83
|
+
const isControlled = 'draft' in bound || 'onUpdate:draft' in bound;
|
|
84
|
+
return isControlled
|
|
85
|
+
? {
|
|
86
|
+
draft: props.draft ?? '',
|
|
87
|
+
'onUpdate:draft': (value: string) => emit('update:draft', value),
|
|
88
|
+
}
|
|
89
|
+
: {};
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<style scoped>
|
|
94
|
+
.chat-thread {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: var(--wt-ws-chat-window-sizes-root-gap);
|
|
98
|
+
min-height: 0;
|
|
99
|
+
height: 100%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.chat-thread__history {
|
|
103
|
+
flex: 1;
|
|
104
|
+
min-height: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.chat-thread__composer {
|
|
108
|
+
flex: 0 0 auto;
|
|
109
|
+
max-height: 50%;
|
|
110
|
+
}
|
|
111
|
+
</style>
|