stream-chat-react 10.1.2 → 10.2.0
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/dist/browser.full-bundle.js +166 -44
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +5 -5
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Attachment/AttachmentContainer.d.ts.map +1 -1
- package/dist/components/Attachment/AttachmentContainer.js +67 -15
- package/dist/components/Attachment/attachment-sizing.d.ts +9 -0
- package/dist/components/Attachment/attachment-sizing.d.ts.map +1 -0
- package/dist/components/Attachment/attachment-sizing.js +72 -0
- package/dist/components/Channel/Channel.d.ts +7 -1
- package/dist/components/Channel/Channel.d.ts.map +1 -1
- package/dist/components/Channel/Channel.js +2 -1
- package/dist/components/Channel/hooks/useCreateChannelStateContext.d.ts.map +1 -1
- package/dist/components/Channel/hooks/useCreateChannelStateContext.js +5 -1
- package/dist/components/Gallery/Gallery.d.ts +7 -2
- package/dist/components/Gallery/Gallery.d.ts.map +1 -1
- package/dist/components/Gallery/Gallery.js +16 -5
- package/dist/components/Gallery/Image.d.ts +4 -0
- package/dist/components/Gallery/Image.d.ts.map +1 -1
- package/dist/components/Gallery/Image.js +3 -3
- package/dist/components/MessageInput/hooks/useFileUploads.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useFileUploads.js +1 -0
- package/dist/components/MessageInput/hooks/useMessageInputState.d.ts +2 -0
- package/dist/components/MessageInput/hooks/useMessageInputState.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useMessageInputState.js +2 -1
- package/dist/components/MessageInput/hooks/useSubmitHandler.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useSubmitHandler.js +1 -0
- package/dist/components/MessageList/MessageList.d.ts.map +1 -1
- package/dist/components/MessageList/MessageList.js +1 -2
- package/dist/components/MessageList/VirtualizedMessageList.d.ts.map +1 -1
- package/dist/components/MessageList/VirtualizedMessageList.js +0 -1
- package/dist/components/MessageList/hooks/useMessageListElements.d.ts +0 -1
- package/dist/components/MessageList/hooks/useMessageListElements.d.ts.map +1 -1
- package/dist/components/MessageList/hooks/useMessageListElements.js +2 -3
- package/dist/components/MessageList/hooks/useScrollLocationLogic.d.ts +0 -1
- package/dist/components/MessageList/hooks/useScrollLocationLogic.d.ts.map +1 -1
- package/dist/components/MessageList/hooks/useScrollLocationLogic.js +0 -10
- package/dist/components/Thread/Thread.d.ts.map +1 -1
- package/dist/components/Thread/Thread.js +7 -2
- package/dist/context/ChannelStateContext.d.ts +5 -2
- package/dist/context/ChannelStateContext.d.ts.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/css/index.css.map +1 -1
- package/dist/css/v2/index.css +1 -1
- package/dist/css/v2/index.css.map +1 -1
- package/dist/css/v2/index.layout.css +1 -1
- package/dist/css/v2/index.layout.css.map +1 -1
- package/dist/index.cjs.js +166 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/scss/Attachment.scss +44 -17
- package/dist/scss/Audio.scss +1 -0
- package/dist/scss/Message.scss +28 -11
- package/dist/scss/v2/AttachmentList/AttachmentList-layout.scss +33 -19
- package/dist/scss/v2/Message/Message-layout.scss +12 -0
- package/dist/scss/v2/Message/Message-theme.scss +20 -0
- package/dist/scss/v2/MessageList/MessageList-layout.scss +1 -4
- package/dist/scss/v2/MessageList/VirtualizedMessageList-layout.scss +21 -0
- package/dist/scss/v2/MessageList/VirtualizedMessageList-theme.scss +9 -0
- package/dist/scss/v2/Notification/NotificationList-theme.scss +2 -2
- package/dist/scss/v2/_utils.scss +8 -0
- package/dist/stories/attachment-sizing.stories.d.ts +2 -0
- package/dist/stories/attachment-sizing.stories.d.ts.map +1 -0
- package/dist/stories/attachment-sizing.stories.js +179 -0
- package/dist/types/types.d.ts +9 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
@mixin clamped-height-from-original-image-dimensions($max-height-css-var, $max-width-css-var) {
|
|
2
|
+
height: min(
|
|
3
|
+
var(#{$max-height-css-var}),
|
|
4
|
+
min(var(#{$max-width-css-var}, 1000000) / var(--original-width, 1000000), 1px) *
|
|
5
|
+
var(--original-height, 1000000)
|
|
6
|
+
);
|
|
3
7
|
}
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
.str-chat__attachment,
|
|
10
|
+
.str-chat__message-attachment {
|
|
11
|
+
--attachment-max-width: 450px;
|
|
12
|
+
--video-width: 300px;
|
|
13
|
+
|
|
14
|
+
max-width: var(--attachment-max-width);
|
|
15
|
+
}
|
|
6
16
|
|
|
7
|
-
.str-chat__message-attachment--video:not(.str-chat__message-attachment--card) {
|
|
8
|
-
width:
|
|
17
|
+
.str-chat__message-attachment.str-chat__message-attachment--video:not(.str-chat__message-attachment--card) {
|
|
18
|
+
--attachment-max-width: var(--video-width);
|
|
19
|
+
width: var(--video-width);
|
|
9
20
|
}
|
|
10
21
|
|
|
11
22
|
.str-chat__player-wrapper {
|
|
12
23
|
position: relative;
|
|
13
24
|
padding-top: 56.25%; /* Player ratio: 100 / (1280 / 720) */
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
|
|
14
28
|
.react-player,
|
|
15
29
|
.str-chat__video-angular {
|
|
16
30
|
position: absolute;
|
|
@@ -18,23 +32,33 @@ $video-width: 300px;
|
|
|
18
32
|
left: 0;
|
|
19
33
|
width: 100%;
|
|
20
34
|
height: 100%;
|
|
35
|
+
min-height: 0;
|
|
36
|
+
max-height: 100%;
|
|
21
37
|
}
|
|
22
38
|
}
|
|
23
39
|
|
|
24
40
|
.str-chat__message-attachment-dynamic-size {
|
|
25
|
-
|
|
41
|
+
--video-max-height: 300px;
|
|
26
42
|
|
|
27
|
-
max-height:
|
|
43
|
+
max-height: var(--video-max-height);
|
|
28
44
|
|
|
29
45
|
.str-chat__player-wrapper {
|
|
46
|
+
@include clamped-height-from-original-image-dimensions(
|
|
47
|
+
'--video-max-height',
|
|
48
|
+
'--attachment-max-width'
|
|
49
|
+
);
|
|
30
50
|
padding-top: 0;
|
|
31
51
|
position: static;
|
|
52
|
+
// CDN resize requires to have max-height/height and max-width set on this element - React
|
|
53
|
+
max-height: var(--video-max-height);
|
|
54
|
+
max-width: var(--attachment-max-width);
|
|
32
55
|
|
|
33
|
-
.str-chat__video-angular
|
|
56
|
+
.str-chat__video-angular,
|
|
57
|
+
.react-player {
|
|
34
58
|
position: static;
|
|
35
|
-
// CDN resize requires to have max-height/height and max-width set on this element
|
|
36
|
-
max-height:
|
|
37
|
-
max-width:
|
|
59
|
+
// CDN resize requires to have max-height/height and max-width set on this element - Angular
|
|
60
|
+
max-height: var(--video-max-height);
|
|
61
|
+
max-width: var(--attachment-max-width);
|
|
38
62
|
}
|
|
39
63
|
}
|
|
40
64
|
}
|
|
@@ -52,8 +76,8 @@ $video-width: 300px;
|
|
|
52
76
|
|
|
53
77
|
.str-chat__message {
|
|
54
78
|
&-attachment {
|
|
79
|
+
--attachment-max-width: 375px;
|
|
55
80
|
width: 100%;
|
|
56
|
-
max-width: 375px;
|
|
57
81
|
|
|
58
82
|
border-radius: var(--border-radius);
|
|
59
83
|
padding: var(--xs-m) auto var(--xs-m) 0;
|
|
@@ -77,7 +101,7 @@ $video-width: 300px;
|
|
|
77
101
|
|
|
78
102
|
.str-chat__message-team.thread-list {
|
|
79
103
|
.str-chat__message-attachment {
|
|
80
|
-
max-width: 200px;
|
|
104
|
+
--attachment-max-width: 200px;
|
|
81
105
|
}
|
|
82
106
|
}
|
|
83
107
|
|
|
@@ -185,9 +209,9 @@ $video-width: 300px;
|
|
|
185
209
|
}
|
|
186
210
|
|
|
187
211
|
&--image {
|
|
188
|
-
height:
|
|
189
|
-
max-height:
|
|
190
|
-
max-width:
|
|
212
|
+
--image-max-height: 300px;
|
|
213
|
+
max-height: var(--image-max-height);
|
|
214
|
+
max-width: var(--attachment-max-width);
|
|
191
215
|
border-radius: 0;
|
|
192
216
|
|
|
193
217
|
&:hover {
|
|
@@ -195,7 +219,10 @@ $video-width: 300px;
|
|
|
195
219
|
}
|
|
196
220
|
|
|
197
221
|
img {
|
|
198
|
-
height
|
|
222
|
+
@include clamped-height-from-original-image-dimensions(
|
|
223
|
+
'--image-max-height',
|
|
224
|
+
'--attachment-max-width'
|
|
225
|
+
);
|
|
199
226
|
width: auto;
|
|
200
227
|
max-height: inherit;
|
|
201
228
|
display: block;
|
package/dist/scss/Audio.scss
CHANGED
package/dist/scss/Message.scss
CHANGED
|
@@ -8,6 +8,24 @@
|
|
|
8
8
|
*/
|
|
9
9
|
.str-chat__message-inner {
|
|
10
10
|
min-width: 0;
|
|
11
|
+
|
|
12
|
+
.str-chat__translation-notice {
|
|
13
|
+
button {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
padding: 0.25rem 0;
|
|
16
|
+
margin: 0;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
line-height: 16px;
|
|
19
|
+
color: var(--lighten-grey);
|
|
20
|
+
border: none;
|
|
21
|
+
background: none;
|
|
22
|
+
|
|
23
|
+
&:active,
|
|
24
|
+
&:hover {
|
|
25
|
+
background: var(--grey-whisper);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
11
29
|
}
|
|
12
30
|
|
|
13
31
|
.quoted-message {
|
|
@@ -417,11 +435,11 @@
|
|
|
417
435
|
}
|
|
418
436
|
|
|
419
437
|
&-attachment {
|
|
438
|
+
--attachment-max-width: 480px;
|
|
439
|
+
|
|
420
440
|
&--img {
|
|
421
441
|
width: 100%;
|
|
422
|
-
max-width: 480px;
|
|
423
442
|
display: block;
|
|
424
|
-
height: inherit;
|
|
425
443
|
cursor: -moz-zoom-in;
|
|
426
444
|
cursor: -webkit-zoom-in;
|
|
427
445
|
cursor: zoom-in;
|
|
@@ -525,7 +543,6 @@
|
|
|
525
543
|
// CDN resize requires max-width to be set on this element
|
|
526
544
|
max-width: inherit;
|
|
527
545
|
display: block;
|
|
528
|
-
height: inherit;
|
|
529
546
|
object-fit: cover;
|
|
530
547
|
border: none;
|
|
531
548
|
}
|
|
@@ -831,8 +848,8 @@
|
|
|
831
848
|
flex-direction: row-reverse;
|
|
832
849
|
}
|
|
833
850
|
|
|
834
|
-
.str-chat__message-attachment
|
|
835
|
-
max-width: 460px;
|
|
851
|
+
.str-chat__message-attachment {
|
|
852
|
+
--attachment-max-width: 460px;
|
|
836
853
|
}
|
|
837
854
|
|
|
838
855
|
&-text-inner {
|
|
@@ -1180,20 +1197,20 @@
|
|
|
1180
1197
|
}
|
|
1181
1198
|
|
|
1182
1199
|
@media screen and (max-width: 375px) {
|
|
1183
|
-
.str-chat__message .str-chat__message-attachment
|
|
1184
|
-
max-width: 235px;
|
|
1200
|
+
.str-chat__message .str-chat__message-attachment {
|
|
1201
|
+
--attachment-max-width: 235px;
|
|
1185
1202
|
}
|
|
1186
1203
|
}
|
|
1187
1204
|
|
|
1188
1205
|
@media screen and (max-width: 414px) {
|
|
1189
|
-
.str-chat__message .str-chat__message-attachment
|
|
1190
|
-
max-width:
|
|
1206
|
+
.str-chat__message .str-chat__message-attachment {
|
|
1207
|
+
--attachment-max-width: 235px;
|
|
1191
1208
|
}
|
|
1192
1209
|
}
|
|
1193
1210
|
|
|
1194
1211
|
@media only screen and (device-width: 375px) and (-webkit-device-pixel-ratio: 3) {
|
|
1195
|
-
.str-chat__message .str-chat__message-attachment
|
|
1196
|
-
max-width:
|
|
1212
|
+
.str-chat__message .str-chat__message-attachment {
|
|
1213
|
+
--attachment-max-width: 235px;
|
|
1197
1214
|
}
|
|
1198
1215
|
}
|
|
1199
1216
|
|
|
@@ -4,31 +4,23 @@
|
|
|
4
4
|
/* The margin applied to every attachment in the attachment list */
|
|
5
5
|
--str-chat__attachment-margin: var(--str-chat__spacing-0_5);
|
|
6
6
|
|
|
7
|
-
/* The maximum allowed width and height of attachments, in case of gallery images this is the maximum size of the whole gallery (not just for a single image inside the gallery). In case of Angular, there are some [constraints](https://getstream.io/chat/docs/sdk/angular/components/AttachmentListComponent/#maximum-size) for the acceptable values you can provide for this variable. */
|
|
8
|
-
--str-chat__attachment-max-width: unset;
|
|
9
|
-
|
|
10
|
-
/* The height of scraped images, the default value is optimized for 1.91:1 aspect ratio */
|
|
11
|
-
--str-chat__scraped-image-height: unset;
|
|
12
|
-
|
|
13
|
-
/* The height of scraped videos, the default value is optimized for 16:9 aspect ratio */
|
|
14
|
-
--str-chat__scraped-video-height: unset;
|
|
15
|
-
|
|
16
7
|
/* The height of GIFs */
|
|
17
8
|
--str-chat__gif-height: calc(var(--str-chat__spacing-px) * 200);
|
|
18
|
-
|
|
19
|
-
/* The height of videos, the default value is the mase as `--str-chat__attachment-max-width`. In Angular SDK this is the maximum height, the video can be smaller based on the aspect ratio */
|
|
20
|
-
--str-chat__video-height: unset;
|
|
21
9
|
}
|
|
22
10
|
|
|
23
11
|
.str-chat__attachment-list {
|
|
12
|
+
/* The maximum allowed width and height of attachments, in case of gallery images this is the maximum size of the whole gallery (not just for a single image inside the gallery). There are some constraints for the acceptable values you can provide for this variable, [Angular documentation](https://getstream.io/chat/docs/sdk/angular/components/AttachmentListComponent/#maximum-size), [React documentation](https://getstream.io/chat/docs/sdk/react/message-components/attachment/#image-and-video-sizing). */
|
|
24
13
|
--str-chat__attachment-max-width: calc(
|
|
25
14
|
var(--str-chat__message-max-width) - calc(2 * var(--str-chat__attachment-margin))
|
|
26
15
|
);
|
|
27
16
|
|
|
17
|
+
/* The maximum height of videos, the default value is the mase as `--str-chat__attachment-max-width`. The rendered video can be smaller based on the aspect ratio */
|
|
28
18
|
--str-chat__video-height: var(--str-chat__attachment-max-width);
|
|
29
19
|
|
|
20
|
+
/* The height of scraped images, the default value is optimized for 1.91:1 aspect ratio */
|
|
30
21
|
--str-chat__scraped-image-height: calc(var(--str-chat__attachment-max-width) * calc(1 / 1.91));
|
|
31
22
|
|
|
23
|
+
/* The height of scraped videos, the default value is optimized for 16:9 aspect ratio */
|
|
32
24
|
--str-chat__scraped-video-height: calc(var(--str-chat__attachment-max-width) * calc(9 / 16));
|
|
33
25
|
|
|
34
26
|
display: flex;
|
|
@@ -104,12 +96,16 @@
|
|
|
104
96
|
// Images uploaded from files
|
|
105
97
|
.str-chat__message-attachment--image:not(.str-chat__message-attachment--card) {
|
|
106
98
|
img {
|
|
99
|
+
@include utils.clamped-height-from-original-image-dimensions(
|
|
100
|
+
'--str-chat__attachment-max-width',
|
|
101
|
+
'--str-chat__attachment-max-width'
|
|
102
|
+
);
|
|
103
|
+
|
|
107
104
|
// CDN resize requires max-width and height/max-height to be present on this element
|
|
108
105
|
max-width: var(--str-chat__attachment-max-width);
|
|
109
106
|
max-height: var(--str-chat__attachment-max-width);
|
|
110
107
|
object-fit: cover;
|
|
111
108
|
width: 100%;
|
|
112
|
-
height: 100%;
|
|
113
109
|
cursor: zoom-in;
|
|
114
110
|
}
|
|
115
111
|
}
|
|
@@ -117,20 +113,27 @@
|
|
|
117
113
|
// Video files: uploaded from files and scraped
|
|
118
114
|
.str-chat__message-attachment--video:not(.str-chat__message-attachment--card),
|
|
119
115
|
.str-chat__message-attachment-card--video .str-chat__message-attachment-card--header {
|
|
120
|
-
|
|
116
|
+
$maxWidth: var(--str-chat__attachment-max-width);
|
|
117
|
+
max-width: $maxWidth;
|
|
121
118
|
display: flex;
|
|
122
119
|
|
|
123
120
|
.str-chat__player-wrapper {
|
|
124
121
|
height: 100%;
|
|
125
122
|
width: 100%;
|
|
126
123
|
min-width: 0;
|
|
124
|
+
// CDN resize requires max-width to be present on this element - React
|
|
125
|
+
max-width: $maxWidth;
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
127
128
|
|
|
128
129
|
.react-player,
|
|
129
130
|
.str-chat__video-angular {
|
|
130
131
|
height: 100%;
|
|
131
132
|
width: 100%;
|
|
132
|
-
// CDN resize requires max-width to be present on this element
|
|
133
|
-
max-width:
|
|
133
|
+
// CDN resize requires max-width to be present on this element - Angular
|
|
134
|
+
max-width: $maxWidth;
|
|
135
|
+
max-height: 100%;
|
|
136
|
+
min-height: 0;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
}
|
|
@@ -140,11 +143,22 @@
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
.str-chat__message-attachment--video.str-chat__message-attachment-dynamic-size:not(.str-chat__message-attachment--card) {
|
|
143
|
-
|
|
146
|
+
$maxHeight: var(--str-chat__video-height);
|
|
147
|
+
|
|
148
|
+
max-height: $maxHeight;
|
|
149
|
+
|
|
150
|
+
.str-chat__player-wrapper {
|
|
151
|
+
@include utils.clamped-height-from-original-image-dimensions(
|
|
152
|
+
'--str-chat__video-height',
|
|
153
|
+
'--str-chat__attachment-max-width'
|
|
154
|
+
);
|
|
155
|
+
// CDN resize requires max-height to be present on this element - React
|
|
156
|
+
max-height: $maxHeight;
|
|
157
|
+
}
|
|
144
158
|
|
|
145
159
|
.str-chat__video-angular {
|
|
146
|
-
// CDN resize requires max-height to be present on this element
|
|
147
|
-
max-height:
|
|
160
|
+
// CDN resize requires max-height to be present on this element - Angular
|
|
161
|
+
max-height: $maxHeight;
|
|
148
162
|
}
|
|
149
163
|
}
|
|
150
164
|
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
grid-template-areas:
|
|
72
72
|
'avatar message'
|
|
73
73
|
'. replies'
|
|
74
|
+
'. translation-notice'
|
|
74
75
|
'. metadata';
|
|
75
76
|
column-gap: var(--str-chat__spacing-2);
|
|
76
77
|
grid-template-columns: auto 1fr;
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
grid-template-areas:
|
|
82
83
|
'message'
|
|
83
84
|
'replies'
|
|
85
|
+
'translation-notice'
|
|
84
86
|
'metadata';
|
|
85
87
|
justify-items: end;
|
|
86
88
|
|
|
@@ -166,6 +168,16 @@
|
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
.str-chat__translation-notice {
|
|
172
|
+
grid-area: translation-notice;
|
|
173
|
+
|
|
174
|
+
button {
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
padding: var(--str-chat__spacing-1) 0;
|
|
177
|
+
margin: 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
169
181
|
.str-chat__message-metadata {
|
|
170
182
|
grid-area: metadata;
|
|
171
183
|
display: flex;
|
|
@@ -165,6 +165,12 @@
|
|
|
165
165
|
|
|
166
166
|
/* Box shadow applied to a date separator */
|
|
167
167
|
--str-chat__date-separator-box-shadow: none;
|
|
168
|
+
|
|
169
|
+
/* The text color of the translation notice that is displayed if a message is translated with auto-translation */
|
|
170
|
+
--str-chat__translation-notice-color: var(--str-chat__text-low-emphasis-color);
|
|
171
|
+
|
|
172
|
+
/* The hover color of the translation notice that is displayed if a message is translated with auto-translation */
|
|
173
|
+
--str-chat__translation-notice-active-background-color: var(--str-chat__tertiary-surface-color);
|
|
168
174
|
}
|
|
169
175
|
|
|
170
176
|
.str-chat__message--system {
|
|
@@ -237,6 +243,20 @@
|
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
245
|
|
|
246
|
+
.str-chat__translation-notice {
|
|
247
|
+
button {
|
|
248
|
+
font: var(--str-chat__body2-text);
|
|
249
|
+
color: var(--str-chat__translation-notice-color);
|
|
250
|
+
border: none;
|
|
251
|
+
background: none;
|
|
252
|
+
|
|
253
|
+
&:active,
|
|
254
|
+
&:hover {
|
|
255
|
+
background: var(--str-chat__translation-notice-active-background-color);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
240
260
|
.str-chat__message-metadata {
|
|
241
261
|
color: var(--str-chat__message-secondary-color);
|
|
242
262
|
font: var(--str-chat__caption-text);
|
|
@@ -32,12 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
.str-chat__thread-start {
|
|
34
34
|
text-align: start;
|
|
35
|
+
padding-top: var(--str-chat__spacing-3);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
.str-chat__parent-message-li .str-chat__thread-start {
|
|
39
|
-
padding-top: var(--str-chat__spacing-3);
|
|
40
|
-
}
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
.str-chat__jump-to-latest-message {
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
@include utils.message-list-spacing;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
.str-chat__parent-message-li {
|
|
18
|
+
padding-block-end: var(--str-chat__spacing-4);
|
|
19
|
+
|
|
20
|
+
.str-chat__thread-start {
|
|
21
|
+
text-align: start;
|
|
22
|
+
padding-top: var(--str-chat__spacing-3);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
// conditionally showing the header displaces items when prepending.
|
|
18
27
|
// a simple workaround is to make the loading indicator an overlay.
|
|
19
28
|
&__loading {
|
|
@@ -42,3 +51,15 @@
|
|
|
42
51
|
padding-block-end: var(--str-chat__spacing-0_5);
|
|
43
52
|
}
|
|
44
53
|
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
.str-chat__thread--virtualized {
|
|
57
|
+
.str-chat__main-panel-inner {
|
|
58
|
+
height: 100%;
|
|
59
|
+
|
|
60
|
+
// the first message in virtualized thread has to be separated from the top by padding, not margin
|
|
61
|
+
.str-chat__virtual-list-message-wrapper:first-of-type {
|
|
62
|
+
padding-block-start: var(--str-chat__spacing-4);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -29,4 +29,13 @@
|
|
|
29
29
|
|
|
30
30
|
.str-chat__virtual-list {
|
|
31
31
|
@include utils.component-layer-overrides('virtual-list');
|
|
32
|
+
|
|
33
|
+
.str-chat__parent-message-li {
|
|
34
|
+
border-block-end: 1px solid var(--str-chat__thread-head-start-border-block-end-color);
|
|
35
|
+
|
|
36
|
+
.str-chat__thread-start {
|
|
37
|
+
color: var(--str-chat__thread-head-start-color);
|
|
38
|
+
font: var(--str-chat__subtitle-text);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
32
41
|
}
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
--str-chat__notification-list-box-shadow: none;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.str-chat__list-
|
|
30
|
-
@include utils.component-layer-overrides('notification-list
|
|
29
|
+
.str-chat__list-notifications {
|
|
30
|
+
@include utils.component-layer-overrides('notification-list');
|
|
31
31
|
}
|
package/dist/scss/v2/_utils.scss
CHANGED
|
@@ -186,3 +186,11 @@
|
|
|
186
186
|
@mixin channel-preview-display-name-theme {
|
|
187
187
|
font: var(--str-chat__subtitle-medium-text);
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
@mixin clamped-height-from-original-image-dimensions($max-height-css-var, $max-width-css-var) {
|
|
191
|
+
height: min(
|
|
192
|
+
var(#{$max-height-css-var}),
|
|
193
|
+
min(var(#{$max-width-css-var}, 1000000) / var(--original-width, 1000000), 1px) *
|
|
194
|
+
var(--original-height, 1000000)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-sizing.stories.d.ts","sourceRoot":"","sources":["../../src/stories/attachment-sizing.stories.tsx"],"names":[],"mappings":"AA2LA,eAAO,MAAM,KAAK,mBAQjB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
49
|
+
import React, { useEffect } from 'react';
|
|
50
|
+
import { Channel, ChannelHeader, ChannelList, MessageList, Thread, useChannelActionContext, useChannelStateContext, useChatContext, Window, } from '../index';
|
|
51
|
+
import { ConnectedUser } from './utils';
|
|
52
|
+
var user1Id = import.meta.env.E2E_TEST_USER_1;
|
|
53
|
+
var user1Token = import.meta.env.E2E_TEST_USER_1_TOKEN;
|
|
54
|
+
var user2Id = import.meta.env.E2E_TEST_USER_2;
|
|
55
|
+
var user2Token = import.meta.env.E2E_TEST_USER_2_TOKEN;
|
|
56
|
+
var channelId = import.meta.env.E2E_ATTACHMENT_SIZING_CHANNEL;
|
|
57
|
+
if (!channelId || typeof channelId !== 'string') {
|
|
58
|
+
throw new Error('expected ADD_MESSAGE_CHANNEL');
|
|
59
|
+
}
|
|
60
|
+
var OtherUserControlButtons = function () {
|
|
61
|
+
var client = useChatContext().client;
|
|
62
|
+
var _a = useChannelStateContext(), channel = _a.channel, messages = _a.messages, threadMessages = _a.threadMessages;
|
|
63
|
+
var lastMessage = channel.state.messages.slice(-1)[0];
|
|
64
|
+
return (React.createElement(React.Fragment, null,
|
|
65
|
+
React.createElement("button", { "data-testid": 'receive-reply', onClick: function () {
|
|
66
|
+
return channel.sendMessage({
|
|
67
|
+
parent_id: lastMessage.id,
|
|
68
|
+
text: 'Reply back',
|
|
69
|
+
});
|
|
70
|
+
} }, "Receive reply"),
|
|
71
|
+
React.createElement("button", { "data-testid": 'delete-other-last-reply', onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var lastReply;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
lastReply = threadMessages === null || threadMessages === void 0 ? void 0 : threadMessages.slice(-1)[0];
|
|
77
|
+
if (!lastReply) return [3 /*break*/, 2];
|
|
78
|
+
return [4 /*yield*/, client.deleteMessage(lastReply.id, true)];
|
|
79
|
+
case 1:
|
|
80
|
+
_a.sent();
|
|
81
|
+
_a.label = 2;
|
|
82
|
+
case 2: return [2 /*return*/];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}); } }, "Delete other user's last reply"),
|
|
86
|
+
React.createElement("button", { "data-testid": 'add-other-user-message', onClick: function () {
|
|
87
|
+
return channel.sendMessage({
|
|
88
|
+
text: "Other user's message",
|
|
89
|
+
});
|
|
90
|
+
} }, "Receive a message"),
|
|
91
|
+
React.createElement("button", { "data-testid": 'delete-other-last-message', onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
92
|
+
var lastMessage;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
lastMessage = messages === null || messages === void 0 ? void 0 : messages.slice(-1)[0];
|
|
97
|
+
if (!lastMessage) return [3 /*break*/, 2];
|
|
98
|
+
return [4 /*yield*/, client.deleteMessage(lastMessage.id, true)];
|
|
99
|
+
case 1:
|
|
100
|
+
_a.sent();
|
|
101
|
+
_a.label = 2;
|
|
102
|
+
case 2: return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); } }, "Delete other user's last message")));
|
|
106
|
+
};
|
|
107
|
+
// Sort in reverse order to avoid auto-selecting unread channel
|
|
108
|
+
var sort = { last_updated: 1 };
|
|
109
|
+
var Controls = function () {
|
|
110
|
+
var client = useChatContext().client;
|
|
111
|
+
var threadMessages = useChannelStateContext().threadMessages;
|
|
112
|
+
return (React.createElement("div", null,
|
|
113
|
+
React.createElement("button", { "data-testid": 'delete-last-reply', onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
var lastReply;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
lastReply = threadMessages === null || threadMessages === void 0 ? void 0 : threadMessages.slice(-1)[0];
|
|
119
|
+
if (!lastReply) return [3 /*break*/, 2];
|
|
120
|
+
return [4 /*yield*/, client.deleteMessage(lastReply.id, true)];
|
|
121
|
+
case 1:
|
|
122
|
+
_a.sent();
|
|
123
|
+
_a.label = 2;
|
|
124
|
+
case 2: return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}); } }, "Delete last reply")));
|
|
128
|
+
};
|
|
129
|
+
var SetThreadOpen = function () {
|
|
130
|
+
var openThread = useChannelActionContext().openThread;
|
|
131
|
+
var messages = useChannelStateContext().messages;
|
|
132
|
+
useEffect(function () {
|
|
133
|
+
if (!messages)
|
|
134
|
+
return;
|
|
135
|
+
var lastMsg = messages.slice(-1)[0];
|
|
136
|
+
if (lastMsg)
|
|
137
|
+
openThread(lastMsg, { preventDefault: function () { return null; } });
|
|
138
|
+
}, [messages]);
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
var OtherUserControls = function () {
|
|
142
|
+
var theOtherUserCredentials = document.location.search.match('user1')
|
|
143
|
+
? { token: user2Token, userId: user2Id }
|
|
144
|
+
: { token: user1Token, userId: user1Id };
|
|
145
|
+
return (React.createElement("div", { className: theOtherUserCredentials.userId },
|
|
146
|
+
React.createElement("style", null, "\n .".concat(theOtherUserCredentials.userId, " .str-chat-channel {\n max-height: 30px;\n display: inline-block;\n }\n .").concat(theOtherUserCredentials.userId, " .str-chat__container {\n height: 30px;\n }\n\n .").concat(theOtherUserCredentials.userId, " .messaging.str-chat .str-chat__thread {\n display: none;\n }\n ")),
|
|
147
|
+
React.createElement(ConnectedUser, __assign({}, theOtherUserCredentials),
|
|
148
|
+
React.createElement("div", { style: { display: 'none' } },
|
|
149
|
+
React.createElement(ChannelList, { customActiveChannel: channelId, filters: { id: { $eq: channelId }, members: { $in: [theOtherUserCredentials.userId] } }, setActiveChannelOnMount: true, sort: sort })),
|
|
150
|
+
React.createElement("div", { style: { height: '30px' } },
|
|
151
|
+
React.createElement(Channel, null,
|
|
152
|
+
React.createElement(SetThreadOpen, null),
|
|
153
|
+
React.createElement(OtherUserControlButtons, null),
|
|
154
|
+
React.createElement(Thread, null))))));
|
|
155
|
+
};
|
|
156
|
+
var WrappedConnectedUser = function (_a) {
|
|
157
|
+
var token = _a.token, userId = _a.userId;
|
|
158
|
+
return (React.createElement("div", { style: { display: 'flex', flexDirection: 'column' } },
|
|
159
|
+
React.createElement("style", null, "\n\t \t.str-chat__thread .str-chat__message-data.str-chat__message-simple-data {\n\t\t\t visibility: hidden;\n\t\t}\n\t "),
|
|
160
|
+
React.createElement("div", { className: userId },
|
|
161
|
+
React.createElement(ConnectedUser, { token: token, userId: userId },
|
|
162
|
+
React.createElement(ChannelList, { filters: { id: { $eq: channelId }, members: { $in: [userId] } }, setActiveChannelOnMount: false, sort: sort }),
|
|
163
|
+
React.createElement(Channel, null,
|
|
164
|
+
React.createElement(Window, null,
|
|
165
|
+
React.createElement(ChannelHeader, null),
|
|
166
|
+
React.createElement(MessageList, null),
|
|
167
|
+
React.createElement(Controls, null)),
|
|
168
|
+
React.createElement(Thread, null)))),
|
|
169
|
+
React.createElement(OtherUserControls, null)));
|
|
170
|
+
};
|
|
171
|
+
export var User1 = function () {
|
|
172
|
+
if (!user1Id || typeof user1Id !== 'string') {
|
|
173
|
+
throw new Error('expected TEST_USER_1');
|
|
174
|
+
}
|
|
175
|
+
if (!user1Token || typeof user1Token !== 'string') {
|
|
176
|
+
throw new Error('expected TEST_USER_1_TOKEN');
|
|
177
|
+
}
|
|
178
|
+
return React.createElement(WrappedConnectedUser, { token: user1Token, userId: user1Id });
|
|
179
|
+
};
|