@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.
Files changed (107) hide show
  1. package/package.json +9 -2
  2. package/src/locale/en/en.ts +3 -0
  3. package/src/locale/es/es.ts +3 -0
  4. package/src/locale/kz/kz.ts +3 -0
  5. package/src/locale/pl/pl.ts +3 -0
  6. package/src/locale/ro/ro.ts +3 -0
  7. package/src/locale/ru/ru.ts +3 -0
  8. package/src/locale/uk/uk.ts +3 -0
  9. package/src/locale/uz/uz.ts +3 -0
  10. package/src/locale/vi/vi.ts +3 -0
  11. package/src/shared/composables/__tests__/useChatScroll.spec.ts +164 -0
  12. package/src/shared/composables/__tests__/useObserveHeightUntilStable.spec.ts +48 -0
  13. package/src/{ui/messaging → shared}/composables/useChatScroll.ts +37 -9
  14. package/src/{ui/messaging → shared}/composables/useObserveHeightUntilStable.ts +2 -0
  15. package/src/ui/index.ts +2 -2
  16. package/src/ui/messaging/components/the-messages-container.vue +2 -2
  17. package/src/v2/index.ts +4 -0
  18. package/src/v2/locale/en.ts +29 -0
  19. package/src/v2/locale/es.ts +28 -0
  20. package/src/v2/locale/kz.ts +28 -0
  21. package/src/v2/locale/pl.ts +28 -0
  22. package/src/v2/locale/ro.ts +28 -0
  23. package/src/v2/locale/ru.ts +27 -0
  24. package/src/v2/locale/uk.ts +27 -0
  25. package/src/v2/locale/useChatsV2I18n.ts +14 -0
  26. package/src/v2/locale/uz.ts +28 -0
  27. package/src/v2/locale/vi.ts +28 -0
  28. package/src/v2/scripts/__tests__/attachments.spec.ts +168 -0
  29. package/src/v2/scripts/__tests__/fixtures.ts +56 -0
  30. package/src/v2/scripts/__tests__/formatDate.spec.ts +96 -0
  31. package/src/v2/scripts/__tests__/getMessageStatus.spec.ts +304 -0
  32. package/src/v2/scripts/__tests__/isContactCentreSide.spec.ts +21 -0
  33. package/src/v2/scripts/__tests__/resolveSystemNotice.spec.ts +157 -0
  34. package/src/v2/scripts/__tests__/toHistoryItems.spec.ts +100 -0
  35. package/src/v2/scripts/attachments.ts +144 -0
  36. package/src/v2/scripts/formatDate.ts +74 -0
  37. package/src/v2/scripts/getMessageStatus.ts +59 -0
  38. package/src/v2/scripts/isContactCentreSide.ts +14 -0
  39. package/src/v2/scripts/isSelfMessage.ts +29 -0
  40. package/src/v2/scripts/resolveSystemNotice.ts +119 -0
  41. package/src/v2/scripts/toHistoryItems.ts +63 -0
  42. package/src/v2/scripts/toTimestamp.ts +21 -0
  43. package/src/v2/types/index.ts +74 -0
  44. package/src/v2/ui/__tests__/mountWithChats.ts +38 -0
  45. package/src/v2/ui/chat-composer/__tests__/chat-composer.spec.ts +221 -0
  46. package/src/v2/ui/chat-composer/chat-composer.vue +212 -0
  47. package/src/v2/ui/chat-history/__tests__/chat-history.spec.ts +334 -0
  48. package/src/v2/ui/chat-history/chat-history.vue +262 -0
  49. package/src/v2/ui/chat-history/components/chat-date-divider.vue +36 -0
  50. package/src/v2/ui/chat-history/components/chat-message.vue +156 -0
  51. package/src/v2/ui/chat-history/components/chat-system-notice.vue +111 -0
  52. package/src/v2/ui/chat-history/components/message-attachments.vue +162 -0
  53. package/src/v2/ui/chat-history/components/message-status.vue +31 -0
  54. package/src/v2/ui/chat-history/components/message-text.vue +37 -0
  55. package/src/v2/ui/chat-history/components/scroll-to-bottom-btn.vue +55 -0
  56. package/src/v2/ui/chat-history/gallery.ts +8 -0
  57. package/src/v2/ui/chat-thread/__tests__/chat-thread.spec.ts +122 -0
  58. package/src/v2/ui/chat-thread/chat-thread.vue +111 -0
  59. package/types/.tsbuildinfo +1 -1
  60. package/types/locale/en/en.d.ts +25 -0
  61. package/types/locale/es/es.d.ts +25 -0
  62. package/types/locale/index.d.ts +225 -0
  63. package/types/locale/kz/kz.d.ts +25 -0
  64. package/types/locale/pl/pl.d.ts +25 -0
  65. package/types/locale/ro/ro.d.ts +25 -0
  66. package/types/locale/ru/ru.d.ts +25 -0
  67. package/types/locale/uk/uk.d.ts +25 -0
  68. package/types/locale/uz/uz.d.ts +25 -0
  69. package/types/locale/vi/vi.d.ts +25 -0
  70. package/types/{ui/messaging → shared}/composables/useChatScroll.d.ts +14 -4
  71. package/types/ui/index.d.ts +2 -2
  72. package/types/v2/index.d.ts +4 -0
  73. package/types/v2/locale/en.d.ts +27 -0
  74. package/types/v2/locale/es.d.ts +26 -0
  75. package/types/v2/locale/kz.d.ts +26 -0
  76. package/types/v2/locale/pl.d.ts +26 -0
  77. package/types/v2/locale/ro.d.ts +26 -0
  78. package/types/v2/locale/ru.d.ts +26 -0
  79. package/types/v2/locale/uk.d.ts +26 -0
  80. package/types/v2/locale/useChatsV2I18n.d.ts +5 -0
  81. package/types/v2/locale/uz.d.ts +26 -0
  82. package/types/v2/locale/vi.d.ts +26 -0
  83. package/types/v2/scripts/__tests__/fixtures.d.ts +7 -0
  84. package/types/v2/scripts/attachments.d.ts +30 -0
  85. package/types/v2/scripts/formatDate.d.ts +17 -0
  86. package/types/v2/scripts/getMessageStatus.d.ts +8 -0
  87. package/types/v2/scripts/isContactCentreSide.d.ts +8 -0
  88. package/types/v2/scripts/isSelfMessage.d.ts +10 -0
  89. package/types/v2/scripts/resolveSystemNotice.d.ts +23 -0
  90. package/types/v2/scripts/toHistoryItems.d.ts +19 -0
  91. package/types/v2/scripts/toTimestamp.d.ts +7 -0
  92. package/types/v2/types/index.d.ts +54 -0
  93. package/types/v2/ui/__tests__/mountWithChats.d.ts +8 -0
  94. package/types/v2/ui/chat-composer/chat-composer.vue.d.ts +31 -0
  95. package/types/v2/ui/chat-history/chat-history.vue.d.ts +11 -0
  96. package/types/v2/ui/chat-history/components/chat-date-divider.vue.d.ts +6 -0
  97. package/types/v2/ui/chat-history/components/chat-message.vue.d.ts +10 -0
  98. package/types/v2/ui/chat-history/components/chat-system-notice.vue.d.ts +9 -0
  99. package/types/v2/ui/chat-history/components/message-attachments.vue.d.ts +7 -0
  100. package/types/v2/ui/chat-history/components/message-status.vue.d.ts +7 -0
  101. package/types/v2/ui/chat-history/components/message-text.vue.d.ts +6 -0
  102. package/types/v2/ui/chat-history/components/scroll-to-bottom-btn.vue.d.ts +12 -0
  103. package/types/v2/ui/chat-history/gallery.d.ts +6 -0
  104. package/types/v2/ui/chat-thread/chat-thread.vue.d.ts +26 -0
  105. /package/src/{ui/messaging → shared}/composables/useScrollToBottomBtn.ts +0 -0
  106. /package/types/{ui/messaging → shared}/composables/useObserveHeightUntilStable.d.ts +0 -0
  107. /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>