@linktr.ee/messaging-react 2.0.1 → 2.1.0-rc-1778695491
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-CFFNq49v.js +163 -0
- package/dist/Card-CFFNq49v.js.map +1 -0
- package/dist/Card-CsJvUF_b.js +107 -0
- package/dist/Card-CsJvUF_b.js.map +1 -0
- package/dist/Card-D32U6KfZ.js +85 -0
- package/dist/Card-D32U6KfZ.js.map +1 -0
- package/dist/Card-DlMSDSdm.js +132 -0
- package/dist/Card-DlMSDSdm.js.map +1 -0
- package/dist/Card-DlSSJPip.js +60 -0
- package/dist/Card-DlSSJPip.js.map +1 -0
- package/dist/Card-zGbhRBwv.js +48 -0
- package/dist/Card-zGbhRBwv.js.map +1 -0
- package/dist/CardThumbnail-DTBuRQHF.js +239 -0
- package/dist/CardThumbnail-DTBuRQHF.js.map +1 -0
- package/dist/LockedThumbnail-DpJx169C.js +220 -0
- package/dist/LockedThumbnail-DpJx169C.js.map +1 -0
- package/dist/{index-Bex7eg3v.js → index-DfcRe-Hj.js} +618 -607
- package/dist/index-DfcRe-Hj.js.map +1 -0
- package/dist/index.d.ts +217 -28
- package/dist/index.js +16 -15
- package/package.json +1 -1
- package/src/components/CustomMessage/index.tsx +2 -3
- package/src/components/LinkAttachment/LinkAttachment.stories.tsx +307 -0
- package/src/components/LinkAttachment/components/Composer/Card.tsx +117 -0
- package/src/components/LinkAttachment/components/Composer/index.ts +2 -0
- package/src/components/LinkAttachment/components/Received/Card.tsx +132 -0
- package/src/components/LinkAttachment/components/Received/index.ts +2 -0
- package/src/components/LinkAttachment/components/Sent/Card.tsx +57 -0
- package/src/components/LinkAttachment/components/Sent/index.ts +2 -0
- package/src/components/LinkAttachment/components/_shared/CardBody.tsx +117 -0
- package/src/components/LinkAttachment/components/_shared/CardCta.tsx +69 -0
- package/src/components/LinkAttachment/components/_shared/CardShell.tsx +120 -0
- package/src/components/LinkAttachment/components/_shared/CardThumbnail.tsx +156 -0
- package/src/components/LinkAttachment/components/_shared/normalizeExternalHref.ts +56 -0
- package/src/components/LinkAttachment/index.tsx +68 -0
- package/src/components/LinkAttachment/types.ts +69 -0
- package/src/components/LockedAttachment/LockedAttachment.stories.tsx +230 -89
- package/src/components/LockedAttachment/components/Composer/Card.tsx +221 -0
- package/src/components/LockedAttachment/components/Composer/index.ts +2 -0
- package/src/components/LockedAttachment/components/Received/Card.tsx +191 -0
- package/src/components/LockedAttachment/components/Received/CardActions.tsx +91 -0
- package/src/components/LockedAttachment/components/Received/index.ts +2 -0
- package/src/components/LockedAttachment/components/Sent/Card.tsx +177 -0
- package/src/components/LockedAttachment/components/Sent/index.ts +2 -0
- package/src/components/LockedAttachment/components/_shared/CardBody.tsx +94 -0
- package/src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx +178 -0
- package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +39 -0
- package/src/components/LockedAttachment/components/_shared/LockedCardShell.tsx +36 -0
- package/src/components/LockedAttachment/components/_shared/LockedThumbnail.tsx +128 -0
- package/src/components/LockedAttachment/index.tsx +43 -12
- package/src/components/LockedAttachment/types.ts +17 -0
- package/src/components/MediaMessage/index.tsx +8 -2
- package/src/index.ts +15 -1
- package/dist/Card-BKP9ml9O.js +0 -138
- package/dist/Card-BKP9ml9O.js.map +0 -1
- package/dist/Card-Bk_4lVzP.js +0 -127
- package/dist/Card-Bk_4lVzP.js.map +0 -1
- package/dist/index-Bex7eg3v.js.map +0 -1
- package/src/components/LockedAttachment/components/Creator/Card.tsx +0 -210
- package/src/components/LockedAttachment/components/Creator/index.tsx +0 -2
- package/src/components/LockedAttachment/components/Visitor/Card.tsx +0 -155
- package/src/components/LockedAttachment/components/Visitor/CardActions.tsx +0 -62
- package/src/components/LockedAttachment/components/Visitor/LockBadge.tsx +0 -12
- package/src/components/LockedAttachment/components/Visitor/index.ts +0 -2
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CaretLeftIcon,
|
|
3
|
+
CaretRightIcon,
|
|
4
|
+
LockOpenIcon,
|
|
5
|
+
LockSimpleIcon,
|
|
6
|
+
PlayIcon,
|
|
7
|
+
} from '@phosphor-icons/react'
|
|
8
|
+
import classNames from 'classnames'
|
|
9
|
+
import React, { useState } from 'react'
|
|
10
|
+
|
|
11
|
+
import { AttachmentThumbnail, getSourceType } from '../../../AttachmentCard'
|
|
12
|
+
import type {
|
|
13
|
+
LockedAttachmentGalleryItem,
|
|
14
|
+
PaymentStatus,
|
|
15
|
+
} from '../../types'
|
|
16
|
+
|
|
17
|
+
import type { LockedCardVariant } from './LockedCardShell'
|
|
18
|
+
|
|
19
|
+
export interface GalleryThumbnailProps {
|
|
20
|
+
variant: LockedCardVariant
|
|
21
|
+
gallery: LockedAttachmentGalleryItem[]
|
|
22
|
+
title?: string
|
|
23
|
+
/** When true, all items are shown blurred + the locked/play badge is overlaid. */
|
|
24
|
+
showLocked: boolean
|
|
25
|
+
paymentStatus?: PaymentStatus
|
|
26
|
+
/** Top-right slot (e.g. dismiss X on Composer). Rendered inside the thumbnail. */
|
|
27
|
+
topRight?: React.ReactNode
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isPlayableItem(item: LockedAttachmentGalleryItem): boolean {
|
|
31
|
+
const sourceType = getSourceType(item.mimeType)
|
|
32
|
+
return sourceType === 'video' || sourceType === 'audio'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Mixed-media carousel used by every LockedAttachment card when its `gallery`
|
|
37
|
+
* prop has 2+ items. Matches the "Gallery" frames in the Figma design system:
|
|
38
|
+
* 337/386 aspect ratio, prev/next caret buttons, a counter pill, and a center
|
|
39
|
+
* lock / play indicator that swaps based on the current item.
|
|
40
|
+
*/
|
|
41
|
+
const GalleryThumbnail: React.FC<GalleryThumbnailProps> = ({
|
|
42
|
+
variant,
|
|
43
|
+
gallery,
|
|
44
|
+
title,
|
|
45
|
+
showLocked,
|
|
46
|
+
paymentStatus,
|
|
47
|
+
topRight,
|
|
48
|
+
}) => {
|
|
49
|
+
const [index, setIndex] = useState(0)
|
|
50
|
+
const total = gallery.length
|
|
51
|
+
const safeIndex = Math.min(index, total - 1)
|
|
52
|
+
const current = gallery[safeIndex]
|
|
53
|
+
const isVideoItem = isPlayableItem(current)
|
|
54
|
+
|
|
55
|
+
// Center badge: PLAY for video items, LOCK for non-video locked items.
|
|
56
|
+
// Unlocked image items show no center badge — the image is the content.
|
|
57
|
+
const centerBadge = (() => {
|
|
58
|
+
if (isVideoItem) {
|
|
59
|
+
return <PlayIcon className="size-6" weight="fill" />
|
|
60
|
+
}
|
|
61
|
+
if (showLocked) {
|
|
62
|
+
return paymentStatus === 'paid' ? (
|
|
63
|
+
<LockOpenIcon className="size-6" weight="fill" />
|
|
64
|
+
) : (
|
|
65
|
+
<LockSimpleIcon className="size-6" weight="fill" />
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
return null
|
|
69
|
+
})()
|
|
70
|
+
|
|
71
|
+
// Stop propagation so arrow taps don't bubble up to the outer preview-toggle
|
|
72
|
+
// wrapper on ComposerCard / SentCard.
|
|
73
|
+
const goPrev = (e: React.MouseEvent) => {
|
|
74
|
+
e.stopPropagation()
|
|
75
|
+
setIndex((i) => Math.max(0, i - 1))
|
|
76
|
+
}
|
|
77
|
+
const goNext = (e: React.MouseEvent) => {
|
|
78
|
+
e.stopPropagation()
|
|
79
|
+
setIndex((i) => Math.min(total - 1, i + 1))
|
|
80
|
+
}
|
|
81
|
+
const atStart = safeIndex === 0
|
|
82
|
+
const atEnd = safeIndex === total - 1
|
|
83
|
+
|
|
84
|
+
const isDark = variant === 'dark'
|
|
85
|
+
|
|
86
|
+
// Locked + unlocked render entirely separate trees so the locked state
|
|
87
|
+
// doesn't end up stacking a blurred `<img>` on top of an underlying
|
|
88
|
+
// `AttachmentThumbnail` (whose `bg-white/10` poster shell otherwise
|
|
89
|
+
// shows through as a visible horizontal seam at the 16:9 boundary
|
|
90
|
+
// inside the taller 337/386 gallery aspect).
|
|
91
|
+
//
|
|
92
|
+
// The locked branch uses `filter: blur` on a single full-size `<img>`
|
|
93
|
+
// — not `backdrop-filter` — so the rounded corners are clipped
|
|
94
|
+
// normally without any clip-path workarounds (see LockedThumbnail).
|
|
95
|
+
return (
|
|
96
|
+
<div className="relative aspect-[337/386] overflow-hidden rounded-t-2xl">
|
|
97
|
+
{showLocked ? (
|
|
98
|
+
<div
|
|
99
|
+
className={classNames(
|
|
100
|
+
'absolute inset-0',
|
|
101
|
+
isDark ? 'bg-white/10' : 'bg-black/5'
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
{current.thumbnailUrl && (
|
|
105
|
+
<img
|
|
106
|
+
src={current.thumbnailUrl}
|
|
107
|
+
alt=""
|
|
108
|
+
aria-hidden
|
|
109
|
+
draggable={false}
|
|
110
|
+
// `scale-110` hides the fuzzy edge that `filter: blur` leaves
|
|
111
|
+
// around the image bounds.
|
|
112
|
+
className="absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
) : (
|
|
117
|
+
<AttachmentThumbnail
|
|
118
|
+
mimeType={current.mimeType}
|
|
119
|
+
sourceUrl={current.sourceUrl}
|
|
120
|
+
thumbnailUrl={current.thumbnailUrl}
|
|
121
|
+
title={title}
|
|
122
|
+
variant={variant}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
125
|
+
|
|
126
|
+
{centerBadge && (
|
|
127
|
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
128
|
+
<div className="flex size-12 items-center justify-center rounded-full bg-black/25 text-white">
|
|
129
|
+
{centerBadge}
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
)}
|
|
133
|
+
|
|
134
|
+
{total > 1 && (
|
|
135
|
+
<React.Fragment>
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
onClick={goPrev}
|
|
139
|
+
disabled={atStart}
|
|
140
|
+
aria-label="Previous item"
|
|
141
|
+
className={classNames(
|
|
142
|
+
'absolute left-3 top-1/2 -translate-y-1/2 flex size-7 items-center justify-center rounded-full bg-black/30 text-white transition-opacity',
|
|
143
|
+
atStart ? 'opacity-40' : 'hover:bg-black/40'
|
|
144
|
+
)}
|
|
145
|
+
>
|
|
146
|
+
<CaretLeftIcon className="size-5" weight="bold" />
|
|
147
|
+
</button>
|
|
148
|
+
<button
|
|
149
|
+
type="button"
|
|
150
|
+
onClick={goNext}
|
|
151
|
+
disabled={atEnd}
|
|
152
|
+
aria-label="Next item"
|
|
153
|
+
className={classNames(
|
|
154
|
+
'absolute right-3 top-1/2 -translate-y-1/2 flex size-7 items-center justify-center rounded-full bg-black/30 text-white transition-opacity',
|
|
155
|
+
atEnd ? 'opacity-40' : 'hover:bg-black/40'
|
|
156
|
+
)}
|
|
157
|
+
>
|
|
158
|
+
<CaretRightIcon className="size-5" weight="bold" />
|
|
159
|
+
</button>
|
|
160
|
+
|
|
161
|
+
<div className="pointer-events-none absolute bottom-5 left-1/2 -translate-x-1/2 rounded-lg bg-black/30 px-2 py-1">
|
|
162
|
+
<span className="text-xs font-medium leading-4 text-white">
|
|
163
|
+
{safeIndex + 1}/{total}
|
|
164
|
+
</span>
|
|
165
|
+
</div>
|
|
166
|
+
</React.Fragment>
|
|
167
|
+
)}
|
|
168
|
+
|
|
169
|
+
{topRight && (
|
|
170
|
+
<div className="pointer-events-auto absolute right-3 top-3 z-10">
|
|
171
|
+
{topRight}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export default GalleryThumbnail
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LockOpenIcon,
|
|
3
|
+
LockSimpleIcon,
|
|
4
|
+
PlayIcon,
|
|
5
|
+
} from '@phosphor-icons/react'
|
|
6
|
+
import React from 'react'
|
|
7
|
+
|
|
8
|
+
import { getSourceType } from '../../../AttachmentCard'
|
|
9
|
+
import type { PaymentStatus } from '../../types'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Centered 48x48 lock badge that overlays the thumbnail of any locked attachment.
|
|
13
|
+
* Uses `bg-black/25` from the design system's `alpha-black-25` token.
|
|
14
|
+
*
|
|
15
|
+
* For playable media (video/audio), the badge shows a play icon instead of a
|
|
16
|
+
* lock — matching the convention used by `GalleryThumbnail`.
|
|
17
|
+
*/
|
|
18
|
+
export const LockBadge: React.FC<{
|
|
19
|
+
paymentStatus?: PaymentStatus
|
|
20
|
+
mimeType?: string
|
|
21
|
+
}> = ({ paymentStatus, mimeType }) => {
|
|
22
|
+
const sourceType = mimeType ? getSourceType(mimeType) : undefined
|
|
23
|
+
const isPlayable = sourceType === 'video' || sourceType === 'audio'
|
|
24
|
+
|
|
25
|
+
const Icon = isPlayable
|
|
26
|
+
? PlayIcon
|
|
27
|
+
: paymentStatus === 'paid'
|
|
28
|
+
? LockOpenIcon
|
|
29
|
+
: LockSimpleIcon
|
|
30
|
+
return (
|
|
31
|
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
32
|
+
<div className="flex size-12 items-center justify-center rounded-full bg-black/25 text-white">
|
|
33
|
+
<Icon className="size-6" weight="fill" />
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default LockBadge
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export type LockedCardVariant = 'dark' | 'light'
|
|
5
|
+
|
|
6
|
+
export interface LockedCardShellProps {
|
|
7
|
+
variant: LockedCardVariant
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
rootRef?: React.Ref<HTMLDivElement>
|
|
10
|
+
'data-testid'?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Outer chrome for every LockedAttachment card.
|
|
15
|
+
* Mirrors the `shadow-400` + 16px radius treatment from the Figma design system.
|
|
16
|
+
*/
|
|
17
|
+
const LockedCardShell: React.FC<LockedCardShellProps> = ({
|
|
18
|
+
variant,
|
|
19
|
+
children,
|
|
20
|
+
rootRef,
|
|
21
|
+
'data-testid': dataTestId,
|
|
22
|
+
}) => (
|
|
23
|
+
<div
|
|
24
|
+
ref={rootRef}
|
|
25
|
+
data-testid={dataTestId}
|
|
26
|
+
className={classNames(
|
|
27
|
+
'relative w-[280px] select-none overflow-hidden rounded-md',
|
|
28
|
+
'shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]',
|
|
29
|
+
variant === 'dark' ? 'bg-[#121110]' : 'bg-white'
|
|
30
|
+
)}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export default LockedCardShell
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AttachmentThumbnail,
|
|
6
|
+
renderTypeIcon,
|
|
7
|
+
} from '../../../AttachmentCard'
|
|
8
|
+
import type { LockedAttachmentSource, PaymentStatus } from '../../types'
|
|
9
|
+
|
|
10
|
+
import { LockBadge } from './LockBadge'
|
|
11
|
+
import type { LockedCardVariant } from './LockedCardShell'
|
|
12
|
+
|
|
13
|
+
export interface LockedThumbnailProps {
|
|
14
|
+
variant: LockedCardVariant
|
|
15
|
+
mimeType: string
|
|
16
|
+
thumbnailUrl?: string
|
|
17
|
+
title?: string
|
|
18
|
+
/**
|
|
19
|
+
* When provided, the underlying source is shown unblurred (preview / unlocked state).
|
|
20
|
+
* When undefined, the thumbnail is treated as locked: blurred with a central lock badge.
|
|
21
|
+
*/
|
|
22
|
+
source?: LockedAttachmentSource
|
|
23
|
+
/**
|
|
24
|
+
* Forces the locked appearance even when a source is provided. Used for the
|
|
25
|
+
* Composer card where the locked treatment is the default and the user toggles
|
|
26
|
+
* a preview in place.
|
|
27
|
+
*/
|
|
28
|
+
showLocked: boolean
|
|
29
|
+
paymentStatus?: PaymentStatus
|
|
30
|
+
/** Top-right overlay (e.g. dismiss X on Composer). Rendered inside the thumbnail. */
|
|
31
|
+
topRight?: React.ReactNode
|
|
32
|
+
/** When true, renders the unlocked image with aspect-video + object-contain. */
|
|
33
|
+
containedImage?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Renders the 180px-tall media area for a LockedAttachment card.
|
|
38
|
+
* Handles three visual states:
|
|
39
|
+
* - locked: blurred thumbnail + centered 48px lock badge
|
|
40
|
+
* - preview/paid: clear thumbnail (the underlying source)
|
|
41
|
+
* - empty: type-icon placeholder
|
|
42
|
+
*/
|
|
43
|
+
const LockedThumbnail: React.FC<LockedThumbnailProps> = ({
|
|
44
|
+
variant,
|
|
45
|
+
mimeType,
|
|
46
|
+
thumbnailUrl,
|
|
47
|
+
title,
|
|
48
|
+
source,
|
|
49
|
+
showLocked,
|
|
50
|
+
paymentStatus,
|
|
51
|
+
topRight,
|
|
52
|
+
containedImage = false,
|
|
53
|
+
}) => {
|
|
54
|
+
const effectiveSourceUrl = showLocked ? undefined : source?.sourceUrl
|
|
55
|
+
const effectiveThumbnailUrl = showLocked
|
|
56
|
+
? thumbnailUrl
|
|
57
|
+
: (source?.thumbnailUrl ?? thumbnailUrl)
|
|
58
|
+
|
|
59
|
+
const isDark = variant === 'dark'
|
|
60
|
+
|
|
61
|
+
// Locked + unlocked render entirely separate trees so the locked state
|
|
62
|
+
// doesn't end up stacking a blurred `<img>` on top of an underlying
|
|
63
|
+
// `AttachmentThumbnail` (whose `bg-white/10` poster shell otherwise
|
|
64
|
+
// shows through as a visible horizontal seam at the 16:9 boundary).
|
|
65
|
+
//
|
|
66
|
+
// The locked branch uses `filter: blur` on a single full-size `<img>`
|
|
67
|
+
// — not `backdrop-filter` — because `backdrop-filter` paints in its
|
|
68
|
+
// own compositing layer that escapes ancestor `overflow: hidden` on
|
|
69
|
+
// Chrome/Safari and flattens the card's top corners. `filter` is
|
|
70
|
+
// clipped normally, so the rounded corners stay round without any
|
|
71
|
+
// clip-path workarounds.
|
|
72
|
+
return (
|
|
73
|
+
<div className="relative overflow-hidden rounded-t-2xl">
|
|
74
|
+
{showLocked ? (
|
|
75
|
+
<div
|
|
76
|
+
className={classNames(
|
|
77
|
+
'relative aspect-video overflow-hidden',
|
|
78
|
+
isDark ? 'bg-white/10' : 'bg-black/5'
|
|
79
|
+
)}
|
|
80
|
+
>
|
|
81
|
+
{effectiveThumbnailUrl ? (
|
|
82
|
+
<img
|
|
83
|
+
src={effectiveThumbnailUrl}
|
|
84
|
+
alt=""
|
|
85
|
+
aria-hidden
|
|
86
|
+
draggable={false}
|
|
87
|
+
// `scale-110` hides the fuzzy semi-transparent edge that
|
|
88
|
+
// `filter: blur` leaves around the image bounds.
|
|
89
|
+
className="absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"
|
|
90
|
+
/>
|
|
91
|
+
) : (
|
|
92
|
+
<div className="absolute inset-0 flex items-center justify-center">
|
|
93
|
+
{renderTypeIcon(mimeType, {
|
|
94
|
+
className: isDark
|
|
95
|
+
? 'size-12 text-white/20'
|
|
96
|
+
: 'size-12 text-black/20',
|
|
97
|
+
weight: 'regular',
|
|
98
|
+
})}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
<LockBadge paymentStatus={paymentStatus} mimeType={mimeType} />
|
|
102
|
+
</div>
|
|
103
|
+
) : (
|
|
104
|
+
<AttachmentThumbnail
|
|
105
|
+
mimeType={mimeType}
|
|
106
|
+
sourceUrl={effectiveSourceUrl}
|
|
107
|
+
thumbnailUrl={effectiveThumbnailUrl}
|
|
108
|
+
title={title}
|
|
109
|
+
variant={variant}
|
|
110
|
+
containedImage={containedImage}
|
|
111
|
+
mediaPlayerProps={
|
|
112
|
+
effectiveSourceUrl
|
|
113
|
+
? { autoPlay: true, loop: true, controls: true, muted: false }
|
|
114
|
+
: undefined
|
|
115
|
+
}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
{topRight && (
|
|
120
|
+
<div className="pointer-events-auto absolute right-3 top-3 z-10">
|
|
121
|
+
{topRight}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default LockedThumbnail
|
|
@@ -1,32 +1,63 @@
|
|
|
1
1
|
import React, { Suspense } from 'react'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { ComposerCardProps } from './components/Composer/Card'
|
|
4
|
+
import type { ReceivedCardProps } from './components/Received/Card'
|
|
5
|
+
import type { SentCardProps } from './components/Sent/Card'
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const ComposerCardLazy = React.lazy(() => import('./components/Composer/Card'))
|
|
8
|
+
const SentCardLazy = React.lazy(() => import('./components/Sent/Card'))
|
|
9
|
+
const ReceivedCardLazy = React.lazy(() => import('./components/Received/Card'))
|
|
8
10
|
|
|
9
11
|
const LockedAttachmentFallback = () => (
|
|
10
12
|
<div
|
|
11
|
-
className="w-[280px] min-h-[200px] animate-pulse rounded-
|
|
13
|
+
className="w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"
|
|
12
14
|
aria-hidden
|
|
13
15
|
/>
|
|
14
16
|
)
|
|
15
17
|
|
|
16
|
-
const
|
|
18
|
+
const Composer = (props: ComposerCardProps) => (
|
|
17
19
|
<Suspense fallback={<LockedAttachmentFallback />}>
|
|
18
|
-
<
|
|
20
|
+
<ComposerCardLazy {...props} />
|
|
19
21
|
</Suspense>
|
|
20
22
|
)
|
|
21
23
|
|
|
22
|
-
const
|
|
24
|
+
const Sent = (props: SentCardProps) => (
|
|
23
25
|
<Suspense fallback={<LockedAttachmentFallback />}>
|
|
24
|
-
<
|
|
26
|
+
<SentCardLazy {...props} />
|
|
25
27
|
</Suspense>
|
|
26
28
|
)
|
|
27
29
|
|
|
28
|
-
const
|
|
30
|
+
const Received = (props: ReceivedCardProps) => (
|
|
31
|
+
<Suspense fallback={<LockedAttachmentFallback />}>
|
|
32
|
+
<ReceivedCardLazy {...props} />
|
|
33
|
+
</Suspense>
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Renamed to `LockedAttachment.Sent` (post-send sender card) or
|
|
38
|
+
* `LockedAttachment.Composer` (drafting state). This alias maps to `Sent`
|
|
39
|
+
* because that matches the previous in-thread usage; pre-send / drafting
|
|
40
|
+
* usages (e.g. with `onDismiss`) should migrate to `LockedAttachment.Composer`.
|
|
41
|
+
*/
|
|
42
|
+
const Creator = Sent
|
|
43
|
+
|
|
44
|
+
/** @deprecated Renamed to `LockedAttachment.Received`. */
|
|
45
|
+
const Visitor = Received
|
|
46
|
+
|
|
47
|
+
const LockedAttachment = { Composer, Sent, Received, Creator, Visitor }
|
|
29
48
|
|
|
30
49
|
export default LockedAttachment
|
|
31
|
-
export type {
|
|
32
|
-
|
|
50
|
+
export type { ComposerCardProps, SentCardProps, ReceivedCardProps }
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Renamed to `SentCardProps`. Drafting usages (with `onDismiss`)
|
|
53
|
+
* should migrate to `ComposerCardProps`.
|
|
54
|
+
*/
|
|
55
|
+
export type CreatorCardProps = SentCardProps
|
|
56
|
+
/** @deprecated Renamed to `ReceivedCardProps`. */
|
|
57
|
+
export type VisitorCardProps = ReceivedCardProps
|
|
58
|
+
export type {
|
|
59
|
+
PaymentStatus,
|
|
60
|
+
LockedAttachmentSource,
|
|
61
|
+
LockedAttachmentGalleryItem,
|
|
62
|
+
LockedAttachmentContextValue,
|
|
63
|
+
} from './types'
|
|
@@ -9,6 +9,23 @@ export interface LockedAttachmentBaseProps {
|
|
|
9
9
|
detail?: string
|
|
10
10
|
amountText?: string
|
|
11
11
|
paymentStatus?: PaymentStatus
|
|
12
|
+
/**
|
|
13
|
+
* When provided with 2+ items, the card renders as a mixed-media carousel
|
|
14
|
+
* (e.g. a couple of photos + a video) instead of a single thumbnail. Each
|
|
15
|
+
* item brings its own thumbnail and optional source so that
|
|
16
|
+
* `LockedAttachment.Composer` / `.Sent` / `.Received` can all share the
|
|
17
|
+
* same carousel chrome.
|
|
18
|
+
*/
|
|
19
|
+
gallery?: LockedAttachmentGalleryItem[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface LockedAttachmentGalleryItem {
|
|
23
|
+
/** MIME type of this carousel item — drives the per-item play / lock affordance. */
|
|
24
|
+
mimeType: string
|
|
25
|
+
/** Poster image used for both the locked (blurred) and unlocked preview state. */
|
|
26
|
+
thumbnailUrl?: string
|
|
27
|
+
/** Underlying source (image or video URL) — shown only when unlocked. */
|
|
28
|
+
sourceUrl?: string
|
|
12
29
|
}
|
|
13
30
|
|
|
14
31
|
export interface LockedAttachmentSource {
|
|
@@ -216,7 +216,7 @@ export function resolveMediaFromMessage(
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
/** Dark card (sent / own message) — matches LockedAttachment.
|
|
219
|
+
/** Dark card (sent / own message) — matches LockedAttachment.Sent preview without toggle. */
|
|
220
220
|
const Creator: React.FC<MediaMessageResolved> = ({
|
|
221
221
|
resolvedUrl,
|
|
222
222
|
resolvedType,
|
|
@@ -246,7 +246,7 @@ const Creator: React.FC<MediaMessageResolved> = ({
|
|
|
246
246
|
)
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
/** Light card (received) — matches LockedAttachment.
|
|
249
|
+
/** Light card (received) — matches LockedAttachment.Received unlocked without Purchased copy. */
|
|
250
250
|
const Visitor: React.FC<MediaMessageResolved> = ({
|
|
251
251
|
resolvedUrl,
|
|
252
252
|
resolvedType,
|
|
@@ -283,6 +283,12 @@ export interface MediaMessageProps {
|
|
|
283
283
|
isMyMessage?: boolean
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
/**
|
|
287
|
+
* @deprecated Slated for removal once the profile repo is migrated to
|
|
288
|
+
* `LinkAttachment` (and its forthcoming media-only Attachment variants).
|
|
289
|
+
* New consumers should reach for `LinkAttachment.Composer`,
|
|
290
|
+
* `LinkAttachment.Sent`, or `LinkAttachment.Received` instead.
|
|
291
|
+
*/
|
|
286
292
|
const MediaMessageRoot: React.FC<MediaMessageProps> = ({
|
|
287
293
|
message,
|
|
288
294
|
isMyMessage = false,
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { ChannelList } from './components/ChannelList'
|
|
|
7
7
|
export { ChannelView } from './components/ChannelView'
|
|
8
8
|
export { default as ActionButton } from './components/ActionButton'
|
|
9
9
|
export { default as LockedAttachment } from './components/LockedAttachment'
|
|
10
|
+
export { default as LinkAttachment } from './components/LinkAttachment'
|
|
10
11
|
export { Avatar } from './components/Avatar'
|
|
11
12
|
export { FaqList } from './components/FaqList'
|
|
12
13
|
export { FaqListItem } from './components/FaqList/FaqListItem'
|
|
@@ -53,10 +54,23 @@ export type { MessageMetadata } from './stream-custom-data'
|
|
|
53
54
|
export type { AvatarProps } from './components/Avatar'
|
|
54
55
|
export type { ActionButtonProps } from './components/ActionButton'
|
|
55
56
|
export type {
|
|
57
|
+
ComposerCardProps,
|
|
58
|
+
SentCardProps,
|
|
59
|
+
ReceivedCardProps,
|
|
60
|
+
LockedAttachmentGalleryItem,
|
|
61
|
+
LockedAttachmentContextValue,
|
|
62
|
+
// Deprecated aliases preserved for backwards compatibility:
|
|
56
63
|
CreatorCardProps,
|
|
57
64
|
VisitorCardProps,
|
|
58
|
-
LockedAttachmentContextValue,
|
|
59
65
|
} from './components/LockedAttachment'
|
|
66
|
+
export type {
|
|
67
|
+
ComposerCardProps as LinkAttachmentComposerCardProps,
|
|
68
|
+
SentCardProps as LinkAttachmentSentCardProps,
|
|
69
|
+
ReceivedCardProps as LinkAttachmentReceivedCardProps,
|
|
70
|
+
LinkAttachmentBaseProps,
|
|
71
|
+
LinkAttachmentCta,
|
|
72
|
+
LinkAttachmentLayout,
|
|
73
|
+
} from './components/LinkAttachment'
|
|
60
74
|
export type { CustomMessageRegistry } from './components/CustomMessage/context'
|
|
61
75
|
export type { AttachmentSourceType } from './components/AttachmentCard/utils/mimeType'
|
|
62
76
|
export type { Faq, FaqListProps } from './components/FaqList'
|
package/dist/Card-BKP9ml9O.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { jsxs as b, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { CheckCircleIcon as C, XIcon as T, EyeIcon as B, EyeSlashIcon as D, LockOpenIcon as H, LockIcon as V } from "@phosphor-icons/react";
|
|
3
|
-
import y from "classnames";
|
|
4
|
-
import I, { useState as g, useRef as O, useCallback as P } from "react";
|
|
5
|
-
import { A as X, a as q } from "./index-Bex7eg3v.js";
|
|
6
|
-
function G(d) {
|
|
7
|
-
const { onDismiss: n, onToggle: r, isExpanded: o, paymentStatus: l, isLoading: f } = d;
|
|
8
|
-
return n ? {
|
|
9
|
-
topLeft: void 0,
|
|
10
|
-
topRight: /* @__PURE__ */ e(
|
|
11
|
-
"button",
|
|
12
|
-
{
|
|
13
|
-
type: "button",
|
|
14
|
-
onClick: n,
|
|
15
|
-
className: "flex size-8 items-center justify-center rounded-full bg-black/60 text-white",
|
|
16
|
-
"aria-label": "Dismiss attachment",
|
|
17
|
-
children: /* @__PURE__ */ e(T, { className: "size-4", weight: "bold" })
|
|
18
|
-
}
|
|
19
|
-
)
|
|
20
|
-
} : r ? {
|
|
21
|
-
topLeft: /* @__PURE__ */ e(
|
|
22
|
-
"button",
|
|
23
|
-
{
|
|
24
|
-
type: "button",
|
|
25
|
-
onClick: r,
|
|
26
|
-
className: "flex size-8 items-center justify-center rounded-full bg-black/60 text-white",
|
|
27
|
-
"aria-label": o ? "Hide preview" : "Show preview",
|
|
28
|
-
"aria-pressed": o,
|
|
29
|
-
children: /* @__PURE__ */ e(o ? B : D, { className: "size-4", weight: "fill" })
|
|
30
|
-
}
|
|
31
|
-
),
|
|
32
|
-
topRight: void 0
|
|
33
|
-
} : {
|
|
34
|
-
topLeft: /* @__PURE__ */ e("div", { className: "flex size-8 items-center justify-center rounded-full bg-black/60 text-white", children: f ? /* @__PURE__ */ e("span", { className: "size-4 animate-spin rounded-full border-2 border-white/30 border-t-white" }) : /* @__PURE__ */ e(l === "paid" ? H : V, { className: "size-4", weight: "fill" }) }),
|
|
35
|
-
topRight: void 0
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const Y = ({
|
|
39
|
-
title: d,
|
|
40
|
-
mimeType: n = "application/octet-stream",
|
|
41
|
-
thumbnailUrl: r,
|
|
42
|
-
detail: o,
|
|
43
|
-
amountText: l,
|
|
44
|
-
placeholderTitle: f = "Attachment title",
|
|
45
|
-
placeholderAmountText: x,
|
|
46
|
-
paymentStatus: m,
|
|
47
|
-
isUnlocking: L,
|
|
48
|
-
onDismiss: k,
|
|
49
|
-
onPreviewClick: c,
|
|
50
|
-
onFetchSource: u
|
|
51
|
-
}) => {
|
|
52
|
-
const [t, z] = g(), [a, h] = g(!1), [R, v] = g(!1), p = O(!1), w = a ? t == null ? void 0 : t.sourceUrl : void 0, j = a ? (t == null ? void 0 : t.thumbnailUrl) ?? r : r, s = R || L, U = P(async () => {
|
|
53
|
-
if (c == null || c(), a) {
|
|
54
|
-
h(!1);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (t) {
|
|
58
|
-
h(!0);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (u && !p.current) {
|
|
62
|
-
p.current = !0, v(!0);
|
|
63
|
-
try {
|
|
64
|
-
const N = await u();
|
|
65
|
-
N && (z(N), h(!0));
|
|
66
|
-
} finally {
|
|
67
|
-
p.current = !1, v(!1);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}, [a, t, c, u]), i = u || c ? U : void 0, A = m === "paid" ? /* @__PURE__ */ b(I.Fragment, { children: [
|
|
71
|
-
/* @__PURE__ */ e("span", { className: "text-xs font-medium text-white/55", children: "•" }),
|
|
72
|
-
/* @__PURE__ */ e("span", { className: "text-xs font-medium text-[#34c759]", children: "Sold" }),
|
|
73
|
-
/* @__PURE__ */ e(C, { className: "size-4 text-[#34c759]", weight: "bold" })
|
|
74
|
-
] }) : /* @__PURE__ */ b(I.Fragment, { children: [
|
|
75
|
-
/* @__PURE__ */ e("span", { className: "text-xs font-medium text-white/55", children: "•" }),
|
|
76
|
-
/* @__PURE__ */ e(
|
|
77
|
-
"span",
|
|
78
|
-
{
|
|
79
|
-
className: y("text-xs font-medium", {
|
|
80
|
-
"text-white/30": !l,
|
|
81
|
-
"text-white/55": !!l
|
|
82
|
-
}),
|
|
83
|
-
children: l || x
|
|
84
|
-
}
|
|
85
|
-
)
|
|
86
|
-
] }), { topLeft: E, topRight: S } = G({
|
|
87
|
-
onDismiss: k,
|
|
88
|
-
onToggle: s ? void 0 : i,
|
|
89
|
-
isExpanded: a,
|
|
90
|
-
paymentStatus: m,
|
|
91
|
-
isLoading: s
|
|
92
|
-
});
|
|
93
|
-
return /* @__PURE__ */ e(
|
|
94
|
-
X,
|
|
95
|
-
{
|
|
96
|
-
variant: "dark",
|
|
97
|
-
title: d,
|
|
98
|
-
placeholderTitle: f,
|
|
99
|
-
mimeType: n,
|
|
100
|
-
detail: o,
|
|
101
|
-
statusBadge: A,
|
|
102
|
-
topLeft: E,
|
|
103
|
-
topRight: S,
|
|
104
|
-
thumbnail: /* @__PURE__ */ b(
|
|
105
|
-
"button",
|
|
106
|
-
{
|
|
107
|
-
type: "button",
|
|
108
|
-
disabled: !i || s,
|
|
109
|
-
className: y(
|
|
110
|
-
"relative block w-full overflow-hidden border-0 bg-white/10 p-0 text-left appearance-none",
|
|
111
|
-
{ "cursor-pointer": !!i && !s, "cursor-default": !i || s }
|
|
112
|
-
),
|
|
113
|
-
onClick: s ? void 0 : i,
|
|
114
|
-
"aria-label": i ? "Toggle preview" : void 0,
|
|
115
|
-
"aria-busy": s,
|
|
116
|
-
children: [
|
|
117
|
-
/* @__PURE__ */ e(
|
|
118
|
-
q,
|
|
119
|
-
{
|
|
120
|
-
mimeType: n,
|
|
121
|
-
sourceUrl: w,
|
|
122
|
-
thumbnailUrl: j,
|
|
123
|
-
title: d,
|
|
124
|
-
variant: "dark",
|
|
125
|
-
mediaPlayerProps: w ? { autoPlay: !0, loop: !0, controls: !0, muted: !1 } : void 0
|
|
126
|
-
}
|
|
127
|
-
),
|
|
128
|
-
!a && /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-0 bg-black/30" })
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
export {
|
|
136
|
-
Y as default
|
|
137
|
-
};
|
|
138
|
-
//# sourceMappingURL=Card-BKP9ml9O.js.map
|