@linktr.ee/messaging-react 3.6.2 → 3.7.0-rc-1783305846

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 (43) hide show
  1. package/dist/{Card-NDZLmjxS.js → Card-BAt0xifq.js} +2 -2
  2. package/dist/{Card-NDZLmjxS.js.map → Card-BAt0xifq.js.map} +1 -1
  3. package/dist/{Card-DSQclaiH.js → Card-BB34_MDl.js} +3 -3
  4. package/dist/{Card-DSQclaiH.js.map → Card-BB34_MDl.js.map} +1 -1
  5. package/dist/{Card-Jc1n2Iqu.cjs → Card-BDKGSydN.cjs} +2 -2
  6. package/dist/{Card-Jc1n2Iqu.cjs.map → Card-BDKGSydN.cjs.map} +1 -1
  7. package/dist/{Card-DEk34Twe.cjs → Card-BGJY5HWf.cjs} +2 -2
  8. package/dist/{Card-DEk34Twe.cjs.map → Card-BGJY5HWf.cjs.map} +1 -1
  9. package/dist/{Card-Cz8tanga.js → Card-C3-Ea5ho.js} +2 -2
  10. package/dist/{Card-Cz8tanga.js.map → Card-C3-Ea5ho.js.map} +1 -1
  11. package/dist/{Card-BThi6-oD.cjs → Card-DnFtpG1h.cjs} +2 -2
  12. package/dist/{Card-BThi6-oD.cjs.map → Card-DnFtpG1h.cjs.map} +1 -1
  13. package/dist/{LockedThumbnail-CqcnnPXB.cjs → LockedThumbnail-Bl9UC9sQ.cjs} +2 -2
  14. package/dist/{LockedThumbnail-CqcnnPXB.cjs.map → LockedThumbnail-Bl9UC9sQ.cjs.map} +1 -1
  15. package/dist/{LockedThumbnail-t9fLaFmy.js → LockedThumbnail-so7ftBnG.js} +2 -2
  16. package/dist/{LockedThumbnail-t9fLaFmy.js.map → LockedThumbnail-so7ftBnG.js.map} +1 -1
  17. package/dist/{index-bPlX3Oo5.js → index-2HMjfjM-.js} +1559 -1744
  18. package/dist/index-2HMjfjM-.js.map +1 -0
  19. package/dist/index-BgzqZorr.cjs +2 -0
  20. package/dist/index-BgzqZorr.cjs.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +14 -2
  23. package/dist/index.js +1 -1
  24. package/dist/testing.cjs +2 -0
  25. package/dist/testing.cjs.map +1 -0
  26. package/dist/testing.d.ts +116 -0
  27. package/dist/testing.js +107 -0
  28. package/dist/testing.js.map +1 -0
  29. package/package.json +14 -2
  30. package/src/components/ChannelView.stories.tsx +11 -68
  31. package/src/components/ChannelView.test.tsx +13 -54
  32. package/src/components/ChannelView.tsx +28 -74
  33. package/src/providers/MessagingProvider.test.tsx +30 -0
  34. package/src/providers/MessagingProvider.tsx +24 -5
  35. package/src/testing/createMockMessagingClient.stories.tsx +77 -0
  36. package/src/testing/createMockMessagingClient.ts +231 -0
  37. package/src/testing/index.ts +7 -0
  38. package/src/types.ts +15 -2
  39. package/dist/index-CPCX_7gP.cjs +0 -2
  40. package/dist/index-CPCX_7gP.cjs.map +0 -1
  41. package/dist/index-bPlX3Oo5.js.map +0 -1
  42. package/src/components/ChannelHeaderRedesign.tsx +0 -231
  43. /package/dist/assets/{index.css → messaging-react.css} +0 -0
@@ -1,231 +0,0 @@
1
- import {
2
- ArrowLeftIcon,
3
- CaretRightIcon,
4
- CurrencyDollarIcon,
5
- SparkleIcon,
6
- StarIcon,
7
- } from '@phosphor-icons/react'
8
- import classNames from 'classnames'
9
- import React from 'react'
10
- import type { ChannelMemberResponse, Channel as ChannelType } from 'stream-chat'
11
- import { useChannelStateContext, useChatContext } from 'stream-chat-react'
12
-
13
- import { useChannelStar } from '../hooks/useChannelStar'
14
- import { resolveConversationParticipant } from '../utils/resolveConversationParticipant'
15
- import { resolveParticipantDisplayName } from '../utils/resolveParticipantDisplayName'
16
-
17
- import { Avatar } from './Avatar'
18
- import { ChannelActionsMenu } from './ChannelActionsMenu'
19
-
20
- const ICON_BTN_CLASS =
21
- 'flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring'
22
-
23
- const CUSTOMER_PAID_TAG = 'CUSTOMER_PAID'
24
- const DM_AGENT_HEADER_HELPER_TEXT = 'Replies instantly with AI assistant'
25
-
26
- const isCustomerPaidTag = (value: unknown) =>
27
- typeof value === 'string' &&
28
- value
29
- .trim()
30
- .replace(/[\s-]+/g, '_')
31
- .toUpperCase() === CUSTOMER_PAID_TAG
32
-
33
- const hasCustomerPaidTag = (participant?: ChannelMemberResponse) => {
34
- const member = participant as
35
- | {
36
- customerTag?: unknown
37
- customer_tag?: unknown
38
- }
39
- | undefined
40
-
41
- return [member?.customerTag, member?.customer_tag].some(isCustomerPaidTag)
42
- }
43
-
44
- interface ChannelHeaderRedesignProps {
45
- onBack?: () => void
46
- showBackButton: boolean
47
- showStarButton?: boolean
48
- dmAgentEnabled?: boolean
49
- onLeaveConversation?: (channel: ChannelType) => void
50
- onBlockParticipant?: (participantId?: string) => void
51
- showDeleteConversation?: boolean
52
- showBlockParticipant?: boolean
53
- showReportParticipant?: boolean
54
- onDeleteConversationClick?: () => void
55
- onBlockParticipantClick?: () => void
56
- onReportParticipantClick?: () => void
57
- customChannelActions?: React.ReactNode
58
- renderChannelActions?: React.ReactNode
59
- showChannelInfo?: boolean
60
- onParticipantNameClick: () => void
61
- }
62
-
63
- export const ChannelHeaderRedesign: React.FC<ChannelHeaderRedesignProps> = ({
64
- onBack,
65
- showBackButton,
66
- showStarButton = false,
67
- dmAgentEnabled = false,
68
- onLeaveConversation,
69
- onBlockParticipant,
70
- showDeleteConversation = true,
71
- showBlockParticipant = true,
72
- showReportParticipant = true,
73
- onDeleteConversationClick,
74
- onBlockParticipantClick,
75
- onReportParticipantClick,
76
- customChannelActions,
77
- renderChannelActions,
78
- showChannelInfo = true,
79
- onParticipantNameClick,
80
- }) => {
81
- const { channel } = useChannelStateContext()
82
- const { client } = useChatContext()
83
-
84
- const participant = React.useMemo(
85
- () =>
86
- resolveConversationParticipant(
87
- channel.state?.members,
88
- client?.userID,
89
- channel.type
90
- ),
91
- [channel.state?.members, client?.userID, channel.type]
92
- )
93
-
94
- const participantName = resolveParticipantDisplayName(participant?.user)
95
- const participantImage = participant?.user?.image
96
- const isStarred = useChannelStar(channel)
97
- const isPaidCustomer = hasCustomerPaidTag(participant)
98
-
99
- const handleStarClick = async () => {
100
- try {
101
- if (isStarred) {
102
- await (channel as ChannelType).unpin()
103
- } else {
104
- await (channel as ChannelType).pin()
105
- }
106
- } catch (error) {
107
- console.error(
108
- '[ChannelHeaderRedesign] Failed to update pinned status:',
109
- error
110
- )
111
- }
112
- }
113
-
114
- return (
115
- <div className="@container w-full bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]">
116
- <div className="grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6">
117
- <div className="flex items-start">
118
- {showBackButton && (
119
- <button
120
- className={classNames(
121
- ICON_BTN_CLASS,
122
- 'messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop'
123
- )}
124
- onClick={onBack || (() => {})}
125
- type="button"
126
- aria-label="Back to conversations"
127
- >
128
- <ArrowLeftIcon className="size-5 text-black/90" />
129
- </button>
130
- )}
131
- </div>
132
-
133
- <div className="flex min-w-0 justify-center" data-dd-privacy="mask">
134
- <button
135
- type="button"
136
- onClick={onParticipantNameClick}
137
- aria-label={`View details for ${participantName}`}
138
- className="group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none"
139
- >
140
- <Avatar
141
- id={participant?.user?.id || channel.id || 'unknown'}
142
- name={participantName}
143
- image={participantImage}
144
- dmAgentEnabled={dmAgentEnabled}
145
- shape="circle"
146
- size={48}
147
- className="-mb-2"
148
- />
149
- <span className="relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 pl-3 pr-2 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95">
150
- <span className="flex max-w-full items-center justify-center">
151
- <span className="min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90">
152
- {participantName}
153
- </span>
154
- <span className="ml-2 flex gap-1">
155
- {isPaidCustomer && (
156
- <span
157
- aria-label="Paid customer"
158
- className="flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white"
159
- >
160
- <CurrencyDollarIcon className="size-2.5" weight="bold" />
161
- </span>
162
- )}
163
- {showStarButton && isStarred && (
164
- <span
165
- aria-label="Starred conversation"
166
- className="flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white"
167
- >
168
- <StarIcon className="size-2.5" weight="fill" />
169
- </span>
170
- )}
171
- <CaretRightIcon
172
- aria-hidden="true"
173
- className="size-4 shrink-0 text-black/65"
174
- weight="bold"
175
- />
176
- </span>
177
- </span>
178
- {dmAgentEnabled && (
179
- <span className="mt-1 flex items-center gap-1 px-1 pb-0.5 text-[10px] leading-3 text-black/55">
180
- <SparkleIcon className="size-3 shrink-0 text-black/55" />
181
- <span>{DM_AGENT_HEADER_HELPER_TEXT}</span>
182
- </span>
183
- )}
184
- </span>
185
- </button>
186
- </div>
187
-
188
- <div className="flex items-start justify-end gap-2">
189
- {showStarButton && (
190
- <button
191
- className={ICON_BTN_CLASS}
192
- onClick={handleStarClick}
193
- type="button"
194
- aria-pressed={isStarred}
195
- aria-label={
196
- isStarred ? 'Unstar conversation' : 'Star conversation'
197
- }
198
- >
199
- <StarIcon
200
- className={classNames('size-5', {
201
- 'text-[#FFD60A]': isStarred,
202
- 'text-black/90': !isStarred,
203
- })}
204
- weight={isStarred ? 'fill' : 'regular'}
205
- />
206
- </button>
207
- )}
208
- {showChannelInfo &&
209
- (renderChannelActions !== undefined ? (
210
- renderChannelActions
211
- ) : (
212
- <ChannelActionsMenu
213
- channel={channel as ChannelType}
214
- participant={participant}
215
- showDeleteConversation={showDeleteConversation}
216
- showBlockParticipant={showBlockParticipant}
217
- showReportParticipant={showReportParticipant}
218
- onLeaveConversation={onLeaveConversation}
219
- onBlockParticipant={onBlockParticipant}
220
- onDeleteConversationClick={onDeleteConversationClick}
221
- onBlockParticipantClick={onBlockParticipantClick}
222
- onReportParticipantClick={onReportParticipantClick}
223
- customChannelActions={customChannelActions}
224
- triggerClassName={ICON_BTN_CLASS}
225
- />
226
- ))}
227
- </div>
228
- </div>
229
- </div>
230
- )
231
- }
File without changes