@linktr.ee/messaging-react 3.9.0-rc-1783472582 → 3.9.0-rc-1783575293
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/Card-B7ccxsKf.cjs +2 -0
- package/dist/Card-B7ccxsKf.cjs.map +1 -0
- package/dist/Card-CXRSSrCh.cjs +2 -0
- package/dist/Card-CXRSSrCh.cjs.map +1 -0
- package/dist/Card-DaUKmwtb.js +105 -0
- package/dist/Card-DaUKmwtb.js.map +1 -0
- package/dist/Card-Q1Ee_UCB.js +693 -0
- package/dist/Card-Q1Ee_UCB.js.map +1 -0
- package/dist/{LoadingDots-nW6r0-Kg.js → LoadingDots-Ct3WmVlT.js} +18 -21
- package/dist/LoadingDots-Ct3WmVlT.js.map +1 -0
- package/dist/LoadingDots-D9GGphgM.cjs +2 -0
- package/dist/LoadingDots-D9GGphgM.cjs.map +1 -0
- package/dist/assets/index.css +1 -1
- package/dist/{index-B8gqCioX.js → index-BiBvPADG.js} +1301 -1315
- package/dist/index-BiBvPADG.js.map +1 -0
- package/dist/index-DuPa2mUh.cjs +2 -0
- package/dist/index-DuPa2mUh.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +149 -129
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelList/CustomChannelPreview.test.tsx +95 -0
- package/src/components/ChannelList/CustomChannelPreview.tsx +21 -9
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/LockedAttachment.stories.tsx +87 -78
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/LockedAttachment.test.tsx +24 -11
- package/src/components/CustomMessage/LockedAttachment/components/Media/Card.tsx +358 -0
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/Media/CardActions.tsx +5 -0
- package/src/components/CustomMessage/LockedAttachment/components/Media/types.ts +79 -0
- package/src/components/CustomMessage/LockedAttachment/components/Text/Card.tsx +155 -0
- package/src/components/CustomMessage/LockedAttachment/components/Text/types.ts +58 -0
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/CardBody.tsx +5 -4
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/GalleryThumbnail.tsx +2 -2
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/LockBadge.tsx +1 -1
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/PurchaseStatusBadge.tsx +0 -12
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/SingleThumbnail.tsx +1 -1
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/SkeletonTextLines.tsx +3 -13
- package/src/components/CustomMessage/LockedAttachment/components/_shared/TextShell.tsx +30 -0
- package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/usePreviewToggle.test.ts +1 -1
- package/src/components/CustomMessage/LockedAttachment/index.tsx +105 -0
- package/src/components/CustomMessage/LockedAttachment/types.ts +44 -0
- package/src/components/CustomMessage/context.tsx +1 -1
- package/src/components/CustomMessage/index.tsx +45 -50
- package/src/components/CustomMessageInput/CustomMessageInput.stories.tsx +5 -3
- package/src/index.ts +3 -5
- package/src/styles.css +8 -1
- package/src/types.ts +1 -1
- package/dist/Card-BVZM0-06.js +0 -108
- package/dist/Card-BVZM0-06.js.map +0 -1
- package/dist/Card-D0hLrOxX.js +0 -221
- package/dist/Card-D0hLrOxX.js.map +0 -1
- package/dist/Card-DIr1UnfC.cjs +0 -2
- package/dist/Card-DIr1UnfC.cjs.map +0 -1
- package/dist/Card-DeSgaRTL.cjs +0 -2
- package/dist/Card-DeSgaRTL.cjs.map +0 -1
- package/dist/Card-DnaXMVrT.cjs +0 -2
- package/dist/Card-DnaXMVrT.cjs.map +0 -1
- package/dist/Card-xv52Ug43.js +0 -61
- package/dist/Card-xv52Ug43.js.map +0 -1
- package/dist/LoadingDots-Cn2y7g7L.cjs +0 -2
- package/dist/LoadingDots-Cn2y7g7L.cjs.map +0 -1
- package/dist/LoadingDots-nW6r0-Kg.js.map +0 -1
- package/dist/TextShell-CKQOFxoH.cjs +0 -2
- package/dist/TextShell-CKQOFxoH.cjs.map +0 -1
- package/dist/TextShell-DIyj9zQ7.js +0 -40
- package/dist/TextShell-DIyj9zQ7.js.map +0 -1
- package/dist/index-B8gqCioX.js.map +0 -1
- package/dist/index-IkikzyWM.cjs +0 -2
- package/dist/index-IkikzyWM.cjs.map +0 -1
- package/dist/usePreviewToggle-B0B8cfxy.cjs +0 -2
- package/dist/usePreviewToggle-B0B8cfxy.cjs.map +0 -1
- package/dist/usePreviewToggle-DRhRTUou.js +0 -357
- package/dist/usePreviewToggle-DRhRTUou.js.map +0 -1
- package/src/components/LockedAttachment/components/Composer/Card.tsx +0 -201
- package/src/components/LockedAttachment/components/Media/Card.tsx +0 -235
- package/src/components/LockedAttachment/components/Text/Card.tsx +0 -177
- package/src/components/LockedAttachment/components/_shared/TextShell.tsx +0 -19
- package/src/components/LockedAttachment/index.tsx +0 -52
- package/src/components/LockedAttachment/types.ts +0 -75
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/CardThumbnail.tsx +0 -0
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/LoadingDots.tsx +0 -0
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/MediaShell.tsx +0 -0
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/PreviewToggle.tsx +0 -0
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/PriceLockRow.tsx +0 -0
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/usePreviewToggle.ts +0 -0
- /package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/useReceivedSource.ts +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Meta, StoryFn } from '@storybook/react'
|
|
2
|
-
import classNames from 'classnames'
|
|
3
2
|
import React, { useState } from 'react'
|
|
4
3
|
import { MessageText } from 'stream-chat-react'
|
|
5
4
|
|
|
@@ -14,16 +13,16 @@ const meta: Meta = {
|
|
|
14
13
|
export default meta
|
|
15
14
|
|
|
16
15
|
const MatrixTable: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
17
|
-
<div className="
|
|
16
|
+
<div className="min-h-screen w-full bg-[#F9F7F4] p-12">
|
|
18
17
|
<table className="border-separate border-spacing-4">
|
|
19
18
|
<thead>
|
|
20
19
|
<tr>
|
|
21
20
|
<th className="w-8 pb-2" />
|
|
22
21
|
<th className="pb-2 text-left text-xs font-medium text-black/40">
|
|
23
|
-
|
|
22
|
+
Visitor
|
|
24
23
|
</th>
|
|
25
24
|
<th className="pb-2 text-left text-xs font-medium text-black/40">
|
|
26
|
-
|
|
25
|
+
Creator
|
|
27
26
|
</th>
|
|
28
27
|
</tr>
|
|
29
28
|
</thead>
|
|
@@ -51,29 +50,16 @@ const MatrixTableRow: React.FC<{
|
|
|
51
50
|
)
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
53
|
+
* Deliberately renders WITHOUT any `.str-chat` ancestor or
|
|
54
|
+
* `str-chat__message*` structure — the real Composer/preview surfaces this
|
|
55
|
+
* card renders in outside a message thread. If a card looks wrong here, it's
|
|
56
|
+
* leaning on ambient stream-chat-react CSS instead of its own explicit
|
|
57
|
+
* styling.
|
|
59
58
|
*/
|
|
60
59
|
const MatrixTableCell: React.FC<{
|
|
61
60
|
isMine: boolean
|
|
62
61
|
children: React.ReactNode
|
|
63
|
-
}> = ({
|
|
64
|
-
<div
|
|
65
|
-
className={classNames(
|
|
66
|
-
'str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received has-no-text',
|
|
67
|
-
isMine
|
|
68
|
-
? 'str-chat__message--me str-chat__message-simple--me'
|
|
69
|
-
: 'str-chat__message--other'
|
|
70
|
-
)}
|
|
71
|
-
>
|
|
72
|
-
<div className="str-chat__message-inner">
|
|
73
|
-
<div className="str-chat__message-bubble-wrapper">{children}</div>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
)
|
|
62
|
+
}> = ({ children }) => <div>{children}</div>
|
|
77
63
|
|
|
78
64
|
export const Text: StoryFn = () => {
|
|
79
65
|
const [isUnlocking, setUnlocking] = useState(false)
|
|
@@ -89,33 +75,35 @@ export const Text: StoryFn = () => {
|
|
|
89
75
|
return (
|
|
90
76
|
<MatrixTable>
|
|
91
77
|
<MatrixTableRow
|
|
92
|
-
label="
|
|
78
|
+
label="Draft"
|
|
93
79
|
received={null}
|
|
94
80
|
sent={
|
|
95
|
-
<LockedAttachment
|
|
81
|
+
<LockedAttachment
|
|
82
|
+
isDraft
|
|
96
83
|
contentType="text"
|
|
97
|
-
|
|
84
|
+
renderedText={purchasedMessage?.text}
|
|
85
|
+
amountText="AU$4.99"
|
|
98
86
|
onDismiss={() => alert('Removed')}
|
|
99
87
|
/>
|
|
100
88
|
}
|
|
101
89
|
/>
|
|
102
90
|
<MatrixTableRow
|
|
103
|
-
label="
|
|
91
|
+
label="Preview"
|
|
104
92
|
received={null}
|
|
105
93
|
sent={
|
|
106
|
-
<LockedAttachment
|
|
94
|
+
<LockedAttachment
|
|
95
|
+
isPreview
|
|
107
96
|
contentType="text"
|
|
108
|
-
|
|
109
|
-
amountText="AU$4.99"
|
|
110
|
-
onDismiss={() => alert('Removed')}
|
|
97
|
+
placeholderAmountText="AU$0.00"
|
|
111
98
|
/>
|
|
112
99
|
}
|
|
113
100
|
/>
|
|
114
101
|
<MatrixTableRow
|
|
115
102
|
label="Idle"
|
|
116
103
|
received={
|
|
117
|
-
<LockedAttachment
|
|
104
|
+
<LockedAttachment
|
|
118
105
|
isMine={false}
|
|
106
|
+
contentType="text"
|
|
119
107
|
amountText="AU$4.99"
|
|
120
108
|
isUnlocking={isUnlocking}
|
|
121
109
|
onUnlockClick={() => {
|
|
@@ -125,8 +113,9 @@ export const Text: StoryFn = () => {
|
|
|
125
113
|
/>
|
|
126
114
|
}
|
|
127
115
|
sent={
|
|
128
|
-
<LockedAttachment
|
|
116
|
+
<LockedAttachment
|
|
129
117
|
isMine
|
|
118
|
+
contentType="text"
|
|
130
119
|
amountText="AU$4.99"
|
|
131
120
|
paymentStatus="pending"
|
|
132
121
|
/>
|
|
@@ -135,8 +124,9 @@ export const Text: StoryFn = () => {
|
|
|
135
124
|
<MatrixTableRow
|
|
136
125
|
label="Unlocking"
|
|
137
126
|
received={
|
|
138
|
-
<LockedAttachment
|
|
127
|
+
<LockedAttachment
|
|
139
128
|
isMine={false}
|
|
129
|
+
contentType="text"
|
|
140
130
|
amountText="AU$4.99"
|
|
141
131
|
isUnlocking
|
|
142
132
|
/>
|
|
@@ -146,22 +136,22 @@ export const Text: StoryFn = () => {
|
|
|
146
136
|
<MatrixTableRow
|
|
147
137
|
label="Purchased"
|
|
148
138
|
received={
|
|
149
|
-
<LockedAttachment
|
|
139
|
+
<LockedAttachment
|
|
150
140
|
isMine={false}
|
|
141
|
+
contentType="text"
|
|
151
142
|
amountText="AU$4.99"
|
|
152
143
|
paymentStatus="paid"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</LockedAttachment.Text>
|
|
144
|
+
renderedText={<MessageText message={purchasedMessage} />}
|
|
145
|
+
/>
|
|
156
146
|
}
|
|
157
147
|
sent={
|
|
158
|
-
<LockedAttachment
|
|
148
|
+
<LockedAttachment
|
|
159
149
|
isMine
|
|
150
|
+
contentType="text"
|
|
160
151
|
amountText="AU$4.99"
|
|
161
152
|
paymentStatus="paid"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
</LockedAttachment.Text>
|
|
153
|
+
renderedText={<MessageText message={purchasedMessage} />}
|
|
154
|
+
/>
|
|
165
155
|
}
|
|
166
156
|
/>
|
|
167
157
|
</MatrixTable>
|
|
@@ -172,6 +162,10 @@ const VIDEO_THUMBNAIL_BLURRED = '/video-thumbnail-blurred.jpg'
|
|
|
172
162
|
const VIDEO_THUMBNAIL = '/video-thumbnail.jpg'
|
|
173
163
|
const VIDEO_SOURCE = '/video-source.mp4'
|
|
174
164
|
|
|
165
|
+
const AUDIO_THUMBNAIL_BLURRED = '/audio-thumbnail-blurred.jpg'
|
|
166
|
+
const AUDIO_THUMBNAIL = '/audio-thumbnail.jpg'
|
|
167
|
+
const AUDIO_SOURCE = '/audio-source.mp3'
|
|
168
|
+
|
|
175
169
|
const IMAGE_THUMBNAIL_BLURRED = '/image-thumbnail-blurred.jpg'
|
|
176
170
|
const IMAGE_THUMBNAIL = '/image-thumbnail.jpg'
|
|
177
171
|
const IMAGE_SOURCE = '/image-source.jpg'
|
|
@@ -180,10 +174,6 @@ const DOCUMENT_THUMBNAIL_BLURRED = '/document-thumbnail-blurred.jpg'
|
|
|
180
174
|
const DOCUMENT_THUMBNAIL = '/document-thumbnail.jpg'
|
|
181
175
|
const DOCUMENT_SOURCE = '/document-source.pdf'
|
|
182
176
|
|
|
183
|
-
const AUDIO_THUMBNAIL_BLURRED = '/audio-thumbnail-blurred.jpg'
|
|
184
|
-
const AUDIO_THUMBNAIL = '/audio-thumbnail.jpg'
|
|
185
|
-
const AUDIO_SOURCE = '/audio-source.mp3'
|
|
186
|
-
|
|
187
177
|
const VARIANTS = [
|
|
188
178
|
{
|
|
189
179
|
label: 'Video',
|
|
@@ -234,8 +224,8 @@ const VARIANTS = [
|
|
|
234
224
|
|
|
235
225
|
/**
|
|
236
226
|
* A mixed-media collection (a video + 3 photos) used by the Gallery stories
|
|
237
|
-
* below.
|
|
238
|
-
*
|
|
227
|
+
* below. `LockedAttachment` accepts a `gallery` prop and renders a carousel
|
|
228
|
+
* of these items when 2+ items are provided.
|
|
239
229
|
*/
|
|
240
230
|
const GALLERY_ITEMS: LockedAttachmentGalleryItem[] = [
|
|
241
231
|
{
|
|
@@ -260,7 +250,7 @@ const GALLERY_ITEMS: LockedAttachmentGalleryItem[] = [
|
|
|
260
250
|
},
|
|
261
251
|
]
|
|
262
252
|
|
|
263
|
-
const GALLERY_DETAIL = '
|
|
253
|
+
const GALLERY_DETAIL = '4 items'
|
|
264
254
|
const GALLERY_TITLE = 'Workout Guide'
|
|
265
255
|
|
|
266
256
|
const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
|
|
@@ -285,41 +275,45 @@ const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
|
|
|
285
275
|
return (
|
|
286
276
|
<MatrixTable>
|
|
287
277
|
<MatrixTableRow
|
|
288
|
-
label="
|
|
278
|
+
label="Draft"
|
|
289
279
|
received={null}
|
|
290
280
|
sent={
|
|
291
|
-
<LockedAttachment
|
|
292
|
-
|
|
293
|
-
|
|
281
|
+
<LockedAttachment
|
|
282
|
+
isDraft
|
|
283
|
+
title={title}
|
|
294
284
|
thumbnailUrl={thumbnailUrl}
|
|
285
|
+
contentType="media"
|
|
295
286
|
mimeType={mimeType}
|
|
296
287
|
detail={detail}
|
|
297
|
-
|
|
288
|
+
amountText="AU$9.99"
|
|
289
|
+
onDismiss={() => alert('Dismissed')}
|
|
298
290
|
/>
|
|
299
291
|
}
|
|
300
292
|
/>
|
|
301
293
|
<MatrixTableRow
|
|
302
|
-
label="
|
|
294
|
+
label="Preview"
|
|
303
295
|
received={null}
|
|
304
296
|
sent={
|
|
305
|
-
<LockedAttachment
|
|
306
|
-
|
|
297
|
+
<LockedAttachment
|
|
298
|
+
isPreview
|
|
299
|
+
placeholderTitle="Attachment title"
|
|
300
|
+
placeholderAmountText="AU$0.00"
|
|
307
301
|
thumbnailUrl={thumbnailUrl}
|
|
308
302
|
mimeType={mimeType}
|
|
303
|
+
contentType="media"
|
|
309
304
|
detail={detail}
|
|
310
|
-
amountText="AU$9.99"
|
|
311
|
-
onDismiss={() => alert('Dismissed')}
|
|
312
305
|
/>
|
|
313
306
|
}
|
|
314
307
|
/>
|
|
315
308
|
<MatrixTableRow
|
|
316
309
|
label="Idle"
|
|
317
310
|
received={
|
|
318
|
-
<LockedAttachment
|
|
311
|
+
<LockedAttachment
|
|
319
312
|
isMine={false}
|
|
320
313
|
title={title}
|
|
321
314
|
thumbnailUrl={thumbnailUrl}
|
|
322
315
|
mimeType={mimeType}
|
|
316
|
+
contentType="media"
|
|
323
317
|
detail={detail}
|
|
324
318
|
amountText="AU$9.99"
|
|
325
319
|
paymentStatus={isPaid ? 'paid' : undefined}
|
|
@@ -336,11 +330,12 @@ const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
|
|
|
336
330
|
/>
|
|
337
331
|
}
|
|
338
332
|
sent={
|
|
339
|
-
<LockedAttachment
|
|
333
|
+
<LockedAttachment
|
|
340
334
|
isMine
|
|
341
335
|
title={title}
|
|
342
336
|
thumbnailUrl={thumbnailUrl}
|
|
343
337
|
mimeType={mimeType}
|
|
338
|
+
contentType="media"
|
|
344
339
|
detail={detail}
|
|
345
340
|
amountText="AU$9.99"
|
|
346
341
|
onFetchSource={fetchSource}
|
|
@@ -350,11 +345,12 @@ const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
|
|
|
350
345
|
<MatrixTableRow
|
|
351
346
|
label="Unlocking"
|
|
352
347
|
received={
|
|
353
|
-
<LockedAttachment
|
|
348
|
+
<LockedAttachment
|
|
354
349
|
isMine={false}
|
|
355
350
|
title={title}
|
|
356
351
|
thumbnailUrl={thumbnailUrl}
|
|
357
352
|
mimeType={mimeType}
|
|
353
|
+
contentType="media"
|
|
358
354
|
detail={detail}
|
|
359
355
|
amountText="AU$9.99"
|
|
360
356
|
isUnlocking
|
|
@@ -368,11 +364,12 @@ const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
|
|
|
368
364
|
<MatrixTableRow
|
|
369
365
|
label="Purchased"
|
|
370
366
|
received={
|
|
371
|
-
<LockedAttachment
|
|
367
|
+
<LockedAttachment
|
|
372
368
|
isMine={false}
|
|
373
369
|
title={title}
|
|
374
370
|
thumbnailUrl={thumbnailUrl}
|
|
375
371
|
mimeType={mimeType}
|
|
372
|
+
contentType="media"
|
|
376
373
|
detail={detail}
|
|
377
374
|
amountText="AU$9.99"
|
|
378
375
|
paymentStatus="paid"
|
|
@@ -382,11 +379,12 @@ const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
|
|
|
382
379
|
/>
|
|
383
380
|
}
|
|
384
381
|
sent={
|
|
385
|
-
<LockedAttachment
|
|
382
|
+
<LockedAttachment
|
|
386
383
|
isMine
|
|
387
384
|
title={title}
|
|
388
385
|
thumbnailUrl={thumbnailUrl}
|
|
389
386
|
mimeType={mimeType}
|
|
387
|
+
contentType="media"
|
|
390
388
|
detail={detail}
|
|
391
389
|
amountText="AU$9.99"
|
|
392
390
|
paymentStatus="paid"
|
|
@@ -404,7 +402,7 @@ const variantByLabel = (label: string) =>
|
|
|
404
402
|
export const Video: StoryFn = () => (
|
|
405
403
|
<MediaMatrix variant={variantByLabel('Video')} />
|
|
406
404
|
)
|
|
407
|
-
// LockedAttachment
|
|
405
|
+
// LockedAttachment (contentType="media", !isMine) autoplays the video preview once paid; even with
|
|
408
406
|
// our SMIL/CSS animation freeze the <video> element advances frames
|
|
409
407
|
// independently and produces a non-deterministic snapshot. Skip in Chromatic.
|
|
410
408
|
Video.parameters = { chromatic: { disableSnapshot: true } }
|
|
@@ -432,34 +430,41 @@ export const Gallery: StoryFn = () => {
|
|
|
432
430
|
return (
|
|
433
431
|
<MatrixTable>
|
|
434
432
|
<MatrixTableRow
|
|
435
|
-
label="
|
|
433
|
+
label="Draft"
|
|
436
434
|
received={null}
|
|
437
435
|
sent={
|
|
438
|
-
<LockedAttachment
|
|
436
|
+
<LockedAttachment
|
|
437
|
+
isDraft
|
|
438
|
+
contentType="media"
|
|
439
|
+
title={GALLERY_TITLE}
|
|
439
440
|
detail={GALLERY_DETAIL}
|
|
441
|
+
amountText="AU$50.00"
|
|
440
442
|
gallery={GALLERY_ITEMS}
|
|
443
|
+
onDismiss={() => alert('Dismissed gallery')}
|
|
444
|
+
onEditClick={() => alert('Edit gallery')}
|
|
441
445
|
/>
|
|
442
446
|
}
|
|
443
447
|
/>
|
|
444
448
|
<MatrixTableRow
|
|
445
|
-
label="
|
|
449
|
+
label="Preview"
|
|
446
450
|
received={null}
|
|
447
451
|
sent={
|
|
448
|
-
<LockedAttachment
|
|
449
|
-
|
|
452
|
+
<LockedAttachment
|
|
453
|
+
isPreview
|
|
454
|
+
contentType="media"
|
|
455
|
+
placeholderTitle="Attachment title"
|
|
450
456
|
detail={GALLERY_DETAIL}
|
|
451
|
-
|
|
457
|
+
placeholderAmountText="AU$0.00"
|
|
452
458
|
gallery={GALLERY_ITEMS}
|
|
453
|
-
onDismiss={() => alert('Dismissed gallery')}
|
|
454
|
-
onEditClick={() => alert('Edit gallery')}
|
|
455
459
|
/>
|
|
456
460
|
}
|
|
457
461
|
/>
|
|
458
462
|
<MatrixTableRow
|
|
459
463
|
label="Idle"
|
|
460
464
|
received={
|
|
461
|
-
<LockedAttachment
|
|
465
|
+
<LockedAttachment
|
|
462
466
|
isMine={false}
|
|
467
|
+
contentType="media"
|
|
463
468
|
title={GALLERY_TITLE}
|
|
464
469
|
detail={GALLERY_DETAIL}
|
|
465
470
|
amountText="AU$50.00"
|
|
@@ -477,8 +482,9 @@ export const Gallery: StoryFn = () => {
|
|
|
477
482
|
/>
|
|
478
483
|
}
|
|
479
484
|
sent={
|
|
480
|
-
<LockedAttachment
|
|
485
|
+
<LockedAttachment
|
|
481
486
|
isMine
|
|
487
|
+
contentType="media"
|
|
482
488
|
title={GALLERY_TITLE}
|
|
483
489
|
detail={GALLERY_DETAIL}
|
|
484
490
|
amountText="AU$50.00"
|
|
@@ -489,8 +495,9 @@ export const Gallery: StoryFn = () => {
|
|
|
489
495
|
<MatrixTableRow
|
|
490
496
|
label="Unlocking"
|
|
491
497
|
received={
|
|
492
|
-
<LockedAttachment
|
|
498
|
+
<LockedAttachment
|
|
493
499
|
isMine={false}
|
|
500
|
+
contentType="media"
|
|
494
501
|
title={GALLERY_TITLE}
|
|
495
502
|
detail={GALLERY_DETAIL}
|
|
496
503
|
amountText="AU$50.00"
|
|
@@ -505,8 +512,9 @@ export const Gallery: StoryFn = () => {
|
|
|
505
512
|
<MatrixTableRow
|
|
506
513
|
label="Purchased"
|
|
507
514
|
received={
|
|
508
|
-
<LockedAttachment
|
|
515
|
+
<LockedAttachment
|
|
509
516
|
isMine={false}
|
|
517
|
+
contentType="media"
|
|
510
518
|
title={GALLERY_TITLE}
|
|
511
519
|
detail={GALLERY_DETAIL}
|
|
512
520
|
amountText="AU$50.00"
|
|
@@ -517,8 +525,9 @@ export const Gallery: StoryFn = () => {
|
|
|
517
525
|
/>
|
|
518
526
|
}
|
|
519
527
|
sent={
|
|
520
|
-
<LockedAttachment
|
|
528
|
+
<LockedAttachment
|
|
521
529
|
isMine
|
|
530
|
+
contentType="media"
|
|
522
531
|
title={GALLERY_TITLE}
|
|
523
532
|
detail={GALLERY_DETAIL}
|
|
524
533
|
amountText="AU$50.00"
|
package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/LockedAttachment.test.tsx
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest'
|
|
2
2
|
|
|
3
|
-
import { renderWithProviders, screen } from '
|
|
3
|
+
import { renderWithProviders, screen } from '../../../test/utils'
|
|
4
4
|
|
|
5
|
-
import ComposerCard from './components/Composer/Card'
|
|
6
5
|
import MediaCard from './components/Media/Card'
|
|
7
6
|
import TextCard from './components/Text/Card'
|
|
8
7
|
|
|
@@ -14,15 +13,15 @@ import TextCard from './components/Text/Card'
|
|
|
14
13
|
* around. Storybook remains the pixel-level visual oracle.
|
|
15
14
|
*/
|
|
16
15
|
describe('LockedAttachment (characterization)', () => {
|
|
17
|
-
describe('
|
|
16
|
+
describe('Draft', () => {
|
|
18
17
|
it('media mode: shows the placeholder title when locked with no title', () => {
|
|
19
|
-
renderWithProviders(<
|
|
18
|
+
renderWithProviders(<MediaCard isDraft />)
|
|
20
19
|
expect(screen.getByText('Attachment title')).toBeInTheDocument()
|
|
21
20
|
})
|
|
22
21
|
|
|
23
22
|
it('media mode: renders a preview toggle when a source fetcher is wired', () => {
|
|
24
23
|
renderWithProviders(
|
|
25
|
-
<
|
|
24
|
+
<MediaCard isDraft onFetchSource={vi.fn().mockResolvedValue(undefined)} />
|
|
26
25
|
)
|
|
27
26
|
expect(
|
|
28
27
|
screen.getByRole('button', { name: 'Toggle preview' })
|
|
@@ -30,7 +29,7 @@ describe('LockedAttachment (characterization)', () => {
|
|
|
30
29
|
})
|
|
31
30
|
|
|
32
31
|
it('media mode: renders a dismiss control when onDismiss is provided', () => {
|
|
33
|
-
renderWithProviders(<
|
|
32
|
+
renderWithProviders(<MediaCard isDraft onDismiss={vi.fn()} />)
|
|
34
33
|
expect(
|
|
35
34
|
screen.getByRole('button', { name: 'Dismiss attachment' })
|
|
36
35
|
).toBeInTheDocument()
|
|
@@ -38,13 +37,27 @@ describe('LockedAttachment (characterization)', () => {
|
|
|
38
37
|
|
|
39
38
|
it('text mode: shows the draft text and amount', () => {
|
|
40
39
|
renderWithProviders(
|
|
41
|
-
<
|
|
40
|
+
<TextCard isDraft amountText="$5" renderedText="Secret draft" />
|
|
42
41
|
)
|
|
43
42
|
expect(screen.getByText('Secret draft')).toBeInTheDocument()
|
|
44
43
|
expect(screen.getByText('$5')).toBeInTheDocument()
|
|
45
44
|
})
|
|
46
45
|
})
|
|
47
46
|
|
|
47
|
+
describe('Preview', () => {
|
|
48
|
+
it('media mode: shows the placeholder title when locked with no title', () => {
|
|
49
|
+
renderWithProviders(<MediaCard isPreview amountText="$5" />)
|
|
50
|
+
expect(screen.getByText('Attachment title')).toBeInTheDocument()
|
|
51
|
+
expect(screen.getByText('$5')).toBeInTheDocument()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('text mode: never shows real text, only the amount', () => {
|
|
55
|
+
renderWithProviders(<TextCard isPreview amountText="$5" />)
|
|
56
|
+
expect(screen.queryByText('Secret draft')).not.toBeInTheDocument()
|
|
57
|
+
expect(screen.getByText('$5')).toBeInTheDocument()
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
48
61
|
describe('Media (isMine)', () => {
|
|
49
62
|
it('shows the amount in the status badge', () => {
|
|
50
63
|
renderWithProviders(<MediaCard isMine amountText="$5" />)
|
|
@@ -53,11 +66,11 @@ describe('LockedAttachment (characterization)', () => {
|
|
|
53
66
|
})
|
|
54
67
|
|
|
55
68
|
describe('Text (isMine)', () => {
|
|
56
|
-
it('pending: shows the
|
|
69
|
+
it('pending: shows the amount with no status label', () => {
|
|
57
70
|
renderWithProviders(
|
|
58
71
|
<TextCard isMine amountText="$5" paymentStatus="pending" />
|
|
59
72
|
)
|
|
60
|
-
expect(screen.
|
|
73
|
+
expect(screen.queryByText('Sent')).not.toBeInTheDocument()
|
|
61
74
|
expect(screen.getByText('$5')).toBeInTheDocument()
|
|
62
75
|
})
|
|
63
76
|
|
|
@@ -87,7 +100,7 @@ describe('LockedAttachment (characterization)', () => {
|
|
|
87
100
|
<TextCard isMine={false} amountText="$5" onUnlockClick={vi.fn()} />
|
|
88
101
|
)
|
|
89
102
|
expect(
|
|
90
|
-
screen.getByRole('button', { name: 'Unlock' })
|
|
103
|
+
screen.getByRole('button', { name: 'Unlock message' })
|
|
91
104
|
).toBeInTheDocument()
|
|
92
105
|
expect(screen.getByText('$5')).toBeInTheDocument()
|
|
93
106
|
})
|
|
@@ -96,7 +109,7 @@ describe('LockedAttachment (characterization)', () => {
|
|
|
96
109
|
renderWithProviders(
|
|
97
110
|
<TextCard isMine={false} isUnlocking onUnlockClick={vi.fn()} />
|
|
98
111
|
)
|
|
99
|
-
const button = screen.getByRole('button', { name: 'Unlocking' })
|
|
112
|
+
const button = screen.getByRole('button', { name: 'Unlocking message' })
|
|
100
113
|
expect(button).toBeDisabled()
|
|
101
114
|
expect(button).toHaveAttribute('aria-busy', 'true')
|
|
102
115
|
})
|