@linktr.ee/messaging-react 4.5.1 → 4.6.0-rc-1788328793

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "4.5.1",
3
+ "version": "4.6.0-rc-1788328793",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -50,8 +50,8 @@
50
50
  "chromatic:local": "yarn storybook:build && chromatic"
51
51
  },
52
52
  "dependencies": {
53
- "@linktr.ee/messaging-core": "^2.6.0",
54
- "@linktr.ee/messaging-taxonomy": "^0.12.0",
53
+ "@linktr.ee/messaging-core": "2.6.0-rc-1788328793",
54
+ "@linktr.ee/messaging-taxonomy": "0.12.0-rc-1788328793",
55
55
  "@phosphor-icons/react": "^2.1.10"
56
56
  },
57
57
  "devDependencies": {
@@ -33,6 +33,7 @@ interface ChannelHeaderProps {
33
33
  onBack?: () => void
34
34
  showBackButton: boolean
35
35
  showStarButton?: boolean
36
+ showStarBadge?: boolean
36
37
  onLeaveConversation?: (channel: ChannelType) => void
37
38
  onBlockParticipant?: (participantId?: string) => void
38
39
  showDeleteConversation?: boolean
@@ -52,6 +53,7 @@ const ChannelHeader: React.FC<ChannelHeaderProps> = ({
52
53
  onBack,
53
54
  showBackButton,
54
55
  showStarButton = false,
56
+ showStarBadge = showStarButton,
55
57
  onLeaveConversation,
56
58
  onBlockParticipant,
57
59
  showDeleteConversation = true,
@@ -85,9 +87,9 @@ const ChannelHeader: React.FC<ChannelHeaderProps> = ({
85
87
  isCustomerPaidTag(channel.data?.customer_tag) &&
86
88
  participant?.is_follower === true
87
89
 
88
- const showStarBadge = showStarButton && isStarred
90
+ const shouldShowStarBadge = showStarBadge && isStarred
89
91
  const hasNameAdornment =
90
- isPaidCustomer || showStarBadge || Boolean(onParticipantNameClick)
92
+ isPaidCustomer || shouldShowStarBadge || Boolean(onParticipantNameClick)
91
93
 
92
94
  const handleStarClick = async () => {
93
95
  try {
@@ -134,7 +136,7 @@ const ChannelHeader: React.FC<ChannelHeaderProps> = ({
134
136
  <CurrencyDollarIcon className="size-2.5" weight="bold" />
135
137
  </span>
136
138
  )}
137
- {showStarBadge && (
139
+ {shouldShowStarBadge && (
138
140
  <span className="messaging-header-star-badge flex overflow-hidden">
139
141
  <span
140
142
  aria-label="Starred conversation"
@@ -519,6 +519,42 @@ describe('ChannelView', () => {
519
519
  ).not.toBeInTheDocument()
520
520
  })
521
521
 
522
+ it('shows the starred badge without the star button when showStarBadge is set explicitly', () => {
523
+ mockIsStarred = true
524
+
525
+ renderWithProviders(
526
+ <ChannelView
527
+ channel={createChannel()}
528
+ showStarButton={false}
529
+ showStarBadge={true}
530
+ />
531
+ )
532
+
533
+ expect(screen.getByLabelText('Starred conversation')).toBeInTheDocument()
534
+ expect(
535
+ screen.queryByRole('button', { name: 'Unstar conversation' })
536
+ ).not.toBeInTheDocument()
537
+ })
538
+
539
+ it('hides the starred badge when showStarBadge is false even with the star button shown', () => {
540
+ mockIsStarred = true
541
+
542
+ renderWithProviders(
543
+ <ChannelView
544
+ channel={createChannel()}
545
+ showStarButton={true}
546
+ showStarBadge={false}
547
+ />
548
+ )
549
+
550
+ expect(
551
+ screen.queryByLabelText('Starred conversation')
552
+ ).not.toBeInTheDocument()
553
+ expect(
554
+ screen.getByRole('button', { name: 'Unstar conversation' })
555
+ ).toBeInTheDocument()
556
+ })
557
+
522
558
  it('keeps channel banner and input action renderers working', () => {
523
559
  const channel = createChannel()
524
560
  const renderMessageInputActions = vi.fn((currentChannel: Channel) => (
@@ -50,6 +50,7 @@ const ChannelViewInner: React.FC<{
50
50
  composerDisabled?: boolean
51
51
  composerDisabledReason?: string
52
52
  showStarButton?: boolean
53
+ showStarBadge?: boolean
53
54
  renderChannelBanner?: () => React.ReactNode
54
55
  customChannelActions?: React.ReactNode
55
56
  renderChannelActions?: React.ReactNode
@@ -80,6 +81,7 @@ const ChannelViewInner: React.FC<{
80
81
  composerDisabled = false,
81
82
  composerDisabledReason,
82
83
  showStarButton = false,
84
+ showStarBadge,
83
85
  renderChannelBanner,
84
86
  customChannelActions,
85
87
  renderChannelActions,
@@ -123,6 +125,7 @@ const ChannelViewInner: React.FC<{
123
125
  showBackButton={showBackButton}
124
126
  showChannelInfo={showChannelInfo}
125
127
  showStarButton={showStarButton}
128
+ showStarBadge={showStarBadge}
126
129
  onLeaveConversation={onLeaveConversation}
127
130
  onBlockParticipant={onBlockParticipant}
128
131
  showDeleteConversation={showDeleteConversation}
@@ -303,6 +306,7 @@ export const ChannelView = React.memo<ChannelViewProps>(
303
306
  messageMetadata,
304
307
  onMessageSent,
305
308
  showStarButton = false,
309
+ showStarBadge,
306
310
  renderChannelBanner,
307
311
  customChannelActions,
308
312
  renderChannelActions,
@@ -430,6 +434,7 @@ export const ChannelView = React.memo<ChannelViewProps>(
430
434
  composerDisabled={composerDisabled}
431
435
  composerDisabledReason={composerDisabledReason}
432
436
  showStarButton={showStarButton}
437
+ showStarBadge={showStarBadge}
433
438
  renderChannelBanner={renderChannelBanner}
434
439
  customChannelActions={customChannelActions}
435
440
  renderChannelActions={renderChannelActions}
package/src/types.ts CHANGED
@@ -280,6 +280,14 @@ export interface ChannelViewProps {
280
280
  */
281
281
  showStarButton?: boolean
282
282
 
283
+ /**
284
+ * Show the starred badge next to the participant name in the channel header
285
+ * when the channel is starred. Defaults to `showStarButton`, so hosts that
286
+ * replace the star button with their own control (e.g. a context menu via
287
+ * `renderChannelActions`) can keep the badge by passing this explicitly.
288
+ */
289
+ showStarBadge?: boolean
290
+
283
291
  /**
284
292
  * @deprecated No longer rendered. The redesigned header shows built-in paid
285
293
  * and starred badges instead. Kept temporarily so existing call sites type-check.