@webitel/ui-chats 26.8.5 → 26.8.7

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": "26.8.5",
3
+ "version": "26.8.7",
4
4
  "description": "Reusable Webitel Frontend Code for Chats UI",
5
5
  "workspaces": [
6
6
  "../../",
@@ -40,6 +40,7 @@
40
40
  v-if="hasAction(ChatComposerAction.Emoji)"
41
41
  :popup-teleport-to="`#${composerId}`"
42
42
  :rounded="false"
43
+ variant="text"
43
44
  size="sm"
44
45
  :title="t('composer.emoji')"
45
46
  @insert-emoji="insertText"
@@ -54,6 +55,7 @@
54
55
  class="chat-composer__send"
55
56
  icon="chat-send"
56
57
  color="secondary"
58
+ size="sm"
57
59
  :loading="isSending"
58
60
  :disabled="isLocked || !canSend"
59
61
  :title="t('composer.send')"
@@ -331,4 +331,23 @@ describe('ChatHistory', () => {
331
331
  wrapper.find('.chat-history__sentinel').findAll('.wt-loader'),
332
332
  ).toHaveLength(0);
333
333
  });
334
+ it('renders the history-end slot after the last message, inside the scroller', () => {
335
+ const wrapper = mountWithChats(ChatHistory, {
336
+ props: {
337
+ thread: thread(),
338
+ messages: [
339
+ message(),
340
+ ],
341
+ selfMemberId: operator.id,
342
+ },
343
+ slots: {
344
+ 'history-end': '<button class="snooze" />',
345
+ },
346
+ });
347
+ const content = wrapper.find('.chat-history__content');
348
+ const last = content.element.lastElementChild;
349
+ expect(last?.querySelector('.snooze')).not.toBeNull();
350
+ // not an entry: the scroll anchor and the seen tracking skip it
351
+ expect(last?.classList.contains('chat-history__entry')).toBe(false);
352
+ });
334
353
  });
@@ -52,6 +52,15 @@
52
52
  >
53
53
  {{ t('history.waitingForOperator') }}
54
54
  </div>
55
+
56
+ <!-- after the newest message and scrolled with it; not an entry, so
57
+ neither the scroll anchor nor the seen tracking counts it -->
58
+ <div
59
+ v-if="slots['history-end']"
60
+ class="chat-history__end"
61
+ >
62
+ <slot name="history-end" />
63
+ </div>
55
64
  </div>
56
65
  </div>
57
66
 
@@ -109,6 +118,10 @@ const emit = defineEmits<{
109
118
  ];
110
119
  }>();
111
120
 
121
+ const slots = defineSlots<{
122
+ 'history-end'?: () => unknown;
123
+ }>();
124
+
112
125
  const { t } = useChatsV2I18n();
113
126
 
114
127
  const scrollContainer = useTemplateRef<HTMLElement>('scroll-container');
@@ -224,8 +237,7 @@ watch(
224
237
  width: 100%;
225
238
  overflow-x: hidden;
226
239
  overflow-y: auto;
227
- padding-right: var(--scrollbar-width);
228
- scrollbar-gutter: stable both-edges;
240
+ scrollbar-gutter: stable;
229
241
  }
230
242
 
231
243
  .chat-history__content {
@@ -233,6 +245,8 @@ watch(
233
245
  flex-direction: column;
234
246
  gap: var(--wt-ws-chat-window-sizes-root-gap);
235
247
  padding: var(--wt-ws-chat-window-sizes-root-padding-y) var(--wt-ws-chat-window-sizes-root-padding-x);
248
+ /* the scrollbar sits a root gap away from the messages, as in DES-730 */
249
+ padding-right: calc(var(--wt-ws-chat-window-sizes-root-padding-x) + var(--wt-ws-chat-window-sizes-root-gap));
236
250
  }
237
251
 
238
252
  .chat-history__sentinel {
@@ -244,6 +258,11 @@ watch(
244
258
  min-height: calc(var(--spacing-lg) * 2 + var(--icon-md-size));
245
259
  }
246
260
 
261
+ .chat-history__end {
262
+ display: flex;
263
+ justify-content: center;
264
+ }
265
+
247
266
  .chat-history__awaiting {
248
267
  display: flex;
249
268
  align-items: center;
@@ -33,4 +33,10 @@ const label = computed(() =>
33
33
  display: flex;
34
34
  justify-content: center;
35
35
  }
36
+
37
+ /* DES-730 draws the chip a step lighter than the default secondary; the
38
+ surface palette does not flip with the theme, so dark keeps the default */
39
+ :global(:root:not(.theme--dark)) .chat-date-divider {
40
+ --p-chip-secondary-background: var(--p-surface-50);
41
+ }
36
42
  </style>
@@ -40,12 +40,12 @@
40
40
  {{ t('history.unsupportedMessage') }}
41
41
  </p>
42
42
  </template>
43
- <div class="chat-message__meta typo-caption">
44
- <span v-if="time">{{ time }}</span>
43
+ <div class="chat-message__meta typo-body-2">
45
44
  <message-status
46
45
  v-if="status"
47
46
  :status="status"
48
47
  />
48
+ <span v-if="time">{{ time }}</span>
49
49
  </div>
50
50
  </div>
51
51
  </div>
@@ -104,6 +104,8 @@ const status = computed(() =>
104
104
 
105
105
  <style scoped>
106
106
  .chat-message {
107
+ --chat-message-tail-size: 8px;
108
+
107
109
  display: flex;
108
110
  align-items: flex-start;
109
111
  gap: var(--wt-ws-chat-window-sizes-message-item-gap);
@@ -122,25 +124,49 @@ const status = computed(() =>
122
124
  display: flex;
123
125
  flex-direction: column;
124
126
  gap: var(--wt-ws-chat-window-sizes-message-item-chat-message-gap);
127
+ position: relative;
125
128
  max-width: 70%;
126
129
  min-width: 0;
127
130
  padding: var(--wt-ws-chat-window-sizes-message-item-chat-message-padding-y) var(--wt-ws-chat-window-sizes-message-item-chat-message-padding-x);
128
131
  border-radius: var(--wt-ws-chat-window-sizes-message-item-chat-message-border-radius);
129
- background: var(--wt-ws-chat-window-colors-message-item-chat-message-client-background);
132
+ background: var(--chat-message-bubble-background);
130
133
  color: var(--wt-ws-chat-window-colors-message-item-chat-message-client-color);
134
+ --chat-message-bubble-background: var(--wt-ws-chat-window-colors-message-item-chat-message-client-background);
131
135
  }
132
136
 
133
- /* the corner next to the avatar is square, as in DES-730 */
137
+ /* the corner next to the avatar is square and carries an 8px tail, as in DES-730 */
134
138
  .chat-message:not(.chat-message--outgoing) .chat-message__bubble {
139
+ margin-left: var(--chat-message-tail-size);
135
140
  border-top-left-radius: 0;
136
141
  }
137
142
 
138
143
  .chat-message--outgoing .chat-message__bubble {
144
+ margin-right: var(--chat-message-tail-size);
139
145
  border-top-right-radius: 0;
140
- background: var(--wt-ws-chat-window-colors-message-item-chat-message-agent-background);
146
+ --chat-message-bubble-background: var(--wt-ws-chat-window-colors-message-item-chat-message-agent-background);
141
147
  color: var(--wt-ws-chat-window-colors-message-item-chat-message-agent-color);
142
148
  }
143
149
 
150
+ /* the tail is the bubble colour left over once a circle is cut out of the
151
+ square beside the bubble's square corner */
152
+ .chat-message__bubble::before {
153
+ position: absolute;
154
+ top: 0;
155
+ width: var(--chat-message-tail-size);
156
+ height: var(--chat-message-tail-size);
157
+ content: '';
158
+ }
159
+
160
+ .chat-message:not(.chat-message--outgoing) .chat-message__bubble::before {
161
+ right: 100%;
162
+ background: radial-gradient(circle 7.333px at 0.667px 7.333px, transparent 7.2px, var(--chat-message-bubble-background) 7.45px);
163
+ }
164
+
165
+ .chat-message--outgoing .chat-message__bubble::before {
166
+ left: 100%;
167
+ background: radial-gradient(circle 7.333px at 7.333px 7.333px, transparent 7.2px, var(--chat-message-bubble-background) 7.45px);
168
+ }
169
+
144
170
  .chat-message__placeholder {
145
171
  margin: 0;
146
172
  font-style: italic;
@@ -8,6 +8,7 @@
8
8
  </div>
9
9
  <wt-rounded-action
10
10
  icon="arrow-down"
11
+ size="sm"
11
12
  rounded
12
13
  @click="emit('scroll')"
13
14
  />
@@ -34,7 +35,7 @@ const emit = defineEmits<{
34
35
  <style scoped>
35
36
  .scroll-to-bottom-btn {
36
37
  position: absolute;
37
- right: calc(var(--scrollbar-width) + var(--spacing-xs));
38
+ right: calc(var(--scrollbar-width) + var(--wt-ws-chat-window-sizes-root-gap) + var(--spacing-xs));
38
39
  bottom: var(--spacing-xs);
39
40
  display: flex;
40
41
  flex-direction: column;
@@ -119,4 +119,17 @@ describe('ChatThread', () => {
119
119
  });
120
120
  expect(wrapper.find('.chat-composer .quick-reply').exists()).toBe(true);
121
121
  });
122
+ it('forwards the history-end slot to the history', () => {
123
+ const wrapper = mountWithChats(ChatThread, {
124
+ props: {
125
+ thread: thread(),
126
+ messages: [],
127
+ selfMemberId: operator.id,
128
+ },
129
+ slots: {
130
+ 'history-end': '<button class="snooze" />',
131
+ },
132
+ });
133
+ expect(wrapper.find('.chat-history .snooze').exists()).toBe(true);
134
+ });
122
135
  });
@@ -10,7 +10,14 @@
10
10
  :on-load-more="props.onLoadMore"
11
11
  :resolve-avatar-url="props.resolveAvatarUrl"
12
12
  @seen="emit('seen', $event)"
13
- />
13
+ >
14
+ <template
15
+ v-if="slots['history-end']"
16
+ #history-end
17
+ >
18
+ <slot name="history-end" />
19
+ </template>
20
+ </chat-history>
14
21
  <!-- keyed by thread: switching chats drops the draft and any pending state -->
15
22
  <chat-composer
16
23
  v-if="props.mode === ChatThreadMode.Active"
@@ -68,8 +75,9 @@ const emit = defineEmits<{
68
75
  ];
69
76
  }>();
70
77
 
71
- defineSlots<{
78
+ const slots = defineSlots<{
72
79
  actions?: (props: ChatComposerSlotProps) => unknown;
80
+ 'history-end'?: () => unknown;
73
81
  }>();
74
82
 
75
83
  const instance = getCurrentInstance();