@linktr.ee/messaging-react 3.4.2-rc-1782453771 → 3.4.2

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 (41) hide show
  1. package/dist/{Card-ql9pImRa.js → Card-BKalDyyu.js} +2 -2
  2. package/dist/{Card-ql9pImRa.js.map → Card-BKalDyyu.js.map} +1 -1
  3. package/dist/{Card-BaXLsSK2.js → Card-CphU_jG-.js} +2 -2
  4. package/dist/{Card-BaXLsSK2.js.map → Card-CphU_jG-.js.map} +1 -1
  5. package/dist/{Card-BkVj6kGN.cjs → Card-DFy_ZvFH.cjs} +2 -2
  6. package/dist/{Card-BkVj6kGN.cjs.map → Card-DFy_ZvFH.cjs.map} +1 -1
  7. package/dist/{Card-CcTyYY9N.cjs → Card-DxroYNrS.cjs} +2 -2
  8. package/dist/{Card-CcTyYY9N.cjs.map → Card-DxroYNrS.cjs.map} +1 -1
  9. package/dist/{Card-BIa-47Ne.cjs → Card-V-bNUxcw.cjs} +2 -2
  10. package/dist/{Card-BIa-47Ne.cjs.map → Card-V-bNUxcw.cjs.map} +1 -1
  11. package/dist/{Card-52LnCirC.js → Card-mpVcQ8-W.js} +3 -3
  12. package/dist/{Card-52LnCirC.js.map → Card-mpVcQ8-W.js.map} +1 -1
  13. package/dist/{LockedThumbnail-D0ASm7LP.cjs → LockedThumbnail-B3W7upHs.cjs} +2 -2
  14. package/dist/{LockedThumbnail-D0ASm7LP.cjs.map → LockedThumbnail-B3W7upHs.cjs.map} +1 -1
  15. package/dist/{LockedThumbnail-C3YOnS-o.js → LockedThumbnail-BD7qtcso.js} +2 -2
  16. package/dist/{LockedThumbnail-C3YOnS-o.js.map → LockedThumbnail-BD7qtcso.js.map} +1 -1
  17. package/dist/{index-CbWEp3Zs.js → index-CjwQ2Hj3.js} +1093 -1136
  18. package/dist/index-CjwQ2Hj3.js.map +1 -0
  19. package/dist/index-tI-4cxV1.cjs +2 -0
  20. package/dist/index-tI-4cxV1.cjs.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +25 -13
  23. package/dist/index.js +14 -13
  24. package/package.json +2 -2
  25. package/src/components/ChannelList/CustomChannelPreview.stories.tsx +0 -63
  26. package/src/components/ChannelList/CustomChannelPreview.test.tsx +8 -58
  27. package/src/components/ChannelList/CustomChannelPreview.tsx +10 -7
  28. package/src/components/ChannelView.stories.tsx +7 -38
  29. package/src/components/ChannelView.test.tsx +15 -29
  30. package/src/components/ChannelView.tsx +9 -19
  31. package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +34 -0
  32. package/src/components/CustomMessageInput/index.tsx +23 -1
  33. package/src/components/MessagingShell/index.tsx +2 -0
  34. package/src/hooks/useChannelStar.ts +6 -9
  35. package/src/index.ts +1 -0
  36. package/src/stream-custom-data.ts +1 -16
  37. package/src/types.ts +18 -0
  38. package/dist/index-CbWEp3Zs.js.map +0 -1
  39. package/dist/index-DkqM2z_j.cjs +0 -2
  40. package/dist/index-DkqM2z_j.cjs.map +0 -1
  41. package/src/components/ParticipantBadges.tsx +0 -39
@@ -32,7 +32,6 @@ import CustomTypingIndicator from './CustomTypingIndicator'
32
32
  import { DmAgentEnabledContext } from './CustomTypingIndicator/DmAgentContext'
33
33
  import { ChannelEmptyState } from './MessagingShell/ChannelEmptyState'
34
34
  import { LoadingState } from './MessagingShell/LoadingState'
35
- import { ParticipantBadges } from './ParticipantBadges'
36
35
 
37
36
  const ICON_BTN_CLASS =
38
37
  'size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring'
@@ -137,6 +136,7 @@ const CustomChannelHeader: React.FC<{
137
136
  id={participant?.user?.id || channel.id || 'unknown'}
138
137
  name={participantName}
139
138
  image={participantImage}
139
+ starred={showStarButton && isStarred}
140
140
  dmAgentEnabled={dmAgentEnabled}
141
141
  size={48}
142
142
  />
@@ -148,10 +148,6 @@ const CustomChannelHeader: React.FC<{
148
148
  className="flex max-w-full items-center gap-0.5 rounded text-center text-xs font-medium text-black/90 transition-opacity hover:opacity-70"
149
149
  >
150
150
  <span className="min-w-0 truncate">{participantName}</span>
151
- <ParticipantBadges
152
- participant={participant}
153
- isStarred={isStarred}
154
- />
155
151
  {headerTitleBadges && (
156
152
  <span className="shrink-0">{headerTitleBadges}</span>
157
153
  )}
@@ -160,10 +156,6 @@ const CustomChannelHeader: React.FC<{
160
156
  ) : (
161
157
  <p className="flex max-w-full items-center justify-center gap-1 text-center text-xs font-medium text-black/90">
162
158
  <span className="min-w-0 truncate">{participantName}</span>
163
- <ParticipantBadges
164
- participant={participant}
165
- isStarred={isStarred}
166
- />
167
159
  {headerTitleBadges && (
168
160
  <span className="shrink-0">{headerTitleBadges}</span>
169
161
  )}
@@ -236,6 +228,7 @@ const CustomChannelHeader: React.FC<{
236
228
  id={participant?.user?.id || channel.id || 'unknown'}
237
229
  name={participantName}
238
230
  image={participantImage}
231
+ starred={showStarButton && isStarred}
239
232
  dmAgentEnabled={dmAgentEnabled}
240
233
  size={48}
241
234
  />
@@ -248,10 +241,6 @@ const CustomChannelHeader: React.FC<{
248
241
  className="flex min-w-0 max-w-full items-center gap-1 rounded font-medium text-black/90 transition-opacity hover:opacity-70"
249
242
  >
250
243
  <span className="min-w-0 truncate">{participantName}</span>
251
- <ParticipantBadges
252
- participant={participant}
253
- isStarred={isStarred}
254
- />
255
244
  {headerTitleBadges && (
256
245
  <span className="shrink-0">{headerTitleBadges}</span>
257
246
  )}
@@ -260,10 +249,6 @@ const CustomChannelHeader: React.FC<{
260
249
  ) : (
261
250
  <h1 className="flex min-w-0 items-center gap-1 font-medium text-black/90">
262
251
  <span className="min-w-0 truncate">{participantName}</span>
263
- <ParticipantBadges
264
- participant={participant}
265
- isStarred={isStarred}
266
- />
267
252
  {headerTitleBadges && (
268
253
  <span className="shrink-0">{headerTitleBadges}</span>
269
254
  )}
@@ -355,6 +340,7 @@ const ChannelViewInner: React.FC<{
355
340
  viewerLanguage?: string
356
341
  showChannelInfo?: boolean
357
342
  onParticipantNameClick?: () => void
343
+ composerInput?: ChannelViewProps['composerInput']
358
344
  }> = ({
359
345
  onBack,
360
346
  showBackButton,
@@ -382,6 +368,7 @@ const ChannelViewInner: React.FC<{
382
368
  viewerLanguage,
383
369
  showChannelInfo = true,
384
370
  onParticipantNameClick,
371
+ composerInput,
385
372
  }) => {
386
373
  const { channel } = useChannelStateContext()
387
374
 
@@ -403,10 +390,10 @@ const ChannelViewInner: React.FC<{
403
390
  }, [channel._client?.userID, channel.state?.members])
404
391
 
405
392
  const currentUserIsAccount =
406
- currentMember?.user?.is_account ??
393
+ (currentMember?.user as { is_account?: boolean } | undefined)?.is_account ??
407
394
  (currentMember as { is_account?: boolean } | undefined)?.is_account
408
395
  const participantIsAccount =
409
- participant?.user?.is_account ??
396
+ (participant?.user as { is_account?: boolean } | undefined)?.is_account ??
410
397
  (participant as { is_account?: boolean } | undefined)?.is_account
411
398
 
412
399
  const showDmAgentHeader =
@@ -498,6 +485,7 @@ const ChannelViewInner: React.FC<{
498
485
  renderFooter={() => renderMessageInputFooter?.(channel)}
499
486
  disabled={composerDisabled}
500
487
  disabledReason={composerDisabledReason}
488
+ composerInput={composerInput}
501
489
  />
502
490
  </Window>
503
491
  </WithComponents>
@@ -544,6 +532,7 @@ export const ChannelView = React.memo<ChannelViewProps>(
544
532
  viewerLanguage,
545
533
  showChannelInfo = true,
546
534
  onParticipantNameClick,
535
+ composerInput,
547
536
  }) => {
548
537
  // Custom send message handler that:
549
538
  // 1. Applies messageMetadata if provided
@@ -658,6 +647,7 @@ export const ChannelView = React.memo<ChannelViewProps>(
658
647
  viewerLanguage={viewerLanguage}
659
648
  showChannelInfo={showChannelInfo}
660
649
  onParticipantNameClick={onParticipantNameClick}
650
+ composerInput={composerInput}
661
651
  />
662
652
  </Channel>
663
653
  </DmAgentEnabledContext.Provider>
@@ -204,6 +204,40 @@ describe('CustomMessageInput', () => {
204
204
  ).toBeInTheDocument()
205
205
  })
206
206
 
207
+ it('renders a custom composerInput in place of the default composer', () => {
208
+ mockChannelData = {}
209
+
210
+ renderWithProviders(
211
+ <CustomMessageInput
212
+ composerInput={() => (
213
+ <div data-testid="custom-composer">custom composer</div>
214
+ )}
215
+ />
216
+ )
217
+
218
+ // The host-owned composer renders instead of the built-in textarea/send.
219
+ expect(screen.getByTestId('custom-composer')).toBeInTheDocument()
220
+ expect(screen.queryByTestId('textarea-composer')).not.toBeInTheDocument()
221
+ // It is still mounted inside Stream's <MessageInput> so it keeps the
222
+ // message-input context (send pipeline, attachments, previews).
223
+ expect(screen.getByTestId('stream-message-input')).toBeInTheDocument()
224
+ })
225
+
226
+ it('keeps the frozen wrapper around a custom composerInput', () => {
227
+ mockChannelData = { frozen: true }
228
+
229
+ const { container } = renderWithProviders(
230
+ <CustomMessageInput
231
+ composerInput={() => <div data-testid="custom-composer" />}
232
+ />
233
+ )
234
+
235
+ const messageInput = container.querySelector('.message-input')
236
+ expect(messageInput).toHaveAttribute('aria-disabled', 'true')
237
+ expect(messageInput).toHaveAttribute('inert')
238
+ expect(screen.getByTestId('custom-composer')).toBeInTheDocument()
239
+ })
240
+
207
241
  it('does not render the locked panel when the composer is not disabled', () => {
208
242
  mockChannelData = {}
209
243
 
@@ -23,6 +23,15 @@ import { CustomLinkPreviewList } from '../CustomLinkPreviewList'
23
23
  */
24
24
  const ComposerLockedContext = React.createContext(false)
25
25
 
26
+ /**
27
+ * Read the composer's locked (frozen-channel) state from inside a custom
28
+ * composer supplied via `composerInput`. Returns true when the channel is
29
+ * frozen; mirror the default composer by rendering the textarea read-only and
30
+ * disabling the send control.
31
+ */
32
+ export const useComposerLocked = (): boolean =>
33
+ useContext(ComposerLockedContext)
34
+
26
35
  const DefaultSendButton: React.FC<{
27
36
  sendMessage: () => void
28
37
  disabled?: boolean
@@ -101,6 +110,18 @@ export interface CustomMessageInputProps {
101
110
  * `disabled` is true.
102
111
  */
103
112
  disabledReason?: string
113
+ /**
114
+ * Replace the inner composer — the textarea + send arrangement rendered
115
+ * inside Stream's `<MessageInput>` — with a host-owned component. When
116
+ * provided it is passed to Stream as the `Input` component, so it runs inside
117
+ * the message-input context and can drive sending, attachments, and previews
118
+ * via the Stream hooks (`useMessageInputContext`,
119
+ * `useMessageComposerHasSendableData`, `TextareaComposer`, …). The outer
120
+ * frozen/`renderActions`/`renderFooter` wrapper is unchanged; read
121
+ * `useComposerLocked()` to honour the frozen state. Defaults to the built-in
122
+ * composer.
123
+ */
124
+ composerInput?: React.ComponentType
104
125
  }
105
126
 
106
127
  export const CustomMessageInput: React.FC<CustomMessageInputProps> = ({
@@ -108,6 +129,7 @@ export const CustomMessageInput: React.FC<CustomMessageInputProps> = ({
108
129
  renderFooter,
109
130
  disabled = false,
110
131
  disabledReason,
132
+ composerInput,
111
133
  }) => {
112
134
  const { channel } = useChannelStateContext()
113
135
  const isFrozen = channel?.data?.frozen === true
@@ -143,7 +165,7 @@ export const CustomMessageInput: React.FC<CustomMessageInputProps> = ({
143
165
  </div>
144
166
  )}
145
167
  <ComposerLockedContext.Provider value={isFrozen}>
146
- <MessageInput Input={CustomMessageInputInner} />
168
+ <MessageInput Input={composerInput ?? CustomMessageInputInner} />
147
169
  </ComposerLockedContext.Provider>
148
170
  </div>
149
171
  {renderFooter?.()}
@@ -39,6 +39,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
39
39
  renderMessage,
40
40
  onMessageLinkClick,
41
41
  showChannelInfo,
42
+ composerInput,
42
43
  }) => {
43
44
  const {
44
45
  client,
@@ -264,6 +265,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
264
265
  renderMessage={renderMessage}
265
266
  onMessageLinkClick={onMessageLinkClick}
266
267
  showChannelInfo={showChannelInfo}
268
+ composerInput={composerInput}
267
269
  />
268
270
  </div>
269
271
  </div>
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react'
2
- import type { Channel, Event } from 'stream-chat'
2
+ import { Channel, Event } from 'stream-chat'
3
3
 
4
4
  export const useChannelStar = (channel?: Channel) => {
5
5
  const [isChannelStarred, setIsChannelStarred] = useState(
@@ -15,18 +15,15 @@ export const useChannelStar = (channel?: Channel) => {
15
15
  setIsChannelStarred(!!channel.state.membership?.pinned_at)
16
16
 
17
17
  const handleMemberUpdate = (event: Event) => {
18
- const currentUserId = channel._client?.userID
19
- const memberUserId = event.member?.user_id ?? event.member?.user?.id
20
-
21
- if (!currentUserId || memberUserId !== currentUserId) return
22
-
23
- setIsChannelStarred(!!event.member?.pinned_at)
18
+ setIsChannelStarred(
19
+ event?.member ? !!event.member.pinned_at : !!channel.state.membership?.pinned_at
20
+ )
24
21
  }
25
22
 
26
- const subscription = channel.on('member.updated', handleMemberUpdate)
23
+ channel.on('member.updated', handleMemberUpdate)
27
24
 
28
25
  return () => {
29
- subscription.unsubscribe()
26
+ channel.off('member.updated', handleMemberUpdate)
30
27
  }
31
28
  }, [channel])
32
29
 
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ export { MessagingProvider } from './providers/MessagingProvider'
30
30
  export { CustomMessageProvider } from './components/CustomMessage/context'
31
31
 
32
32
  // Hooks
33
+ export { useComposerLocked } from './components/CustomMessageInput'
33
34
  export { useMessaging } from './hooks/useMessaging'
34
35
  export { useMessageVote } from './hooks/useMessageVote'
35
36
  export { useCustomMessage } from './components/CustomMessage/context'
@@ -2,8 +2,7 @@
2
2
  * Stream Chat custom data type augmentation.
3
3
  *
4
4
  * This file extends Stream Chat's type system by augmenting their empty
5
- * CustomMessageData, CustomChannelData, CustomMemberData, and CustomUserData
6
- * interfaces with our custom properties.
5
+ * CustomMessageData and CustomChannelData interfaces with our custom properties.
7
6
  *
8
7
  * @see https://getstream.io/chat/docs/sdk/react/guides/typescript_and_custom_data_types/
9
8
  *
@@ -99,14 +98,6 @@ declare module 'stream-chat' {
99
98
  chatbot_paused?: boolean
100
99
  }
101
100
 
102
- interface CustomMemberData {
103
- /**
104
- * Whether the member should be identified as a customer in participant UI.
105
- * Stored on the channel member so it is scoped to this conversation.
106
- */
107
- customer?: boolean
108
- }
109
-
110
101
  interface CustomMessageData {
111
102
  /**
112
103
  * When true, hides the date timestamp in system messages.
@@ -124,10 +115,4 @@ declare module 'stream-chat' {
124
115
  */
125
116
  dm_agent_system_type?: DmAgentSystemType
126
117
  }
127
-
128
- interface CustomUserData {
129
- is_account?: boolean
130
- is_follower?: boolean
131
- username?: string
132
- }
133
118
  }
package/src/types.ts CHANGED
@@ -324,6 +324,23 @@ export interface ChannelViewProps {
324
324
  */
325
325
  attachmentPreviewList?: ComponentType
326
326
 
327
+ /**
328
+ * Replace the entire inner composer — the textarea + send arrangement — with
329
+ * a host-owned component. Passed to Stream's `<MessageInput>` as the `Input`
330
+ * component, so it runs inside the message-input context and reuses the
331
+ * library's send pipeline (`doSendMessageRequest`, message metadata, DM-agent
332
+ * suppression), attachments, and previews via the Stream hooks
333
+ * (`useMessageInputContext`, `useMessageComposerHasSendableData`,
334
+ * `TextareaComposer`, …). Use it when a surface needs a different composer
335
+ * layout (e.g. a full-width textarea above a toolbar row) than the default.
336
+ *
337
+ * The outer wrapper — frozen handling and the `renderMessageInputActions` /
338
+ * `renderMessageInputFooter` slots — is unchanged. Read the exported
339
+ * `useComposerLocked()` hook to honour the frozen state. Defaults to the
340
+ * built-in composer when omitted.
341
+ */
342
+ composerInput?: ComponentType
343
+
327
344
  /**
328
345
  * Fired when the participant's name in the channel header is clicked. When
329
346
  * provided, the name renders as a button with a trailing caret (an affordance
@@ -359,6 +376,7 @@ export type ChannelViewPassthroughProps = Pick<
359
376
  | 'renderMessage'
360
377
  | 'onMessageLinkClick'
361
378
  | 'showChannelInfo'
379
+ | 'composerInput'
362
380
  >
363
381
 
364
382
  /**