@linktr.ee/messaging-react 3.8.1 → 3.9.0-rc-1783407048
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-D8yiJ8Uw.cjs +2 -0
- package/dist/Card-D8yiJ8Uw.cjs.map +1 -0
- package/dist/Card-DSG-wR8t.js +96 -0
- package/dist/Card-DSG-wR8t.js.map +1 -0
- package/dist/Card-DVfSiq9b.cjs +2 -0
- package/dist/Card-DVfSiq9b.cjs.map +1 -0
- package/dist/Card-DX9nBx1S.js +221 -0
- package/dist/Card-DX9nBx1S.js.map +1 -0
- package/dist/Card-iKTcn1wg.cjs +2 -0
- package/dist/Card-iKTcn1wg.cjs.map +1 -0
- package/dist/Card-qDLtjK6u.js +108 -0
- package/dist/Card-qDLtjK6u.js.map +1 -0
- package/dist/PurchaseStatusBadge-CJH4S-8Z.js +36 -0
- package/dist/PurchaseStatusBadge-CJH4S-8Z.js.map +1 -0
- package/dist/PurchaseStatusBadge-UjDzZhLj.cjs +2 -0
- package/dist/PurchaseStatusBadge-UjDzZhLj.cjs.map +1 -0
- package/dist/TextShell-BiqF2UB0.js +32 -0
- package/dist/TextShell-BiqF2UB0.js.map +1 -0
- package/dist/TextShell-Bnzh0T75.cjs +2 -0
- package/dist/TextShell-Bnzh0T75.cjs.map +1 -0
- package/dist/assets/index.css +1 -1
- package/dist/{index-BCgRoF_u.js → index-CZTUyiPe.js} +1154 -1113
- package/dist/index-CZTUyiPe.js.map +1 -0
- package/dist/index-DwUOvMxg.cjs +2 -0
- package/dist/index-DwUOvMxg.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +98 -55
- package/dist/index.js +1 -1
- package/dist/testing.d.ts +1 -0
- package/dist/usePreviewToggle-BG-pfsgP.js +323 -0
- package/dist/usePreviewToggle-BG-pfsgP.js.map +1 -0
- package/dist/usePreviewToggle-DXQT07ws.cjs +2 -0
- package/dist/usePreviewToggle-DXQT07ws.cjs.map +1 -0
- package/package.json +2 -2
- package/src/components/CustomMessage/CustomMessage.stories.tsx +54 -1
- package/src/components/CustomMessage/MessageTag.tsx +8 -0
- package/src/components/CustomMessage/index.tsx +61 -22
- package/src/components/LockedAttachment/LockedAttachment.stories.tsx +410 -333
- package/src/components/LockedAttachment/LockedAttachment.test.tsx +104 -0
- package/src/components/LockedAttachment/components/Composer/Card.tsx +97 -120
- package/src/components/LockedAttachment/components/Media/Card.tsx +237 -0
- package/src/components/LockedAttachment/components/Text/Card.tsx +177 -0
- package/src/components/LockedAttachment/components/_shared/CardBody.tsx +3 -3
- package/src/components/LockedAttachment/components/_shared/CardThumbnail.tsx +92 -0
- package/src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx +11 -33
- package/src/components/LockedAttachment/components/_shared/LoadingDots.tsx +36 -0
- package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +21 -11
- package/src/components/LockedAttachment/components/_shared/{LockedCardShell.tsx → MediaShell.tsx} +5 -5
- package/src/components/LockedAttachment/components/_shared/PreviewToggle.tsx +58 -0
- package/src/components/LockedAttachment/components/_shared/PriceLockRow.tsx +21 -0
- package/src/components/LockedAttachment/components/_shared/PurchaseStatusBadge.tsx +87 -0
- package/src/components/LockedAttachment/components/_shared/{LockedThumbnail.tsx → SingleThumbnail.tsx} +5 -5
- package/src/components/LockedAttachment/components/_shared/SkeletonTextLines.tsx +39 -0
- package/src/components/LockedAttachment/components/_shared/TextShell.tsx +19 -0
- package/src/components/LockedAttachment/components/_shared/usePreviewToggle.test.ts +67 -0
- package/src/components/LockedAttachment/components/_shared/usePreviewToggle.ts +89 -0
- package/src/components/LockedAttachment/components/_shared/useReceivedSource.ts +83 -0
- package/src/components/LockedAttachment/index.tsx +17 -28
- package/src/components/LockedAttachment/types.ts +28 -4
- package/src/index.ts +2 -5
- package/src/stream-custom-data.ts +1 -0
- package/src/styles.css +5 -0
- package/dist/Card-BRvcFjsq.js +0 -132
- package/dist/Card-BRvcFjsq.js.map +0 -1
- package/dist/Card-BuXkok0A.cjs +0 -2
- package/dist/Card-BuXkok0A.cjs.map +0 -1
- package/dist/Card-CvNHv3me.js +0 -107
- package/dist/Card-CvNHv3me.js.map +0 -1
- package/dist/Card-DOSuQdnk.cjs +0 -2
- package/dist/Card-DOSuQdnk.cjs.map +0 -1
- package/dist/Card-NnQw99XE.cjs +0 -2
- package/dist/Card-NnQw99XE.cjs.map +0 -1
- package/dist/Card-jGOcSN1O.js +0 -163
- package/dist/Card-jGOcSN1O.js.map +0 -1
- package/dist/LockedThumbnail-EsjaAqLR.js +0 -220
- package/dist/LockedThumbnail-EsjaAqLR.js.map +0 -1
- package/dist/LockedThumbnail-uAauUd5c.cjs +0 -2
- package/dist/LockedThumbnail-uAauUd5c.cjs.map +0 -1
- package/dist/index-BCgRoF_u.js.map +0 -1
- package/dist/index-DRurVQ0-.cjs +0 -2
- package/dist/index-DRurVQ0-.cjs.map +0 -1
- package/src/components/LockedAttachment/components/Composer/index.ts +0 -2
- package/src/components/LockedAttachment/components/Received/Card.tsx +0 -191
- package/src/components/LockedAttachment/components/Received/index.ts +0 -2
- package/src/components/LockedAttachment/components/Sent/Card.tsx +0 -177
- package/src/components/LockedAttachment/components/Sent/index.ts +0 -2
- /package/src/components/LockedAttachment/components/{Received → Media}/CardActions.tsx +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePreviewToggle-BG-pfsgP.js","sources":["../src/components/LockedAttachment/components/_shared/CardBody.tsx","../src/components/LockedAttachment/components/_shared/LockBadge.tsx","../src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx","../src/components/LockedAttachment/components/_shared/SingleThumbnail.tsx","../src/components/LockedAttachment/components/_shared/CardThumbnail.tsx","../src/components/LockedAttachment/components/_shared/MediaShell.tsx","../src/components/LockedAttachment/components/_shared/PreviewToggle.tsx","../src/components/LockedAttachment/components/_shared/usePreviewToggle.ts"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\n\nimport { renderTypeIcon } from '../../../AttachmentCard'\n\nimport type { CardVariant } from './MediaShell'\n\nexport interface CardBodyProps {\n variant: CardVariant\n title?: string\n placeholderTitle?: string\n mimeType: string\n detail?: string\n statusBadge?: React.ReactNode\n action?: React.ReactNode\n /** Overrides the auto-detected type icon (used by Gallery to swap in an `Images` icon). */\n icon?: React.ReactNode\n /** Optional control rendered on the right of the title/status block (e.g. Composer edit pencil). */\n trailingAction?: React.ReactNode\n}\n\n/**\n * Title + status row layout shared by Composer and `LockedAttachment.Media`.\n * Layout matches the Figma `Container > Labels` group (16px h-padding, 12px v-padding,\n * 4px gap between title and status row, 4px gap inside status row).\n */\nconst CardBody: React.FC<CardBodyProps> = ({\n variant,\n title,\n placeholderTitle = 'Attachment title',\n mimeType,\n detail,\n statusBadge,\n action,\n icon,\n trailingAction,\n}) => {\n const isDark = variant === 'dark'\n const displayTitle = isDark ? (title ?? placeholderTitle) : (title ?? '')\n const titleDimmed = isDark && !title\n\n const typeIcon =\n icon ??\n renderTypeIcon(mimeType, {\n className: classNames(\n 'size-5 shrink-0',\n isDark ? 'text-white/55' : 'text-black/55'\n ),\n weight: 'regular',\n })\n\n return (\n <div className=\"px-4 py-3\">\n <div className=\"flex items-end gap-3\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n {displayTitle.trim() !== '' && (\n <p\n className={classNames('truncate text-base font-medium leading-6', {\n 'text-black/90': !isDark,\n 'text-white/30': isDark && titleDimmed,\n 'text-white': isDark && !titleDimmed,\n })}\n >\n {displayTitle}\n </p>\n )}\n\n <div className=\"flex flex-wrap items-center gap-1\">\n {typeIcon}\n\n {detail != null && detail !== '' && (\n <span\n className={classNames(\n 'text-xs font-medium',\n isDark ? 'text-white/55' : 'text-black/55'\n )}\n >\n {detail}\n </span>\n )}\n\n {statusBadge}\n </div>\n </div>\n\n {trailingAction && <div className=\"shrink-0\">{trailingAction}</div>}\n </div>\n\n {action}\n </div>\n )\n}\n\nexport default CardBody\n","import { LockOpenIcon, LockSimpleIcon, PlayIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport { getSourceType } from '../../../AttachmentCard'\nimport type { PaymentStatus } from '../../types'\n\nexport interface LockBadgeProps {\n paymentStatus?: PaymentStatus\n mimeType?: string\n /**\n * Overrides the `mimeType`-derived playable check. Lets a caller that\n * already knows per-item playability (e.g. `GalleryThumbnail`, checking a\n * carousel item's own mimeType rather than the card's single `mimeType`)\n * skip re-deriving it.\n */\n isPlayable?: boolean\n}\n\n/**\n * Centered 48x48 lock badge that overlays the thumbnail of any locked attachment.\n * Uses `bg-black/25` from the design system's `alpha-black-25` token.\n *\n * For playable media (video/audio), the badge shows a play icon instead of a\n * lock — matching the convention used by `GalleryThumbnail`.\n */\nexport const LockBadge: React.FC<LockBadgeProps> = ({\n paymentStatus,\n mimeType,\n isPlayable,\n}) => {\n const sourceType = mimeType ? getSourceType(mimeType) : undefined\n const resolvedIsPlayable =\n isPlayable ?? (sourceType === 'video' || sourceType === 'audio')\n\n const Icon = resolvedIsPlayable\n ? PlayIcon\n : paymentStatus === 'paid'\n ? LockOpenIcon\n : LockSimpleIcon\n return (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center\">\n <div className=\"flex size-12 items-center justify-center rounded-full bg-black/25 text-white\">\n <Icon className=\"size-6\" weight=\"fill\" />\n </div>\n </div>\n )\n}\n\nexport default LockBadge\n","import { CaretLeftIcon, CaretRightIcon } from '@phosphor-icons/react'\nimport classNames from 'classnames'\nimport React, { useState } from 'react'\n\nimport { AttachmentThumbnail, getSourceType } from '../../../AttachmentCard'\nimport type {\n LockedAttachmentGalleryItem,\n PaymentStatus,\n} from '../../types'\n\nimport { LockBadge } from './LockBadge'\nimport type { CardVariant } from './MediaShell'\n\nexport interface GalleryThumbnailProps {\n variant: CardVariant\n gallery: LockedAttachmentGalleryItem[]\n title?: string\n /** When true, all items are shown blurred + the locked/play badge is overlaid. */\n showLocked: boolean\n paymentStatus?: PaymentStatus\n /** Top-right slot (e.g. dismiss X on Composer). Rendered inside the thumbnail. */\n topRight?: React.ReactNode\n}\n\nfunction isPlayableItem(item: LockedAttachmentGalleryItem): boolean {\n const sourceType = getSourceType(item.mimeType)\n return sourceType === 'video' || sourceType === 'audio'\n}\n\n/**\n * Mixed-media carousel used by every LockedAttachment card when its `gallery`\n * prop has 2+ items. Matches the \"Gallery\" frames in the Figma design system:\n * 337/386 aspect ratio, prev/next caret buttons, a counter pill, and a center\n * lock / play indicator that swaps based on the current item.\n */\nconst GalleryThumbnail: React.FC<GalleryThumbnailProps> = ({\n variant,\n gallery,\n title,\n showLocked,\n paymentStatus,\n topRight,\n}) => {\n const [index, setIndex] = useState(0)\n const total = gallery.length\n const safeIndex = Math.min(index, total - 1)\n const current = gallery[safeIndex]\n const isVideoItem = isPlayableItem(current)\n\n // Stop propagation so arrow taps don't bubble up to the outer preview-toggle\n // wrapper on ComposerCard / OwnMediaCard.\n const goPrev = (e: React.MouseEvent) => {\n e.stopPropagation()\n setIndex((i) => Math.max(0, i - 1))\n }\n const goNext = (e: React.MouseEvent) => {\n e.stopPropagation()\n setIndex((i) => Math.min(total - 1, i + 1))\n }\n const atStart = safeIndex === 0\n const atEnd = safeIndex === total - 1\n\n const isDark = variant === 'dark'\n\n // Locked + unlocked render entirely separate trees so the locked state\n // doesn't end up stacking a blurred `<img>` on top of an underlying\n // `AttachmentThumbnail` (whose `bg-white/10` poster shell otherwise\n // shows through as a visible horizontal seam at the 16:9 boundary\n // inside the taller 337/386 gallery aspect).\n //\n // The locked branch uses `filter: blur` on a single full-size `<img>`\n // — not `backdrop-filter` — so the rounded corners are clipped\n // normally without any clip-path workarounds (see SingleThumbnail).\n return (\n <div className=\"relative aspect-[337/386] overflow-hidden rounded-t-md\">\n {showLocked ? (\n <div\n className={classNames(\n 'absolute inset-0',\n isDark ? 'bg-white/10' : 'bg-black/5'\n )}\n >\n {current.thumbnailUrl && (\n <img\n src={current.thumbnailUrl}\n alt=\"\"\n aria-hidden\n draggable={false}\n // `scale-110` hides the fuzzy edge that `filter: blur` leaves\n // around the image bounds.\n className=\"absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]\"\n />\n )}\n </div>\n ) : (\n <AttachmentThumbnail\n mimeType={current.mimeType}\n sourceUrl={current.sourceUrl}\n thumbnailUrl={current.thumbnailUrl}\n title={title}\n variant={variant}\n />\n )}\n\n {/* PLAY for video items (locked or not — video needs a play affordance\n either way); LOCK for non-video locked items. Unlocked non-video\n items show no badge — the image is the content. */}\n {(isVideoItem || showLocked) && (\n <LockBadge paymentStatus={paymentStatus} isPlayable={isVideoItem} />\n )}\n\n {total > 1 && (\n <React.Fragment>\n <button\n type=\"button\"\n onClick={goPrev}\n disabled={atStart}\n aria-label=\"Previous item\"\n className={classNames(\n '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',\n atStart ? 'opacity-40' : 'hover:bg-black/40'\n )}\n >\n <CaretLeftIcon className=\"size-5\" weight=\"bold\" />\n </button>\n <button\n type=\"button\"\n onClick={goNext}\n disabled={atEnd}\n aria-label=\"Next item\"\n className={classNames(\n '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',\n atEnd ? 'opacity-40' : 'hover:bg-black/40'\n )}\n >\n <CaretRightIcon className=\"size-5\" weight=\"bold\" />\n </button>\n\n <div className=\"pointer-events-none absolute bottom-5 left-1/2 -translate-x-1/2 rounded-lg bg-black/30 px-2 py-1\">\n <span className=\"text-xs font-medium leading-4 text-white\">\n {safeIndex + 1}/{total}\n </span>\n </div>\n </React.Fragment>\n )}\n\n {topRight && (\n <div className=\"pointer-events-auto absolute right-3 top-3 z-10\">\n {topRight}\n </div>\n )}\n </div>\n )\n}\n\nexport default GalleryThumbnail\n","import classNames from 'classnames'\nimport React from 'react'\n\nimport {\n AttachmentThumbnail,\n renderTypeIcon,\n} from '../../../AttachmentCard'\nimport type { LockedAttachmentSource, PaymentStatus } from '../../types'\n\nimport { LockBadge } from './LockBadge'\nimport type { CardVariant } from './MediaShell'\n\nexport interface SingleThumbnailProps {\n variant: CardVariant\n mimeType: string\n thumbnailUrl?: string\n title?: string\n /**\n * When provided, the underlying source is shown unblurred (preview / unlocked state).\n * When undefined, the thumbnail is treated as locked: blurred with a central lock badge.\n */\n source?: LockedAttachmentSource\n /**\n * Forces the locked appearance even when a source is provided. Used for the\n * Composer card where the locked treatment is the default and the user toggles\n * a preview in place.\n */\n showLocked: boolean\n paymentStatus?: PaymentStatus\n /** Top-right overlay (e.g. dismiss X on Composer). Rendered inside the thumbnail. */\n topRight?: React.ReactNode\n /** When true, renders the unlocked image with aspect-video + object-contain. */\n containedImage?: boolean\n}\n\n/**\n * Renders the 180px-tall media area for a LockedAttachment card.\n * Handles three visual states:\n * - locked: blurred thumbnail + centered 48px lock badge\n * - preview/paid: clear thumbnail (the underlying source)\n * - empty: type-icon placeholder\n */\nconst SingleThumbnail: React.FC<SingleThumbnailProps> = ({\n variant,\n mimeType,\n thumbnailUrl,\n title,\n source,\n showLocked,\n paymentStatus,\n topRight,\n containedImage = false,\n}) => {\n const effectiveSourceUrl = showLocked ? undefined : source?.sourceUrl\n const effectiveThumbnailUrl = showLocked\n ? thumbnailUrl\n : (source?.thumbnailUrl ?? thumbnailUrl)\n\n const isDark = variant === 'dark'\n\n // Locked + unlocked render entirely separate trees so the locked state\n // doesn't end up stacking a blurred `<img>` on top of an underlying\n // `AttachmentThumbnail` (whose `bg-white/10` poster shell otherwise\n // shows through as a visible horizontal seam at the 16:9 boundary).\n //\n // The locked branch uses `filter: blur` on a single full-size `<img>`\n // — not `backdrop-filter` — because `backdrop-filter` paints in its\n // own compositing layer that escapes ancestor `overflow: hidden` on\n // Chrome/Safari and flattens the card's top corners. `filter` is\n // clipped normally, so the rounded corners stay round without any\n // clip-path workarounds.\n return (\n <div className=\"relative overflow-hidden rounded-t-md\">\n {showLocked ? (\n <div\n className={classNames(\n 'relative aspect-video overflow-hidden',\n isDark ? 'bg-white/10' : 'bg-black/5'\n )}\n >\n {effectiveThumbnailUrl ? (\n <img\n src={effectiveThumbnailUrl}\n alt=\"\"\n aria-hidden\n draggable={false}\n // `scale-110` hides the fuzzy semi-transparent edge that\n // `filter: blur` leaves around the image bounds.\n className=\"absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]\"\n />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n {renderTypeIcon(mimeType, {\n className: isDark\n ? 'size-12 text-white/20'\n : 'size-12 text-black/20',\n weight: 'regular',\n })}\n </div>\n )}\n <LockBadge paymentStatus={paymentStatus} mimeType={mimeType} />\n </div>\n ) : (\n <AttachmentThumbnail\n mimeType={mimeType}\n sourceUrl={effectiveSourceUrl}\n thumbnailUrl={effectiveThumbnailUrl}\n title={title}\n variant={variant}\n containedImage={containedImage}\n mediaPlayerProps={\n effectiveSourceUrl\n ? { autoPlay: true, loop: true, controls: true, muted: false }\n : undefined\n }\n />\n )}\n\n {topRight && (\n <div className=\"pointer-events-auto absolute right-3 top-3 z-10\">\n {topRight}\n </div>\n )}\n </div>\n )\n}\n\nexport default SingleThumbnail\n","import { ImagesIcon } from '@phosphor-icons/react'\nimport type React from 'react'\n\nimport type {\n LockedAttachmentGalleryItem,\n LockedAttachmentSource,\n PaymentStatus,\n} from '../../types'\n\nimport GalleryThumbnail from './GalleryThumbnail'\nimport type { CardVariant } from './MediaShell'\nimport SingleThumbnail from './SingleThumbnail'\n\nexport interface CardThumbnailProps {\n variant: CardVariant\n gallery: LockedAttachmentGalleryItem[]\n title?: string\n showLocked: boolean\n paymentStatus?: PaymentStatus\n /** Single-asset props — ignored when the card renders as a gallery. */\n mimeType: string\n thumbnailUrl?: string\n source?: LockedAttachmentSource\n containedImage?: boolean\n /** Top-right overlay (e.g. Composer dismiss X). Rendered inside the thumbnail. */\n topRight?: React.ReactNode\n}\n\n/** True when the card should render as a mixed-media carousel (2+ items). */\nexport const isGalleryCard = (\n gallery: LockedAttachmentGalleryItem[]\n): boolean => gallery.length >= 2\n\n/**\n * The body-row icon a card shows when it renders as a gallery — `CardBody`\n * otherwise auto-detects the icon from `mimeType`. Returned as a ready node so\n * every card shares the same size/tone treatment.\n */\nexport const galleryBodyIcon = (\n variant: CardVariant\n): React.ReactNode => (\n <ImagesIcon\n className={\n variant === 'dark'\n ? 'size-5 shrink-0 text-white/55'\n : 'size-5 shrink-0 text-black/55'\n }\n />\n)\n\n/**\n * Owns the single-vs-gallery thumbnail decision shared by Composer /\n * `LockedAttachment.Media` cards: renders `GalleryThumbnail` for a 2+ item `gallery`,\n * else `SingleThumbnail` for the single asset. Callers pass the superset of\n * props; the unused half is ignored by whichever branch renders.\n */\nconst CardThumbnail: React.FC<CardThumbnailProps> = ({\n variant,\n gallery,\n title,\n showLocked,\n paymentStatus,\n mimeType,\n thumbnailUrl,\n source,\n containedImage,\n topRight,\n}) =>\n isGalleryCard(gallery) ? (\n <GalleryThumbnail\n variant={variant}\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n topRight={topRight}\n />\n ) : (\n <SingleThumbnail\n variant={variant}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n title={title}\n source={source}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n topRight={topRight}\n containedImage={containedImage}\n />\n )\n\nexport default CardThumbnail\n","import classNames from 'classnames'\nimport React from 'react'\n\nexport type CardVariant = 'dark' | 'light'\n\nexport interface MediaShellProps {\n variant: CardVariant\n children: React.ReactNode\n rootRef?: React.Ref<HTMLDivElement>\n 'data-testid'?: string\n}\n\n/**\n * Outer chrome for every LockedAttachment card.\n * Mirrors the `shadow-400` + 16px radius treatment from the Figma design system.\n */\nconst MediaShell: React.FC<MediaShellProps> = ({\n variant,\n children,\n rootRef,\n 'data-testid': dataTestId,\n}) => (\n <div\n ref={rootRef}\n data-testid={dataTestId}\n className={classNames(\n 'relative w-[280px] select-none overflow-hidden rounded-md',\n '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)]',\n variant === 'dark' ? 'bg-[#1e2330]' : 'bg-white'\n )}\n >\n {children}\n </div>\n)\n\nexport default MediaShell\n","import React from 'react'\n\nexport interface PreviewToggleProps {\n /** Toggles the preview; omit to render `children` with no wrapper at all (nothing to toggle). */\n onToggle: (() => void | Promise<void>) | undefined\n isBusy: boolean\n isPreviewVisible: boolean\n children: React.ReactNode\n}\n\n/**\n * Makes a locked thumbnail clickable to toggle its preview. Uses a\n * `role=\"button\"` div rather than a native `<button>` because the thumbnail\n * it wraps can itself contain interactive children (gallery carousel arrows,\n * a Composer dismiss X) — nesting a real `<button>` around those would\n * produce invalid, inaccessible nested-interactive-element markup.\n */\nconst PreviewToggle: React.FC<PreviewToggleProps> = ({\n onToggle,\n isBusy,\n isPreviewVisible,\n children,\n}) => {\n if (!onToggle) return <React.Fragment>{children}</React.Fragment>\n\n return (\n <div\n role=\"button\"\n tabIndex={isBusy ? -1 : 0}\n aria-label=\"Toggle preview\"\n aria-busy={isBusy}\n aria-pressed={isPreviewVisible}\n aria-disabled={isBusy || undefined}\n onClick={isBusy ? undefined : onToggle}\n onKeyDown={(e) => {\n if (isBusy) return\n // Only handle keys that originate on the wrapper itself, not on\n // inner interactive elements (dismiss X, carousel arrows). Without\n // this guard, pressing Enter/Space on a focused child would bubble\n // up and toggle the preview in addition to activating the child.\n if (e.target !== e.currentTarget) return\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n void onToggle()\n }\n }}\n className={\n !isBusy\n ? 'block w-full cursor-pointer text-left'\n : 'block w-full text-left'\n }\n >\n {children}\n </div>\n )\n}\n\nexport default PreviewToggle\n","import { useCallback, useRef, useState } from 'react'\n\nimport type { LockedAttachmentSource } from '../../types'\n\nexport interface UsePreviewToggleOptions {\n /** Gallery items carry their own per-item sources on the `gallery` prop already, so toggling skips the async fetch entirely. */\n isGallery: boolean\n /**\n * Lazily loads the underlying source; the resolved value is cached in\n * `source` and reused on subsequent toggles.\n */\n onFetchSource?: () => Promise<LockedAttachmentSource | void>\n /** Fired on every toggle tap, before any visibility/fetch logic runs. */\n onPreviewClick?: () => void\n}\n\nexport interface UsePreviewToggleResult {\n source: LockedAttachmentSource | undefined\n isPreviewVisible: boolean\n isLoadingPreview: boolean\n handleToggle: () => Promise<void>\n /**\n * `handleToggle` when the card can actually be previewed (gallery, or a\n * fetch/click handler is wired), else `undefined` — pass straight to\n * `PreviewToggle.onToggle` so a non-previewable card renders no\n * toggle affordance.\n */\n togglePreview: (() => Promise<void>) | undefined\n}\n\n/**\n * Shared preview-toggle state for Composer/Media isMine: flips a locked thumbnail to\n * its unlocked preview, lazily fetching and caching the source on first\n * reveal. Media !isMine doesn't use this — it fetches on scroll-into-view/paid\n * instead of on a toggle tap.\n */\nexport function usePreviewToggle({\n isGallery,\n onFetchSource,\n onPreviewClick,\n}: UsePreviewToggleOptions): UsePreviewToggleResult {\n const [source, setSource] = useState<LockedAttachmentSource | undefined>()\n const [isPreviewVisible, setIsPreviewVisible] = useState(false)\n const [isLoadingPreview, setIsLoadingPreview] = useState(false)\n const fetchingRef = useRef(false)\n\n const handleToggle = useCallback(async () => {\n onPreviewClick?.()\n if (isPreviewVisible) {\n setIsPreviewVisible(false)\n return\n }\n if (isGallery) {\n setIsPreviewVisible(true)\n return\n }\n if (source) {\n setIsPreviewVisible(true)\n return\n }\n if (!onFetchSource) return\n if (fetchingRef.current) return\n fetchingRef.current = true\n setIsLoadingPreview(true)\n try {\n const result = await onFetchSource()\n if (result) {\n setSource(result)\n setIsPreviewVisible(true)\n }\n } finally {\n fetchingRef.current = false\n setIsLoadingPreview(false)\n }\n }, [isPreviewVisible, isGallery, source, onPreviewClick, onFetchSource])\n\n const togglePreview =\n isGallery || onFetchSource != null || onPreviewClick != null\n ? handleToggle\n : undefined\n\n return {\n source,\n isPreviewVisible,\n isLoadingPreview,\n handleToggle,\n togglePreview,\n }\n}\n"],"names":["CardBody","variant","title","placeholderTitle","mimeType","detail","statusBadge","action","icon","trailingAction","isDark","displayTitle","titleDimmed","typeIcon","renderTypeIcon","classNames","jsxs","jsx","LockBadge","paymentStatus","isPlayable","sourceType","getSourceType","PlayIcon","LockOpenIcon","LockSimpleIcon","isPlayableItem","item","GalleryThumbnail","gallery","showLocked","topRight","index","setIndex","useState","total","safeIndex","current","isVideoItem","goPrev","e","i","goNext","atStart","atEnd","AttachmentThumbnail","React","CaretLeftIcon","CaretRightIcon","SingleThumbnail","thumbnailUrl","source","containedImage","effectiveSourceUrl","effectiveThumbnailUrl","isGalleryCard","galleryBodyIcon","ImagesIcon","CardThumbnail","MediaShell","children","rootRef","dataTestId","PreviewToggle","onToggle","isBusy","isPreviewVisible","usePreviewToggle","isGallery","onFetchSource","onPreviewClick","setSource","setIsPreviewVisible","isLoadingPreview","setIsLoadingPreview","fetchingRef","useRef","handleToggle","useCallback","result","togglePreview"],"mappings":";;;;;AA0BA,MAAMA,IAAoC,CAAC;AAAA,EACzC,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC;AAAA,EACA,gBAAAC;AACF,MAAM;AACJ,QAAMC,IAAST,MAAY,QACrBU,IAAeD,IAAUR,KAASC,IAAqBD,KAAS,IAChEU,IAAcF,KAAU,CAACR,GAEzBW,IACJL,KACAM,EAAeV,GAAU;AAAA,IACvB,WAAWW;AAAA,MACT;AAAA,MACAL,IAAS,kBAAkB;AAAA,IAAA;AAAA,IAE7B,QAAQ;AAAA,EAAA,CACT;AAEH,SACE,gBAAAM,EAAC,OAAA,EAAI,WAAU,aACb,UAAA;AAAA,IAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,wBACb,UAAA;AAAA,MAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,sCACZ,UAAA;AAAA,QAAAL,EAAa,WAAW,MACvB,gBAAAM;AAAA,UAAC;AAAA,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jsx-runtime"),m=require("classnames"),g=require("./index-DwUOvMxg.cjs"),b=require("react"),h=require("@phosphor-icons/react"),T=({variant:s,title:t,placeholderTitle:r="Attachment title",mimeType:i,detail:a,statusBadge:n,action:d,icon:u,trailingAction:o})=>{const l=s==="dark",c=l?t??r:t??"",x=l&&!t,f=u??g.renderTypeIcon(i,{className:m("size-5 shrink-0",l?"text-white/55":"text-black/55"),weight:"regular"});return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[c.trim()!==""&&e.jsx("p",{className:m("truncate text-base font-medium leading-6",{"text-black/90":!l,"text-white/30":l&&x,"text-white":l&&!x}),children:c}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[f,a!=null&&a!==""&&e.jsx("span",{className:m("text-xs font-medium",l?"text-white/55":"text-black/55"),children:a}),n]})]}),o&&e.jsx("div",{className:"shrink-0",children:o})]}),d]})},N=({paymentStatus:s,mimeType:t,isPlayable:r})=>{const i=t?g.getSourceType(t):void 0,n=r??(i==="video"||i==="audio")?h.PlayIcon:s==="paid"?h.LockOpenIcon:h.LockSimpleIcon;return e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-black/25 text-white",children:e.jsx(n,{className:"size-6",weight:"fill"})})})};function P(s){const t=g.getSourceType(s.mimeType);return t==="video"||t==="audio"}const z=({variant:s,gallery:t,title:r,showLocked:i,paymentStatus:a,topRight:n})=>{const[d,u]=b.useState(0),o=t.length,l=Math.min(d,o-1),c=t[l],x=P(c),f=p=>{p.stopPropagation(),u(v=>Math.max(0,v-1))},k=p=>{p.stopPropagation(),u(v=>Math.min(o-1,v+1))},j=l===0,y=l===o-1,I=s==="dark";return e.jsxs("div",{className:"relative aspect-[337/386] overflow-hidden rounded-t-md",children:[i?e.jsx("div",{className:m("absolute inset-0",I?"bg-white/10":"bg-black/5"),children:c.thumbnailUrl&&e.jsx("img",{src:c.thumbnailUrl,alt:"","aria-hidden":!0,draggable:!1,className:"absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"})}):e.jsx(g.AttachmentThumbnail,{mimeType:c.mimeType,sourceUrl:c.sourceUrl,thumbnailUrl:c.thumbnailUrl,title:r,variant:s}),(x||i)&&e.jsx(N,{paymentStatus:a,isPlayable:x}),o>1&&e.jsxs(b.Fragment,{children:[e.jsx("button",{type:"button",onClick:f,disabled:j,"aria-label":"Previous item",className:m("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",j?"opacity-40":"hover:bg-black/40"),children:e.jsx(h.CaretLeftIcon,{className:"size-5",weight:"bold"})}),e.jsx("button",{type:"button",onClick:k,disabled:y,"aria-label":"Next item",className:m("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",y?"opacity-40":"hover:bg-black/40"),children:e.jsx(h.CaretRightIcon,{className:"size-5",weight:"bold"})}),e.jsx("div",{className:"pointer-events-none absolute bottom-5 left-1/2 -translate-x-1/2 rounded-lg bg-black/30 px-2 py-1",children:e.jsxs("span",{className:"text-xs font-medium leading-4 text-white",children:[l+1,"/",o]})})]}),n&&e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:n})]})},U=({variant:s,mimeType:t,thumbnailUrl:r,title:i,source:a,showLocked:n,paymentStatus:d,topRight:u,containedImage:o=!1})=>{const l=n||a==null?void 0:a.sourceUrl,c=n?r:(a==null?void 0:a.thumbnailUrl)??r,x=s==="dark";return e.jsxs("div",{className:"relative overflow-hidden rounded-t-md",children:[n?e.jsxs("div",{className:m("relative aspect-video overflow-hidden",x?"bg-white/10":"bg-black/5"),children:[c?e.jsx("img",{src:c,alt:"","aria-hidden":!0,draggable:!1,className:"absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:g.renderTypeIcon(t,{className:x?"size-12 text-white/20":"size-12 text-black/20",weight:"regular"})}),e.jsx(N,{paymentStatus:d,mimeType:t})]}):e.jsx(g.AttachmentThumbnail,{mimeType:t,sourceUrl:l,thumbnailUrl:c,title:i,variant:s,containedImage:o,mediaPlayerProps:l?{autoPlay:!0,loop:!0,controls:!0,muted:!1}:void 0}),u&&e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:u})]})},w=s=>s.length>=2,_=s=>e.jsx(h.ImagesIcon,{className:s==="dark"?"size-5 shrink-0 text-white/55":"size-5 shrink-0 text-black/55"}),S=({variant:s,gallery:t,title:r,showLocked:i,paymentStatus:a,mimeType:n,thumbnailUrl:d,source:u,containedImage:o,topRight:l})=>w(t)?e.jsx(z,{variant:s,gallery:t,title:r,showLocked:i,paymentStatus:a,topRight:l}):e.jsx(U,{variant:s,mimeType:n,thumbnailUrl:d,title:r,source:u,showLocked:i,paymentStatus:a,topRight:l,containedImage:o}),C=({variant:s,children:t,rootRef:r,"data-testid":i})=>e.jsx("div",{ref:r,"data-testid":i,className:m("relative w-[280px] select-none overflow-hidden rounded-md","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)]",s==="dark"?"bg-[#1e2330]":"bg-white"),children:t}),D=({onToggle:s,isBusy:t,isPreviewVisible:r,children:i})=>s?e.jsx("div",{role:"button",tabIndex:t?-1:0,"aria-label":"Toggle preview","aria-busy":t,"aria-pressed":r,"aria-disabled":t||void 0,onClick:t?void 0:s,onKeyDown:a=>{t||a.target===a.currentTarget&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},className:t?"block w-full text-left":"block w-full cursor-pointer text-left",children:i}):e.jsx(b.Fragment,{children:i});function q({isGallery:s,onFetchSource:t,onPreviewClick:r}){const[i,a]=b.useState(),[n,d]=b.useState(!1),[u,o]=b.useState(!1),l=b.useRef(!1),c=b.useCallback(async()=>{if(r==null||r(),n){d(!1);return}if(s){d(!0);return}if(i){d(!0);return}if(t&&!l.current){l.current=!0,o(!0);try{const f=await t();f&&(a(f),d(!0))}finally{l.current=!1,o(!1)}}},[n,s,i,r,t]),x=s||t!=null||r!=null?c:void 0;return{source:i,isPreviewVisible:n,isLoadingPreview:u,handleToggle:c,togglePreview:x}}exports.CardBody=T;exports.CardThumbnail=S;exports.MediaShell=C;exports.PreviewToggle=D;exports.galleryBodyIcon=_;exports.isGalleryCard=w;exports.usePreviewToggle=q;
|
|
2
|
+
//# sourceMappingURL=usePreviewToggle-DXQT07ws.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePreviewToggle-DXQT07ws.cjs","sources":["../src/components/LockedAttachment/components/_shared/CardBody.tsx","../src/components/LockedAttachment/components/_shared/LockBadge.tsx","../src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx","../src/components/LockedAttachment/components/_shared/SingleThumbnail.tsx","../src/components/LockedAttachment/components/_shared/CardThumbnail.tsx","../src/components/LockedAttachment/components/_shared/MediaShell.tsx","../src/components/LockedAttachment/components/_shared/PreviewToggle.tsx","../src/components/LockedAttachment/components/_shared/usePreviewToggle.ts"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\n\nimport { renderTypeIcon } from '../../../AttachmentCard'\n\nimport type { CardVariant } from './MediaShell'\n\nexport interface CardBodyProps {\n variant: CardVariant\n title?: string\n placeholderTitle?: string\n mimeType: string\n detail?: string\n statusBadge?: React.ReactNode\n action?: React.ReactNode\n /** Overrides the auto-detected type icon (used by Gallery to swap in an `Images` icon). */\n icon?: React.ReactNode\n /** Optional control rendered on the right of the title/status block (e.g. Composer edit pencil). */\n trailingAction?: React.ReactNode\n}\n\n/**\n * Title + status row layout shared by Composer and `LockedAttachment.Media`.\n * Layout matches the Figma `Container > Labels` group (16px h-padding, 12px v-padding,\n * 4px gap between title and status row, 4px gap inside status row).\n */\nconst CardBody: React.FC<CardBodyProps> = ({\n variant,\n title,\n placeholderTitle = 'Attachment title',\n mimeType,\n detail,\n statusBadge,\n action,\n icon,\n trailingAction,\n}) => {\n const isDark = variant === 'dark'\n const displayTitle = isDark ? (title ?? placeholderTitle) : (title ?? '')\n const titleDimmed = isDark && !title\n\n const typeIcon =\n icon ??\n renderTypeIcon(mimeType, {\n className: classNames(\n 'size-5 shrink-0',\n isDark ? 'text-white/55' : 'text-black/55'\n ),\n weight: 'regular',\n })\n\n return (\n <div className=\"px-4 py-3\">\n <div className=\"flex items-end gap-3\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n {displayTitle.trim() !== '' && (\n <p\n className={classNames('truncate text-base font-medium leading-6', {\n 'text-black/90': !isDark,\n 'text-white/30': isDark && titleDimmed,\n 'text-white': isDark && !titleDimmed,\n })}\n >\n {displayTitle}\n </p>\n )}\n\n <div className=\"flex flex-wrap items-center gap-1\">\n {typeIcon}\n\n {detail != null && detail !== '' && (\n <span\n className={classNames(\n 'text-xs font-medium',\n isDark ? 'text-white/55' : 'text-black/55'\n )}\n >\n {detail}\n </span>\n )}\n\n {statusBadge}\n </div>\n </div>\n\n {trailingAction && <div className=\"shrink-0\">{trailingAction}</div>}\n </div>\n\n {action}\n </div>\n )\n}\n\nexport default CardBody\n","import { LockOpenIcon, LockSimpleIcon, PlayIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport { getSourceType } from '../../../AttachmentCard'\nimport type { PaymentStatus } from '../../types'\n\nexport interface LockBadgeProps {\n paymentStatus?: PaymentStatus\n mimeType?: string\n /**\n * Overrides the `mimeType`-derived playable check. Lets a caller that\n * already knows per-item playability (e.g. `GalleryThumbnail`, checking a\n * carousel item's own mimeType rather than the card's single `mimeType`)\n * skip re-deriving it.\n */\n isPlayable?: boolean\n}\n\n/**\n * Centered 48x48 lock badge that overlays the thumbnail of any locked attachment.\n * Uses `bg-black/25` from the design system's `alpha-black-25` token.\n *\n * For playable media (video/audio), the badge shows a play icon instead of a\n * lock — matching the convention used by `GalleryThumbnail`.\n */\nexport const LockBadge: React.FC<LockBadgeProps> = ({\n paymentStatus,\n mimeType,\n isPlayable,\n}) => {\n const sourceType = mimeType ? getSourceType(mimeType) : undefined\n const resolvedIsPlayable =\n isPlayable ?? (sourceType === 'video' || sourceType === 'audio')\n\n const Icon = resolvedIsPlayable\n ? PlayIcon\n : paymentStatus === 'paid'\n ? LockOpenIcon\n : LockSimpleIcon\n return (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center\">\n <div className=\"flex size-12 items-center justify-center rounded-full bg-black/25 text-white\">\n <Icon className=\"size-6\" weight=\"fill\" />\n </div>\n </div>\n )\n}\n\nexport default LockBadge\n","import { CaretLeftIcon, CaretRightIcon } from '@phosphor-icons/react'\nimport classNames from 'classnames'\nimport React, { useState } from 'react'\n\nimport { AttachmentThumbnail, getSourceType } from '../../../AttachmentCard'\nimport type {\n LockedAttachmentGalleryItem,\n PaymentStatus,\n} from '../../types'\n\nimport { LockBadge } from './LockBadge'\nimport type { CardVariant } from './MediaShell'\n\nexport interface GalleryThumbnailProps {\n variant: CardVariant\n gallery: LockedAttachmentGalleryItem[]\n title?: string\n /** When true, all items are shown blurred + the locked/play badge is overlaid. */\n showLocked: boolean\n paymentStatus?: PaymentStatus\n /** Top-right slot (e.g. dismiss X on Composer). Rendered inside the thumbnail. */\n topRight?: React.ReactNode\n}\n\nfunction isPlayableItem(item: LockedAttachmentGalleryItem): boolean {\n const sourceType = getSourceType(item.mimeType)\n return sourceType === 'video' || sourceType === 'audio'\n}\n\n/**\n * Mixed-media carousel used by every LockedAttachment card when its `gallery`\n * prop has 2+ items. Matches the \"Gallery\" frames in the Figma design system:\n * 337/386 aspect ratio, prev/next caret buttons, a counter pill, and a center\n * lock / play indicator that swaps based on the current item.\n */\nconst GalleryThumbnail: React.FC<GalleryThumbnailProps> = ({\n variant,\n gallery,\n title,\n showLocked,\n paymentStatus,\n topRight,\n}) => {\n const [index, setIndex] = useState(0)\n const total = gallery.length\n const safeIndex = Math.min(index, total - 1)\n const current = gallery[safeIndex]\n const isVideoItem = isPlayableItem(current)\n\n // Stop propagation so arrow taps don't bubble up to the outer preview-toggle\n // wrapper on ComposerCard / OwnMediaCard.\n const goPrev = (e: React.MouseEvent) => {\n e.stopPropagation()\n setIndex((i) => Math.max(0, i - 1))\n }\n const goNext = (e: React.MouseEvent) => {\n e.stopPropagation()\n setIndex((i) => Math.min(total - 1, i + 1))\n }\n const atStart = safeIndex === 0\n const atEnd = safeIndex === total - 1\n\n const isDark = variant === 'dark'\n\n // Locked + unlocked render entirely separate trees so the locked state\n // doesn't end up stacking a blurred `<img>` on top of an underlying\n // `AttachmentThumbnail` (whose `bg-white/10` poster shell otherwise\n // shows through as a visible horizontal seam at the 16:9 boundary\n // inside the taller 337/386 gallery aspect).\n //\n // The locked branch uses `filter: blur` on a single full-size `<img>`\n // — not `backdrop-filter` — so the rounded corners are clipped\n // normally without any clip-path workarounds (see SingleThumbnail).\n return (\n <div className=\"relative aspect-[337/386] overflow-hidden rounded-t-md\">\n {showLocked ? (\n <div\n className={classNames(\n 'absolute inset-0',\n isDark ? 'bg-white/10' : 'bg-black/5'\n )}\n >\n {current.thumbnailUrl && (\n <img\n src={current.thumbnailUrl}\n alt=\"\"\n aria-hidden\n draggable={false}\n // `scale-110` hides the fuzzy edge that `filter: blur` leaves\n // around the image bounds.\n className=\"absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]\"\n />\n )}\n </div>\n ) : (\n <AttachmentThumbnail\n mimeType={current.mimeType}\n sourceUrl={current.sourceUrl}\n thumbnailUrl={current.thumbnailUrl}\n title={title}\n variant={variant}\n />\n )}\n\n {/* PLAY for video items (locked or not — video needs a play affordance\n either way); LOCK for non-video locked items. Unlocked non-video\n items show no badge — the image is the content. */}\n {(isVideoItem || showLocked) && (\n <LockBadge paymentStatus={paymentStatus} isPlayable={isVideoItem} />\n )}\n\n {total > 1 && (\n <React.Fragment>\n <button\n type=\"button\"\n onClick={goPrev}\n disabled={atStart}\n aria-label=\"Previous item\"\n className={classNames(\n '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',\n atStart ? 'opacity-40' : 'hover:bg-black/40'\n )}\n >\n <CaretLeftIcon className=\"size-5\" weight=\"bold\" />\n </button>\n <button\n type=\"button\"\n onClick={goNext}\n disabled={atEnd}\n aria-label=\"Next item\"\n className={classNames(\n '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',\n atEnd ? 'opacity-40' : 'hover:bg-black/40'\n )}\n >\n <CaretRightIcon className=\"size-5\" weight=\"bold\" />\n </button>\n\n <div className=\"pointer-events-none absolute bottom-5 left-1/2 -translate-x-1/2 rounded-lg bg-black/30 px-2 py-1\">\n <span className=\"text-xs font-medium leading-4 text-white\">\n {safeIndex + 1}/{total}\n </span>\n </div>\n </React.Fragment>\n )}\n\n {topRight && (\n <div className=\"pointer-events-auto absolute right-3 top-3 z-10\">\n {topRight}\n </div>\n )}\n </div>\n )\n}\n\nexport default GalleryThumbnail\n","import classNames from 'classnames'\nimport React from 'react'\n\nimport {\n AttachmentThumbnail,\n renderTypeIcon,\n} from '../../../AttachmentCard'\nimport type { LockedAttachmentSource, PaymentStatus } from '../../types'\n\nimport { LockBadge } from './LockBadge'\nimport type { CardVariant } from './MediaShell'\n\nexport interface SingleThumbnailProps {\n variant: CardVariant\n mimeType: string\n thumbnailUrl?: string\n title?: string\n /**\n * When provided, the underlying source is shown unblurred (preview / unlocked state).\n * When undefined, the thumbnail is treated as locked: blurred with a central lock badge.\n */\n source?: LockedAttachmentSource\n /**\n * Forces the locked appearance even when a source is provided. Used for the\n * Composer card where the locked treatment is the default and the user toggles\n * a preview in place.\n */\n showLocked: boolean\n paymentStatus?: PaymentStatus\n /** Top-right overlay (e.g. dismiss X on Composer). Rendered inside the thumbnail. */\n topRight?: React.ReactNode\n /** When true, renders the unlocked image with aspect-video + object-contain. */\n containedImage?: boolean\n}\n\n/**\n * Renders the 180px-tall media area for a LockedAttachment card.\n * Handles three visual states:\n * - locked: blurred thumbnail + centered 48px lock badge\n * - preview/paid: clear thumbnail (the underlying source)\n * - empty: type-icon placeholder\n */\nconst SingleThumbnail: React.FC<SingleThumbnailProps> = ({\n variant,\n mimeType,\n thumbnailUrl,\n title,\n source,\n showLocked,\n paymentStatus,\n topRight,\n containedImage = false,\n}) => {\n const effectiveSourceUrl = showLocked ? undefined : source?.sourceUrl\n const effectiveThumbnailUrl = showLocked\n ? thumbnailUrl\n : (source?.thumbnailUrl ?? thumbnailUrl)\n\n const isDark = variant === 'dark'\n\n // Locked + unlocked render entirely separate trees so the locked state\n // doesn't end up stacking a blurred `<img>` on top of an underlying\n // `AttachmentThumbnail` (whose `bg-white/10` poster shell otherwise\n // shows through as a visible horizontal seam at the 16:9 boundary).\n //\n // The locked branch uses `filter: blur` on a single full-size `<img>`\n // — not `backdrop-filter` — because `backdrop-filter` paints in its\n // own compositing layer that escapes ancestor `overflow: hidden` on\n // Chrome/Safari and flattens the card's top corners. `filter` is\n // clipped normally, so the rounded corners stay round without any\n // clip-path workarounds.\n return (\n <div className=\"relative overflow-hidden rounded-t-md\">\n {showLocked ? (\n <div\n className={classNames(\n 'relative aspect-video overflow-hidden',\n isDark ? 'bg-white/10' : 'bg-black/5'\n )}\n >\n {effectiveThumbnailUrl ? (\n <img\n src={effectiveThumbnailUrl}\n alt=\"\"\n aria-hidden\n draggable={false}\n // `scale-110` hides the fuzzy semi-transparent edge that\n // `filter: blur` leaves around the image bounds.\n className=\"absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]\"\n />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n {renderTypeIcon(mimeType, {\n className: isDark\n ? 'size-12 text-white/20'\n : 'size-12 text-black/20',\n weight: 'regular',\n })}\n </div>\n )}\n <LockBadge paymentStatus={paymentStatus} mimeType={mimeType} />\n </div>\n ) : (\n <AttachmentThumbnail\n mimeType={mimeType}\n sourceUrl={effectiveSourceUrl}\n thumbnailUrl={effectiveThumbnailUrl}\n title={title}\n variant={variant}\n containedImage={containedImage}\n mediaPlayerProps={\n effectiveSourceUrl\n ? { autoPlay: true, loop: true, controls: true, muted: false }\n : undefined\n }\n />\n )}\n\n {topRight && (\n <div className=\"pointer-events-auto absolute right-3 top-3 z-10\">\n {topRight}\n </div>\n )}\n </div>\n )\n}\n\nexport default SingleThumbnail\n","import { ImagesIcon } from '@phosphor-icons/react'\nimport type React from 'react'\n\nimport type {\n LockedAttachmentGalleryItem,\n LockedAttachmentSource,\n PaymentStatus,\n} from '../../types'\n\nimport GalleryThumbnail from './GalleryThumbnail'\nimport type { CardVariant } from './MediaShell'\nimport SingleThumbnail from './SingleThumbnail'\n\nexport interface CardThumbnailProps {\n variant: CardVariant\n gallery: LockedAttachmentGalleryItem[]\n title?: string\n showLocked: boolean\n paymentStatus?: PaymentStatus\n /** Single-asset props — ignored when the card renders as a gallery. */\n mimeType: string\n thumbnailUrl?: string\n source?: LockedAttachmentSource\n containedImage?: boolean\n /** Top-right overlay (e.g. Composer dismiss X). Rendered inside the thumbnail. */\n topRight?: React.ReactNode\n}\n\n/** True when the card should render as a mixed-media carousel (2+ items). */\nexport const isGalleryCard = (\n gallery: LockedAttachmentGalleryItem[]\n): boolean => gallery.length >= 2\n\n/**\n * The body-row icon a card shows when it renders as a gallery — `CardBody`\n * otherwise auto-detects the icon from `mimeType`. Returned as a ready node so\n * every card shares the same size/tone treatment.\n */\nexport const galleryBodyIcon = (\n variant: CardVariant\n): React.ReactNode => (\n <ImagesIcon\n className={\n variant === 'dark'\n ? 'size-5 shrink-0 text-white/55'\n : 'size-5 shrink-0 text-black/55'\n }\n />\n)\n\n/**\n * Owns the single-vs-gallery thumbnail decision shared by Composer /\n * `LockedAttachment.Media` cards: renders `GalleryThumbnail` for a 2+ item `gallery`,\n * else `SingleThumbnail` for the single asset. Callers pass the superset of\n * props; the unused half is ignored by whichever branch renders.\n */\nconst CardThumbnail: React.FC<CardThumbnailProps> = ({\n variant,\n gallery,\n title,\n showLocked,\n paymentStatus,\n mimeType,\n thumbnailUrl,\n source,\n containedImage,\n topRight,\n}) =>\n isGalleryCard(gallery) ? (\n <GalleryThumbnail\n variant={variant}\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n topRight={topRight}\n />\n ) : (\n <SingleThumbnail\n variant={variant}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n title={title}\n source={source}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n topRight={topRight}\n containedImage={containedImage}\n />\n )\n\nexport default CardThumbnail\n","import classNames from 'classnames'\nimport React from 'react'\n\nexport type CardVariant = 'dark' | 'light'\n\nexport interface MediaShellProps {\n variant: CardVariant\n children: React.ReactNode\n rootRef?: React.Ref<HTMLDivElement>\n 'data-testid'?: string\n}\n\n/**\n * Outer chrome for every LockedAttachment card.\n * Mirrors the `shadow-400` + 16px radius treatment from the Figma design system.\n */\nconst MediaShell: React.FC<MediaShellProps> = ({\n variant,\n children,\n rootRef,\n 'data-testid': dataTestId,\n}) => (\n <div\n ref={rootRef}\n data-testid={dataTestId}\n className={classNames(\n 'relative w-[280px] select-none overflow-hidden rounded-md',\n '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)]',\n variant === 'dark' ? 'bg-[#1e2330]' : 'bg-white'\n )}\n >\n {children}\n </div>\n)\n\nexport default MediaShell\n","import React from 'react'\n\nexport interface PreviewToggleProps {\n /** Toggles the preview; omit to render `children` with no wrapper at all (nothing to toggle). */\n onToggle: (() => void | Promise<void>) | undefined\n isBusy: boolean\n isPreviewVisible: boolean\n children: React.ReactNode\n}\n\n/**\n * Makes a locked thumbnail clickable to toggle its preview. Uses a\n * `role=\"button\"` div rather than a native `<button>` because the thumbnail\n * it wraps can itself contain interactive children (gallery carousel arrows,\n * a Composer dismiss X) — nesting a real `<button>` around those would\n * produce invalid, inaccessible nested-interactive-element markup.\n */\nconst PreviewToggle: React.FC<PreviewToggleProps> = ({\n onToggle,\n isBusy,\n isPreviewVisible,\n children,\n}) => {\n if (!onToggle) return <React.Fragment>{children}</React.Fragment>\n\n return (\n <div\n role=\"button\"\n tabIndex={isBusy ? -1 : 0}\n aria-label=\"Toggle preview\"\n aria-busy={isBusy}\n aria-pressed={isPreviewVisible}\n aria-disabled={isBusy || undefined}\n onClick={isBusy ? undefined : onToggle}\n onKeyDown={(e) => {\n if (isBusy) return\n // Only handle keys that originate on the wrapper itself, not on\n // inner interactive elements (dismiss X, carousel arrows). Without\n // this guard, pressing Enter/Space on a focused child would bubble\n // up and toggle the preview in addition to activating the child.\n if (e.target !== e.currentTarget) return\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n void onToggle()\n }\n }}\n className={\n !isBusy\n ? 'block w-full cursor-pointer text-left'\n : 'block w-full text-left'\n }\n >\n {children}\n </div>\n )\n}\n\nexport default PreviewToggle\n","import { useCallback, useRef, useState } from 'react'\n\nimport type { LockedAttachmentSource } from '../../types'\n\nexport interface UsePreviewToggleOptions {\n /** Gallery items carry their own per-item sources on the `gallery` prop already, so toggling skips the async fetch entirely. */\n isGallery: boolean\n /**\n * Lazily loads the underlying source; the resolved value is cached in\n * `source` and reused on subsequent toggles.\n */\n onFetchSource?: () => Promise<LockedAttachmentSource | void>\n /** Fired on every toggle tap, before any visibility/fetch logic runs. */\n onPreviewClick?: () => void\n}\n\nexport interface UsePreviewToggleResult {\n source: LockedAttachmentSource | undefined\n isPreviewVisible: boolean\n isLoadingPreview: boolean\n handleToggle: () => Promise<void>\n /**\n * `handleToggle` when the card can actually be previewed (gallery, or a\n * fetch/click handler is wired), else `undefined` — pass straight to\n * `PreviewToggle.onToggle` so a non-previewable card renders no\n * toggle affordance.\n */\n togglePreview: (() => Promise<void>) | undefined\n}\n\n/**\n * Shared preview-toggle state for Composer/Media isMine: flips a locked thumbnail to\n * its unlocked preview, lazily fetching and caching the source on first\n * reveal. Media !isMine doesn't use this — it fetches on scroll-into-view/paid\n * instead of on a toggle tap.\n */\nexport function usePreviewToggle({\n isGallery,\n onFetchSource,\n onPreviewClick,\n}: UsePreviewToggleOptions): UsePreviewToggleResult {\n const [source, setSource] = useState<LockedAttachmentSource | undefined>()\n const [isPreviewVisible, setIsPreviewVisible] = useState(false)\n const [isLoadingPreview, setIsLoadingPreview] = useState(false)\n const fetchingRef = useRef(false)\n\n const handleToggle = useCallback(async () => {\n onPreviewClick?.()\n if (isPreviewVisible) {\n setIsPreviewVisible(false)\n return\n }\n if (isGallery) {\n setIsPreviewVisible(true)\n return\n }\n if (source) {\n setIsPreviewVisible(true)\n return\n }\n if (!onFetchSource) return\n if (fetchingRef.current) return\n fetchingRef.current = true\n setIsLoadingPreview(true)\n try {\n const result = await onFetchSource()\n if (result) {\n setSource(result)\n setIsPreviewVisible(true)\n }\n } finally {\n fetchingRef.current = false\n setIsLoadingPreview(false)\n }\n }, [isPreviewVisible, isGallery, source, onPreviewClick, onFetchSource])\n\n const togglePreview =\n isGallery || onFetchSource != null || onPreviewClick != null\n ? handleToggle\n : undefined\n\n return {\n source,\n isPreviewVisible,\n isLoadingPreview,\n handleToggle,\n togglePreview,\n }\n}\n"],"names":["CardBody","variant","title","placeholderTitle","mimeType","detail","statusBadge","action","icon","trailingAction","isDark","displayTitle","titleDimmed","typeIcon","renderTypeIcon","classNames","jsxs","jsx","LockBadge","paymentStatus","isPlayable","sourceType","getSourceType","Icon","PlayIcon","LockOpenIcon","LockSimpleIcon","isPlayableItem","item","GalleryThumbnail","gallery","showLocked","topRight","index","setIndex","useState","total","safeIndex","current","isVideoItem","goPrev","e","i","goNext","atStart","atEnd","AttachmentThumbnail","React","CaretLeftIcon","CaretRightIcon","SingleThumbnail","thumbnailUrl","source","containedImage","effectiveSourceUrl","effectiveThumbnailUrl","isGalleryCard","galleryBodyIcon","ImagesIcon","CardThumbnail","MediaShell","children","rootRef","dataTestId","PreviewToggle","onToggle","isBusy","isPreviewVisible","usePreviewToggle","isGallery","onFetchSource","onPreviewClick","setSource","setIsPreviewVisible","isLoadingPreview","setIsLoadingPreview","fetchingRef","useRef","handleToggle","useCallback","result","togglePreview"],"mappings":"kKA0BMA,EAAoC,CAAC,CACzC,QAAAC,EACA,MAAAC,EACA,iBAAAC,EAAmB,mBACnB,SAAAC,EACA,OAAAC,EACA,YAAAC,EACA,OAAAC,EACA,KAAAC,EACA,eAAAC,CACF,IAAM,CACJ,MAAMC,EAAST,IAAY,OACrBU,EAAeD,EAAUR,GAASC,EAAqBD,GAAS,GAChEU,EAAcF,GAAU,CAACR,EAEzBW,EACJL,GACAM,EAAAA,eAAeV,EAAU,CACvB,UAAWW,EACT,kBACAL,EAAS,gBAAkB,eAAA,EAE7B,OAAQ,SAAA,CACT,EAEH,OACEM,EAAAA,KAAC,MAAA,CAAI,UAAU,YACb,SAAA,CAAAA,EAAAA,KAAC,MAAA,CAAI,UAAU,uBACb,SAAA,CAAAA,EAAAA,KAAC,MAAA,CAAI,UAAU,qCACZ,SAAA,CAAAL,EAAa,SAAW,IACvBM,EAAAA,IAAC,IAAA,CACC,UAAWF,EAAW,2CAA4C,CAChE,gBAAiB,CAACL,EAClB,gBAAiBA,GAAUE,EAC3B,aAAcF,GAAU,CAACE,CAAA,CAC1B,EAEA,SAAAD,CAAA,CAAA,EAILK,EAAAA,KAAC,MAAA,CAAI,UAAU,oCACZ,SAAA,CAAAH,EAEAR,GAAU,MAAQA,IAAW,IAC5BY,EAAAA,IAAC,OAAA,CACC,UAAWF,EACT,sBACAL,EAAS,gBAAkB,eAAA,EAG5B,SAAAL,CAAA,CAAA,EAIJC,CAAA,CAAA,CACH,CAAA,EACF,EAECG,GAAkBQ,EAAAA,IAAC,MAAA,CAAI,UAAU,WAAY,SAAAR,CAAA,CAAe,CAAA,EAC/D,EAECF,CAAA,EACH,CAEJ,EClEaW,EAAsC,CAAC,CAClD,cAAAC,EACA,SAAAf,EACA,WAAAgB,CACF,IAAM,CACJ,MAAMC,E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EAAoB,EAAI,EACxB,MACF,CACA,GAAKH,GACD,CAAAM,EAAY,QAChB,CAAAA,EAAY,QAAU,GACtBD,EAAoB,EAAI,EACxB,GAAI,CACF,MAAMK,EAAS,MAAMV,EAAA,EACjBU,IACFR,EAAUQ,CAAM,EAChBP,EAAoB,EAAI,EAE5B,QAAA,CACEG,EAAY,QAAU,GACtBD,EAAoB,EAAK,CAC3B,EACF,EAAG,CAACR,EAAkBE,EAAWjB,EAAQmB,EAAgBD,CAAa,CAAC,EAEjEW,EACJZ,GAAaC,GAAiB,MAAQC,GAAkB,KACpDO,EACA,OAEN,MAAO,CACL,OAAA1B,EACA,iBAAAe,EACA,iBAAAO,EACA,aAAAI,EACA,cAAAG,CAAA,CAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linktr.ee/messaging-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0-rc-1783407048",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@linktr.ee/component-library": "11.8.6",
|
|
53
|
-
"@linktr.ee/messaging-core": "
|
|
53
|
+
"@linktr.ee/messaging-core": "2.3.0-rc-1783407048",
|
|
54
54
|
"@phosphor-icons/react": "^2.1.10"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -126,6 +126,7 @@ interface TemplateProps {
|
|
|
126
126
|
attachment_mime_type?: string
|
|
127
127
|
attachment_thumbnail?: string
|
|
128
128
|
attachment_detail?: string
|
|
129
|
+
attachment_content_type?: 'text' | 'media'
|
|
129
130
|
}
|
|
130
131
|
}>
|
|
131
132
|
}
|
|
@@ -416,7 +417,59 @@ LockedAttachment.args = {
|
|
|
416
417
|
],
|
|
417
418
|
}
|
|
418
419
|
|
|
419
|
-
|
|
420
|
+
export const LockedTextAttachment: StoryFn<TemplateProps> = Template.bind({})
|
|
421
|
+
LockedTextAttachment.args = {
|
|
422
|
+
messages: [
|
|
423
|
+
{
|
|
424
|
+
id: 'msg-1',
|
|
425
|
+
text: 'Can you send me the details privately?',
|
|
426
|
+
user: storyUsers.visitor,
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
id: 'msg-2',
|
|
430
|
+
// Empty text: the real content is redacted server-side until purchase,
|
|
431
|
+
// so the bubble renders the blurred placeholder instead.
|
|
432
|
+
text: '',
|
|
433
|
+
user: storyUsers.creator,
|
|
434
|
+
metadata: {
|
|
435
|
+
custom_type: 'MESSAGE_ATTACHMENT',
|
|
436
|
+
amount_text: 'AU$4.99',
|
|
437
|
+
attachment_content_type: 'text',
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
id: 'msg-3',
|
|
442
|
+
text: '',
|
|
443
|
+
user: storyUsers.creator,
|
|
444
|
+
metadata: {
|
|
445
|
+
custom_type: 'MESSAGE_ATTACHMENT',
|
|
446
|
+
amount_text: 'AU$4.99',
|
|
447
|
+
payment_status: 'paid',
|
|
448
|
+
attachment_content_type: 'text',
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
id: 'msg-4',
|
|
453
|
+
// Buyer reveal: backend writes the real text back onto the message.
|
|
454
|
+
text: "Here's the address — see you Thursday at 7!",
|
|
455
|
+
user: storyUsers.creator,
|
|
456
|
+
metadata: {
|
|
457
|
+
custom_type: 'MESSAGE_ATTACHMENT',
|
|
458
|
+
amount_text: 'AU$4.99',
|
|
459
|
+
payment_status: 'paid',
|
|
460
|
+
attachment_content_type: 'text',
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
}
|
|
465
|
+
LockedTextAttachment.parameters = {
|
|
466
|
+
docs: {
|
|
467
|
+
description: {
|
|
468
|
+
story:
|
|
469
|
+
'A paid text-only message renders as a regular bubble with blurred placeholder copy (msg-2: pending, msg-3: purchased-but-not-yet-revealed) until the real text is revealed (msg-4).',
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
}
|
|
420
473
|
|
|
421
474
|
export const ChatbotVariants: StoryFn<TemplateProps> = Template.bind({})
|
|
422
475
|
ChatbotVariants.args = {
|
|
@@ -47,6 +47,14 @@ export const isAttachmentMessage = (message: LocalMessage): boolean => {
|
|
|
47
47
|
return message.metadata?.custom_type === 'MESSAGE_ATTACHMENT'
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export const isTextAttachmentMessage = (message: LocalMessage): boolean => {
|
|
51
|
+
return isAttachmentMessage(message) && message.metadata?.attachment_content_type === 'text'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const isMediaAttachmentMessage = (message: LocalMessage): boolean => {
|
|
55
|
+
return isAttachmentMessage(message) && message.metadata?.attachment_content_type !== 'text'
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
/** Check if a message has a tip/paid tag (both render the same) */
|
|
51
59
|
export const isTipOrPaidMessage = (message: LocalMessage): boolean => {
|
|
52
60
|
return isTipMessage(message) || isPaidMessage(message)
|
|
@@ -34,15 +34,15 @@ import { getMessageDisplayText } from '../../utils/getMessageDisplayText'
|
|
|
34
34
|
import { Avatar } from '../Avatar'
|
|
35
35
|
import LockedAttachment from '../LockedAttachment'
|
|
36
36
|
import { isLinkAttachment } from '../MediaMessage'
|
|
37
|
-
import {
|
|
38
|
-
bubbleGroupPositionFromStream as messageAttachmentGroupPositionFromStream,
|
|
39
|
-
} from '../MessageAttachment'
|
|
37
|
+
import { bubbleGroupPositionFromStream as messageAttachmentGroupPositionFromStream } from '../MessageAttachment'
|
|
40
38
|
|
|
41
39
|
import { useCustomMessage } from './context'
|
|
42
40
|
import {
|
|
43
41
|
MessageTag,
|
|
44
42
|
isAttachmentMessage,
|
|
45
43
|
isChatbotMessage,
|
|
44
|
+
isMediaAttachmentMessage,
|
|
45
|
+
isTextAttachmentMessage,
|
|
46
46
|
isTipOnlyMessage,
|
|
47
47
|
} from './MessageTag'
|
|
48
48
|
import { MessageVoteButtons } from './MessageVoteButtons'
|
|
@@ -276,12 +276,51 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
|
|
|
276
276
|
marginInlineStart: 0,
|
|
277
277
|
}}
|
|
278
278
|
>
|
|
279
|
-
{
|
|
279
|
+
{isTipOnly ? (
|
|
280
|
+
<MessageTag message={message} standalone />
|
|
281
|
+
) : isTextAttachmentMessage(message) ? (
|
|
282
|
+
<div className="str-chat__message-bubble-wrapper">
|
|
283
|
+
<div className="flex items-center gap-2">
|
|
284
|
+
{isMine && MessageActions && <MessageActions />}
|
|
285
|
+
{isMine ? (
|
|
286
|
+
<LockedAttachment.Text
|
|
287
|
+
isMine={true}
|
|
288
|
+
amountText={message.metadata?.amount_text}
|
|
289
|
+
paymentStatus={message.metadata?.payment_status}
|
|
290
|
+
>
|
|
291
|
+
{message.text && (
|
|
292
|
+
<MessageText
|
|
293
|
+
message={displayMessage}
|
|
294
|
+
renderText={renderText}
|
|
295
|
+
/>
|
|
296
|
+
)}
|
|
297
|
+
</LockedAttachment.Text>
|
|
298
|
+
) : (
|
|
299
|
+
<LockedAttachment.Text
|
|
300
|
+
isMine={false}
|
|
301
|
+
amountText={message.metadata?.amount_text}
|
|
302
|
+
paymentStatus={message.metadata?.payment_status}
|
|
303
|
+
isUnlocking={isUnlocking(message.id)}
|
|
304
|
+
onUnlockClick={() => onUnlockClick?.(message, channel)}
|
|
305
|
+
>
|
|
306
|
+
{message.text && (
|
|
307
|
+
<MessageText
|
|
308
|
+
message={displayMessage}
|
|
309
|
+
renderText={renderText}
|
|
310
|
+
/>
|
|
311
|
+
)}
|
|
312
|
+
</LockedAttachment.Text>
|
|
313
|
+
)}
|
|
314
|
+
{!isMine && MessageActions && <MessageActions />}
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
) : isMediaAttachmentMessage(message) ? (
|
|
280
318
|
<div className="str-chat__message-bubble-wrapper">
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
<LockedAttachment.
|
|
319
|
+
<div className="flex items-center gap-2">
|
|
320
|
+
{isMine && MessageActions && <MessageActions />}
|
|
321
|
+
{isMine ? (
|
|
322
|
+
<LockedAttachment.Media
|
|
323
|
+
isMine={true}
|
|
285
324
|
title={message.metadata?.attachment_title}
|
|
286
325
|
mimeType={message.metadata?.attachment_mime_type}
|
|
287
326
|
thumbnailUrl={message.metadata?.attachment_thumbnail}
|
|
@@ -289,14 +328,15 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
|
|
|
289
328
|
detail={message.metadata?.attachment_detail}
|
|
290
329
|
paymentStatus={message.metadata?.payment_status}
|
|
291
330
|
onPreviewClick={() => onUnlockClick?.(message, channel)}
|
|
292
|
-
onFetchSource={
|
|
293
|
-
|
|
331
|
+
onFetchSource={
|
|
332
|
+
onFetchSource
|
|
333
|
+
? () => onFetchSource(message, channel)
|
|
334
|
+
: undefined
|
|
294
335
|
}
|
|
295
336
|
/>
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
<LockedAttachment.Received
|
|
337
|
+
) : (
|
|
338
|
+
<LockedAttachment.Media
|
|
339
|
+
isMine={false}
|
|
300
340
|
title={message.metadata?.attachment_title}
|
|
301
341
|
mimeType={message.metadata?.attachment_mime_type}
|
|
302
342
|
thumbnailUrl={message.metadata?.attachment_thumbnail}
|
|
@@ -305,14 +345,16 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
|
|
|
305
345
|
paymentStatus={message.metadata?.payment_status}
|
|
306
346
|
isUnlocking={isUnlocking(message.id)}
|
|
307
347
|
onUnlockClick={() => onUnlockClick?.(message, channel)}
|
|
308
|
-
onFetchSource={
|
|
309
|
-
|
|
348
|
+
onFetchSource={
|
|
349
|
+
onFetchSource
|
|
350
|
+
? () => onFetchSource(message, channel)
|
|
351
|
+
: undefined
|
|
310
352
|
}
|
|
311
353
|
onDownloadClick={() => onDownloadClick?.(message, channel)}
|
|
312
354
|
/>
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
355
|
+
)}
|
|
356
|
+
{!isMine && MessageActions && <MessageActions />}
|
|
357
|
+
</div>
|
|
316
358
|
{message.text && (
|
|
317
359
|
<div className="str-chat__message-bubble">
|
|
318
360
|
<MessageText
|
|
@@ -322,9 +364,6 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
|
|
|
322
364
|
</div>
|
|
323
365
|
)}
|
|
324
366
|
</div>
|
|
325
|
-
) : isTipOnly ? (
|
|
326
|
-
/* Tip-only messages render as a standalone bubble */
|
|
327
|
-
<MessageTag message={message} standalone />
|
|
328
367
|
) : canRenderAttachmentsInToolkit ? (
|
|
329
368
|
<div className="str-chat__message-bubble-wrapper">
|
|
330
369
|
<div
|