@linktr.ee/messaging-react 1.37.0 → 1.38.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/Card-DwgUtqsA.js +127 -0
- package/dist/Card-DwgUtqsA.js.map +1 -0
- package/dist/Card-RgHsp9x1.js +138 -0
- package/dist/Card-RgHsp9x1.js.map +1 -0
- package/dist/{index-DOsC03ZN.js → index-B_4pciGp.js} +1411 -1358
- package/dist/index-B_4pciGp.js.map +1 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +15 -13
- package/package.json +1 -1
- package/src/components/{LockedAttachment/components → AttachmentCard}/MediaPlayer.tsx +4 -3
- package/src/components/AttachmentCard/Thumbnail.tsx +150 -0
- package/src/components/AttachmentCard/index.tsx +114 -0
- package/src/components/LockedAttachment/components/Creator/Card.tsx +123 -113
- package/src/components/LockedAttachment/components/Visitor/Card.tsx +43 -42
- package/src/components/LockedAttachment/components/Visitor/LockBadge.tsx +12 -0
- package/src/components/MediaMessage/MediaMessage.stories.tsx +45 -4
- package/src/components/MediaMessage/MediaMessage.test.tsx +151 -153
- package/src/components/MediaMessage/index.tsx +239 -349
- package/src/index.ts +7 -3
- package/dist/Card-BHrnmHeu.js +0 -167
- package/dist/Card-BHrnmHeu.js.map +0 -1
- package/dist/Card-D4vEgqWt.js +0 -195
- package/dist/Card-D4vEgqWt.js.map +0 -1
- package/dist/index-DOsC03ZN.js.map +0 -1
- package/src/components/LockedAttachment/components/Creator/CardThumbnail.tsx +0 -114
- package/src/components/LockedAttachment/components/Visitor/CardThumbnail.tsx +0 -81
- /package/src/components/{LockedAttachment → AttachmentCard}/utils/icons.ts +0 -0
- /package/src/components/{LockedAttachment → AttachmentCard}/utils/mimeType.test.ts +0 -0
- /package/src/components/{LockedAttachment → AttachmentCard}/utils/mimeType.ts +0 -0
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { renderTypeIcon } from '../../utils/icons'
|
|
5
|
-
import { getSourceType } from '../../utils/mimeType'
|
|
6
|
-
import MediaPlayer from '../MediaPlayer'
|
|
7
|
-
|
|
8
|
-
interface CardThumbnailProps {
|
|
9
|
-
title?: string
|
|
10
|
-
sourceUrl?: string
|
|
11
|
-
thumbnailUrl?: string
|
|
12
|
-
mimeType: string
|
|
13
|
-
onToggle?: () => void
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const CardThumbnail: React.FC<CardThumbnailProps> = ({
|
|
17
|
-
title,
|
|
18
|
-
sourceUrl,
|
|
19
|
-
thumbnailUrl,
|
|
20
|
-
mimeType,
|
|
21
|
-
onToggle,
|
|
22
|
-
}) => {
|
|
23
|
-
const isExpanded = onToggle && sourceUrl && thumbnailUrl
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<button
|
|
27
|
-
type="button"
|
|
28
|
-
disabled={!onToggle}
|
|
29
|
-
className={classNames(
|
|
30
|
-
'relative block w-full overflow-hidden border-0 bg-white/10 p-0 text-left appearance-none',
|
|
31
|
-
{ 'cursor-pointer': !!onToggle, 'cursor-default': !onToggle }
|
|
32
|
-
)}
|
|
33
|
-
onClick={onToggle}
|
|
34
|
-
aria-label={onToggle ? 'Toggle preview' : undefined}
|
|
35
|
-
>
|
|
36
|
-
{isExpanded ? (
|
|
37
|
-
<ThumbnailMedia
|
|
38
|
-
sourceUrl={sourceUrl}
|
|
39
|
-
thumbnailUrl={thumbnailUrl}
|
|
40
|
-
mimeType={mimeType}
|
|
41
|
-
/>
|
|
42
|
-
) : thumbnailUrl ? (
|
|
43
|
-
<div className="aspect-video overflow-hidden">
|
|
44
|
-
<img
|
|
45
|
-
src={thumbnailUrl}
|
|
46
|
-
alt={title}
|
|
47
|
-
draggable={false}
|
|
48
|
-
className="absolute inset-0 h-full w-full object-cover"
|
|
49
|
-
/>
|
|
50
|
-
</div>
|
|
51
|
-
) : (
|
|
52
|
-
<div className="aspect-video flex items-center justify-center">
|
|
53
|
-
{renderTypeIcon(mimeType, {
|
|
54
|
-
className: 'size-12 text-white/20',
|
|
55
|
-
weight: 'regular',
|
|
56
|
-
})}
|
|
57
|
-
</div>
|
|
58
|
-
)}
|
|
59
|
-
|
|
60
|
-
{!isExpanded && (
|
|
61
|
-
<div className="pointer-events-none absolute inset-0 bg-black/30" />
|
|
62
|
-
)}
|
|
63
|
-
</button>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface ThumbnailMediaProps {
|
|
68
|
-
sourceUrl: string
|
|
69
|
-
thumbnailUrl: string
|
|
70
|
-
mimeType: string
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const ThumbnailMedia: React.FC<ThumbnailMediaProps> = ({
|
|
74
|
-
sourceUrl,
|
|
75
|
-
thumbnailUrl,
|
|
76
|
-
mimeType,
|
|
77
|
-
}) => {
|
|
78
|
-
const sourceType = getSourceType(mimeType)
|
|
79
|
-
|
|
80
|
-
if (sourceType === 'video' || sourceType === 'audio') {
|
|
81
|
-
return (
|
|
82
|
-
<MediaPlayer
|
|
83
|
-
mimeType={mimeType}
|
|
84
|
-
source={sourceUrl}
|
|
85
|
-
poster={thumbnailUrl}
|
|
86
|
-
autoPlay={true}
|
|
87
|
-
loop={true}
|
|
88
|
-
controls={true}
|
|
89
|
-
muted={false}
|
|
90
|
-
/>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (sourceType === 'image') {
|
|
95
|
-
return (
|
|
96
|
-
<img src={sourceUrl} alt="" className="block w-full" draggable={false} />
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (sourceType === 'document') {
|
|
101
|
-
return (
|
|
102
|
-
<img
|
|
103
|
-
src={thumbnailUrl}
|
|
104
|
-
alt=""
|
|
105
|
-
className="block w-full"
|
|
106
|
-
draggable={false}
|
|
107
|
-
/>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return null
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default CardThumbnail
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { LockOpenIcon, LockSimpleIcon } from '@phosphor-icons/react'
|
|
2
|
-
import React, { useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import { PaymentStatus } from '../../types'
|
|
5
|
-
import { renderTypeIcon } from '../../utils/icons'
|
|
6
|
-
import { getSourceType } from '../../utils/mimeType'
|
|
7
|
-
import MediaPlayer from '../MediaPlayer'
|
|
8
|
-
|
|
9
|
-
interface CardThumbnailProps {
|
|
10
|
-
title?: string
|
|
11
|
-
sourceUrl?: string
|
|
12
|
-
thumbnailUrl?: string
|
|
13
|
-
mimeType: string
|
|
14
|
-
paymentStatus?: PaymentStatus
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const CardThumbnail: React.FC<CardThumbnailProps> = ({
|
|
18
|
-
title,
|
|
19
|
-
sourceUrl,
|
|
20
|
-
thumbnailUrl,
|
|
21
|
-
mimeType,
|
|
22
|
-
paymentStatus,
|
|
23
|
-
}) => {
|
|
24
|
-
const [sourceReady, setSourceReady] = useState(false)
|
|
25
|
-
|
|
26
|
-
const isLocked = sourceUrl === undefined
|
|
27
|
-
const sourceType = getSourceType(mimeType)
|
|
28
|
-
|
|
29
|
-
if (!isLocked) {
|
|
30
|
-
if (sourceType === 'audio' || sourceType === 'video') {
|
|
31
|
-
return (
|
|
32
|
-
<MediaPlayer
|
|
33
|
-
source={sourceUrl}
|
|
34
|
-
poster={thumbnailUrl}
|
|
35
|
-
mimeType={mimeType}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div className="relative aspect-video overflow-hidden bg-black/5">
|
|
42
|
-
<img
|
|
43
|
-
src={sourceType === 'document' ? thumbnailUrl : sourceUrl}
|
|
44
|
-
alt={title}
|
|
45
|
-
className={`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${sourceReady ? 'opacity-100' : 'opacity-0'}`}
|
|
46
|
-
draggable={false}
|
|
47
|
-
onLoad={() => setSourceReady(true)}
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<div className="relative aspect-video overflow-hidden bg-black/5">
|
|
55
|
-
{thumbnailUrl != null ? (
|
|
56
|
-
<img
|
|
57
|
-
src={thumbnailUrl}
|
|
58
|
-
alt=""
|
|
59
|
-
className="absolute inset-0 h-full w-full object-cover"
|
|
60
|
-
draggable={false}
|
|
61
|
-
/>
|
|
62
|
-
) : (
|
|
63
|
-
<div className="absolute inset-0 flex items-center justify-center">
|
|
64
|
-
{renderTypeIcon(mimeType, {
|
|
65
|
-
className: 'size-12 text-black/20',
|
|
66
|
-
weight: 'regular',
|
|
67
|
-
})}
|
|
68
|
-
</div>
|
|
69
|
-
)}
|
|
70
|
-
{isLocked && (
|
|
71
|
-
<div className="absolute inset-0 bg-black/30">
|
|
72
|
-
<div className="absolute left-3 top-3 flex size-8 items-center justify-center rounded-full bg-black/60 text-white">
|
|
73
|
-
{paymentStatus === 'paid' ? <LockOpenIcon /> : <LockSimpleIcon />}
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
)}
|
|
77
|
-
</div>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export default CardThumbnail
|
|
File without changes
|
|
File without changes
|
|
File without changes
|