@linktr.ee/messaging-react 1.36.0 → 1.38.0-rc-1777583423

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.
Files changed (30) hide show
  1. package/dist/Card-BlXnKGaR.js +127 -0
  2. package/dist/Card-BlXnKGaR.js.map +1 -0
  3. package/dist/Card-DoNJA-jg.js +138 -0
  4. package/dist/Card-DoNJA-jg.js.map +1 -0
  5. package/dist/{index-DOsC03ZN.js → index-jnKl3mQ0.js} +1404 -1352
  6. package/dist/index-jnKl3mQ0.js.map +1 -0
  7. package/dist/index.d.ts +21 -1
  8. package/dist/index.js +15 -13
  9. package/package.json +2 -2
  10. package/src/components/{LockedAttachment/components → AttachmentCard}/MediaPlayer.tsx +4 -3
  11. package/src/components/AttachmentCard/Thumbnail.tsx +150 -0
  12. package/src/components/AttachmentCard/index.tsx +112 -0
  13. package/src/components/LockedAttachment/components/Creator/Card.tsx +123 -113
  14. package/src/components/LockedAttachment/components/Visitor/Card.tsx +43 -42
  15. package/src/components/LockedAttachment/components/Visitor/LockBadge.tsx +12 -0
  16. package/src/components/MediaMessage/MediaMessage.stories.tsx +45 -4
  17. package/src/components/MediaMessage/MediaMessage.test.tsx +125 -160
  18. package/src/components/MediaMessage/index.tsx +226 -349
  19. package/src/index.ts +7 -3
  20. package/src/providers/MessagingProvider.test.tsx +126 -0
  21. package/dist/Card-BHrnmHeu.js +0 -167
  22. package/dist/Card-BHrnmHeu.js.map +0 -1
  23. package/dist/Card-D4vEgqWt.js +0 -195
  24. package/dist/Card-D4vEgqWt.js.map +0 -1
  25. package/dist/index-DOsC03ZN.js.map +0 -1
  26. package/src/components/LockedAttachment/components/Creator/CardThumbnail.tsx +0 -114
  27. package/src/components/LockedAttachment/components/Visitor/CardThumbnail.tsx +0 -81
  28. /package/src/components/{LockedAttachment → AttachmentCard}/utils/icons.ts +0 -0
  29. /package/src/components/{LockedAttachment → AttachmentCard}/utils/mimeType.test.ts +0 -0
  30. /package/src/components/{LockedAttachment → AttachmentCard}/utils/mimeType.ts +0 -0
@@ -1,14 +1,14 @@
1
1
  import { CheckCircleIcon } from '@phosphor-icons/react'
2
2
  import React, { useCallback, useEffect, useRef, useState } from 'react'
3
3
 
4
+ import AttachmentCard, { AttachmentThumbnail } from '../../../AttachmentCard'
4
5
  import type {
5
6
  LockedAttachmentBaseProps,
6
7
  LockedAttachmentSource,
7
8
  } from '../../types'
8
- import { renderTypeIcon } from '../../utils/icons'
9
9
 
10
10
  import CardActions from './CardActions'
11
- import CardThumbnail from './CardThumbnail'
11
+ import { LockBadge } from './LockBadge'
12
12
 
13
13
  export interface VisitorCardProps extends LockedAttachmentBaseProps {
14
14
  /**
@@ -97,48 +97,49 @@ const VisitorCard: React.FC<VisitorCardProps> = ({
97
97
  return () => observer.disconnect()
98
98
  }, [paymentStatus, source, fetchSource])
99
99
 
100
+ const isLocked = effectiveSourceUrl === undefined
101
+
102
+ const statusBadge =
103
+ paymentStatus === 'paid' ? (
104
+ <React.Fragment>
105
+ <span className="text-xs font-medium text-black/55">&bull;</span>
106
+ <span className="text-xs font-medium text-[#008236]">Purchased</span>
107
+ <CheckCircleIcon className="size-4 text-[#008236]" weight="bold" />
108
+ </React.Fragment>
109
+ ) : amountText != null ? (
110
+ <React.Fragment>
111
+ <span className="text-xs font-medium text-black/55">&bull;</span>
112
+ <span className="text-xs font-medium text-black/55">{amountText}</span>
113
+ </React.Fragment>
114
+ ) : null
115
+
100
116
  return (
101
- <div
102
- ref={cardRef}
117
+ <AttachmentCard
118
+ variant="light"
119
+ rootRef={cardRef}
103
120
  data-testid="locked-attachment"
104
- className="w-[280px] select-none overflow-hidden rounded-[24px] bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]"
105
- >
106
- <CardThumbnail
107
- title={title}
108
- sourceUrl={effectiveSourceUrl}
109
- thumbnailUrl={effectiveThumbnail}
110
- mimeType={mimeType}
111
- paymentStatus={paymentStatus}
112
- />
113
-
114
- <div className="px-4 pb-3 pt-3">
115
- <p className="mb-0.5 truncate text-base font-medium text-black">
116
- {title}
117
- </p>
118
- <div className="flex items-center gap-1">
119
- {renderTypeIcon(mimeType, {
120
- className: 'size-5 shrink-0 text-black/55',
121
- weight: 'regular',
122
- })}
123
-
124
- {detail && (
125
- <span className="text-xs font-medium text-black/55">{detail}</span>
121
+ title={title}
122
+ mimeType={mimeType}
123
+ detail={detail}
124
+ statusBadge={statusBadge}
125
+ thumbnail={
126
+ <div className="relative">
127
+ <AttachmentThumbnail
128
+ mimeType={mimeType}
129
+ sourceUrl={effectiveSourceUrl}
130
+ thumbnailUrl={effectiveThumbnail}
131
+ title={title}
132
+ variant="light"
133
+ containedImage={!isLocked}
134
+ />
135
+ {isLocked && (
136
+ <div className="pointer-events-none absolute inset-0 bg-black/30">
137
+ <LockBadge paymentStatus={paymentStatus} />
138
+ </div>
126
139
  )}
127
-
128
- {paymentStatus === 'paid' ? (
129
- <React.Fragment>
130
- <span className="text-xs font-medium text-black/55">&bull;</span>
131
- <span className="text-xs font-medium text-[#008236]">Purchased</span>
132
- <CheckCircleIcon className="size-4 text-[#008236]" weight="bold" />
133
- </React.Fragment>
134
- ) : amountText != null ? (
135
- <React.Fragment>
136
- <span className="text-xs font-medium text-black/55">&bull;</span>
137
- <span className="text-xs font-medium text-black/55">{amountText}</span>
138
- </React.Fragment>
139
- ) : null}
140
140
  </div>
141
-
141
+ }
142
+ action={
142
143
  <CardActions
143
144
  isUnlocking={isUnlocking}
144
145
  sourceUrl={effectiveSourceUrl}
@@ -146,8 +147,8 @@ const VisitorCard: React.FC<VisitorCardProps> = ({
146
147
  onUnlockClicked={handleUnlockClick}
147
148
  onDownloadClicked={onDownloadClick}
148
149
  />
149
- </div>
150
- </div>
150
+ }
151
+ />
151
152
  )
152
153
  }
153
154
 
@@ -0,0 +1,12 @@
1
+ import { LockOpenIcon, LockSimpleIcon } from '@phosphor-icons/react'
2
+ import React from 'react'
3
+
4
+ import type { PaymentStatus } from '../../types'
5
+
6
+ export const LockBadge: React.FC<{ paymentStatus?: PaymentStatus }> = ({
7
+ paymentStatus,
8
+ }) => (
9
+ <div className="absolute left-3 top-3 flex size-8 items-center justify-center rounded-full bg-black/60 text-white">
10
+ {paymentStatus === 'paid' ? <LockOpenIcon /> : <LockSimpleIcon />}
11
+ </div>
12
+ )
@@ -160,7 +160,7 @@ export const Attachment: StoryFn = () => (
160
160
  <tbody>
161
161
  <tr>
162
162
  <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
163
- Received
163
+ Visitor
164
164
  </td>
165
165
  {VARIANTS.map(({ label, attachment }) => (
166
166
  <td key={label} className="align-top">
@@ -177,7 +177,7 @@ export const Attachment: StoryFn = () => (
177
177
  </tr>
178
178
  <tr>
179
179
  <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
180
- Sent
180
+ Creator
181
181
  </td>
182
182
  {VARIANTS.map(({ label, attachment }) => (
183
183
  <td key={label} className="align-top">
@@ -202,7 +202,7 @@ export const Links: StoryFn = () => (
202
202
  <tbody>
203
203
  <tr>
204
204
  <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
205
- Received
205
+ Visitor
206
206
  </td>
207
207
  {LINK_VARIANTS.map(({ label, attachment }) => (
208
208
  <td key={label} className="align-top">
@@ -219,7 +219,7 @@ export const Links: StoryFn = () => (
219
219
  </tr>
220
220
  <tr>
221
221
  <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
222
- Sent
222
+ Creator
223
223
  </td>
224
224
  {LINK_VARIANTS.map(({ label, attachment }) => (
225
225
  <td key={label} className="align-top">
@@ -237,3 +237,44 @@ export const Links: StoryFn = () => (
237
237
  </tbody>
238
238
  </Table>
239
239
  )
240
+
241
+ /** Standalone cards (no chat bubble shell), matching LockedAttachment story layout. */
242
+ export const Compound: StoryFn = () => (
243
+ <Table>
244
+ <TableHead variants={VARIANTS} />
245
+ <tbody>
246
+ <tr>
247
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
248
+ MediaMessage.Visitor
249
+ </td>
250
+ {VARIANTS.map(({ label, attachment }) => (
251
+ <td key={label} className="align-top">
252
+ <MediaMessage.Visitor
253
+ message={base({
254
+ attachments: [
255
+ attachment as MessageAttachment,
256
+ ],
257
+ })}
258
+ />
259
+ </td>
260
+ ))}
261
+ </tr>
262
+ <tr>
263
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
264
+ MediaMessage.Creator
265
+ </td>
266
+ {VARIANTS.map(({ label, attachment }) => (
267
+ <td key={label} className="align-top">
268
+ <MediaMessage.Creator
269
+ message={base({
270
+ attachments: [
271
+ attachment as MessageAttachment,
272
+ ],
273
+ })}
274
+ />
275
+ </td>
276
+ ))}
277
+ </tr>
278
+ </tbody>
279
+ </Table>
280
+ )