@linktr.ee/messaging-react 1.40.0 → 1.40.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.
package/dist/index.d.ts CHANGED
@@ -283,6 +283,8 @@ export declare interface FaqListProps {
283
283
  */
284
284
  export declare const formatRelativeTime: (date: Date) => string;
285
285
 
286
+ export declare function isLinkAttachment(a: Attachment): boolean;
287
+
286
288
  export declare const LockedAttachment: {
287
289
  Creator: (props: CreatorCardProps) => JSX_2.Element;
288
290
  Visitor: (props: VisitorCardProps) => JSX_2.Element;
package/dist/index.js CHANGED
@@ -1,23 +1,24 @@
1
- import { b as a, c as t, C as i, d as n, e as o, f as g, F as r, g as M, L as m, M as l, h as u, i as h, j as d, k as v, r as C, l as L, u as c, m as A, n as F } from "./index-DY-3-rt4.js";
1
+ import { b as e, c as t, C as i, d as n, e as o, f as g, F as m, g as r, L as M, M as l, h, i as u, j as L, k as c, l as d, r as v, m as C, u as A, n as k, o as F } from "./index-B_PLgcDi.js";
2
2
  export {
3
- a as ActionButton,
3
+ e as ActionButton,
4
4
  t as Avatar,
5
5
  i as ChannelEmptyState,
6
6
  n as ChannelList,
7
7
  o as ChannelView,
8
8
  g as CustomMessageProvider,
9
- r as FaqList,
10
- M as FaqListItem,
11
- m as LockedAttachment,
9
+ m as FaqList,
10
+ r as FaqListItem,
11
+ M as LockedAttachment,
12
12
  l as MediaMessage,
13
- u as MessageVoteButtons,
14
- h as MessagingProvider,
15
- d as MessagingShell,
16
- v as formatRelativeTime,
17
- C as resolveLinkAttachment,
18
- L as resolveMediaFromMessage,
19
- c as useCustomMessage,
20
- A as useMessageVote,
13
+ h as MessageVoteButtons,
14
+ u as MessagingProvider,
15
+ L as MessagingShell,
16
+ c as formatRelativeTime,
17
+ d as isLinkAttachment,
18
+ v as resolveLinkAttachment,
19
+ C as resolveMediaFromMessage,
20
+ A as useCustomMessage,
21
+ k as useMessageVote,
21
22
  F as useMessaging
22
23
  };
23
24
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "1.40.0",
3
+ "version": "1.40.2",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -54,7 +54,7 @@ export const Avatar = ({
54
54
  <img
55
55
  src={image}
56
56
  alt=""
57
- className="aspect-square h-full w-full object-cover"
57
+ className="h-full w-full object-cover"
58
58
  />
59
59
  ) : (
60
60
  <div
@@ -77,9 +77,10 @@ export const Avatar = ({
77
77
  className
78
78
  )}
79
79
  style={{
80
+ '--str-chat__avatar-size': `${size}px`,
80
81
  width: `${size}px`,
81
82
  height: `${size}px`,
82
- }}
83
+ } as React.CSSProperties}
83
84
  >
84
85
  {starred && (
85
86
  <div
@@ -386,6 +386,34 @@ ChatbotVariants.args = {
386
386
  ],
387
387
  }
388
388
 
389
+ export const ChatbotLinkPreviews: StoryFn<TemplateProps> = Template.bind({})
390
+ ChatbotLinkPreviews.args = {
391
+ messages: [
392
+ {
393
+ id: 'msg-1',
394
+ text: 'Check the FAQ pages: pizzeriamozza.com/faq or osteriamozza.com/faq.',
395
+ user: storyUsers.creator,
396
+ metadata: { custom_type: 'MESSAGE_CHATBOT' },
397
+ attachments: [
398
+ {
399
+ type: 'link',
400
+ og_scrape_url: 'https://www.pizzeriamozza.com/faq',
401
+ title: 'Pizzeria Mozza | Pizza Restaurant in CA',
402
+ text: 'FAQ | Pizzeria Mozza',
403
+ image_url: 'https://picsum.photos/seed/mozza1/560/315',
404
+ },
405
+ {
406
+ type: 'link',
407
+ og_scrape_url: 'https://www.osteriamozza.com/faq',
408
+ title: 'Osteria Mozza | Italian Restaurant in LA',
409
+ text: 'FAQ | Osteria Mozza',
410
+ image_url: 'https://picsum.photos/seed/mozza2/560/315',
411
+ },
412
+ ],
413
+ },
414
+ ],
415
+ }
416
+
389
417
  export const WithTypingIndicatorComparison: StoryFn<TemplateProps> =
390
418
  Template.bind({})
391
419
  WithTypingIndicatorComparison.args = {
@@ -32,6 +32,7 @@ import {
32
32
  import { useMessageVote } from '../../hooks/useMessageVote'
33
33
  import { Avatar } from '../Avatar'
34
34
  import LockedAttachment from '../LockedAttachment'
35
+ import { isLinkAttachment } from '../MediaMessage'
35
36
 
36
37
  import { useCustomMessage } from './context'
37
38
  import {
@@ -95,15 +96,17 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
95
96
  () => isMessageAIGenerated?.(message),
96
97
  [isMessageAIGenerated, message]
97
98
  )
98
- const finalAttachments = useMemo(
99
- () =>
100
- !message.shared_location && !message.attachments
101
- ? []
102
- : !message.shared_location
103
- ? message.attachments
104
- : [message.shared_location, ...(message.attachments ?? [])],
105
- [message]
106
- )
99
+ const finalAttachments = useMemo(() => {
100
+ const attachments = message.attachments ?? []
101
+ const raw = message.shared_location
102
+ ? [message.shared_location, ...attachments]
103
+ : attachments
104
+
105
+ if (!isChatbotMessage(message)) return raw
106
+
107
+ const filtered = raw.filter((a) => !('type' in a) || !isLinkAttachment(a))
108
+ return filtered.length === raw.length ? raw : filtered
109
+ }, [message])
107
110
 
108
111
  if (isDateSeparatorMessage(message)) {
109
112
  return null
@@ -188,6 +191,9 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
188
191
  id={message.user.id}
189
192
  image={message.user.image}
190
193
  name={message.user.name || message.user.id}
194
+ size={isChatbot ? 24 : 28}
195
+ shape="circle"
196
+ dmAgentEnabled={isChatbot}
191
197
  />
192
198
  )}
193
199
  {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
@@ -95,12 +95,14 @@ const LinkCard: React.FC<{
95
95
  return <div className="block">{body}</div>
96
96
  }
97
97
 
98
+ export function isLinkAttachment(a: Attachment): boolean {
99
+ return a.type === 'link' || (!!a.og_scrape_url && !a.asset_url)
100
+ }
101
+
98
102
  export function resolveLinkAttachment(
99
103
  message: LocalMessage
100
104
  ): Attachment | undefined {
101
- return message.attachments?.find(
102
- (a) => a.type === 'link' || (!!a.og_scrape_url && !a.asset_url)
103
- )
105
+ return message.attachments?.find(isLinkAttachment)
104
106
  }
105
107
 
106
108
  async function triggerDownload(url: string, filename?: string): Promise<void> {
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ export { ChannelEmptyState } from './components/MessagingShell/ChannelEmptyState
14
14
  export { MessageVoteButtons } from './components/CustomMessage/MessageVoteButtons'
15
15
  export {
16
16
  MediaMessage,
17
+ isLinkAttachment,
17
18
  resolveLinkAttachment,
18
19
  resolveMediaFromMessage,
19
20
  } from './components/MediaMessage'
package/src/styles.css CHANGED
@@ -137,10 +137,6 @@
137
137
  .str-chat__attachment-list .str-chat__message-attachment--card {
138
138
  color: white;
139
139
  }
140
-
141
- a {
142
- color: color-mix(in srgb, white 60%, #005fff);
143
- }
144
140
  }
145
141
 
146
142
  .str-chat__unread-messages-separator,
@@ -169,7 +165,7 @@
169
165
 
170
166
  .str-chat__li .str-chat__message--other {
171
167
  position: relative;
172
- grid-template-columns: 40px 1fr;
168
+ grid-template-columns: 28px 1fr;
173
169
  }
174
170
 
175
171
  .str-chat__li .str-chat__message--other .str-chat__message-bubble-wrapper {
@@ -369,6 +365,7 @@
369
365
  }
370
366
 
371
367
  .str-chat__message-text-inner a {
368
+ color: inherit;
372
369
  text-decoration: underline;
373
370
  text-underline-offset: 0.15em;
374
371
  word-break: break-word;