@planningcenter/chat-react-native 3.1.0-rc.13 → 3.1.0-rc.15

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 (252) hide show
  1. package/build/components/conversation/attachments/attachment_card.d.ts +9 -0
  2. package/build/components/conversation/attachments/attachment_card.d.ts.map +1 -0
  3. package/build/components/conversation/attachments/attachment_card.js +35 -0
  4. package/build/components/conversation/attachments/attachment_card.js.map +1 -0
  5. package/build/components/conversation/attachments/audio_attachment.d.ts +6 -0
  6. package/build/components/conversation/attachments/audio_attachment.d.ts.map +1 -0
  7. package/build/components/conversation/attachments/audio_attachment.js +84 -0
  8. package/build/components/conversation/attachments/audio_attachment.js.map +1 -0
  9. package/build/components/conversation/attachments/constants.d.ts +3 -0
  10. package/build/components/conversation/attachments/constants.d.ts.map +1 -0
  11. package/build/components/conversation/attachments/constants.js +4 -0
  12. package/build/components/conversation/attachments/constants.js.map +1 -0
  13. package/build/components/conversation/attachments/download_attachment_button.d.ts +9 -0
  14. package/build/components/conversation/attachments/download_attachment_button.d.ts.map +1 -0
  15. package/build/components/conversation/attachments/download_attachment_button.js +29 -0
  16. package/build/components/conversation/attachments/download_attachment_button.js.map +1 -0
  17. package/build/components/conversation/attachments/expanded_link.d.ts +5 -0
  18. package/build/components/conversation/attachments/expanded_link.d.ts.map +1 -0
  19. package/build/components/conversation/attachments/expanded_link.js +44 -0
  20. package/build/components/conversation/attachments/expanded_link.js.map +1 -0
  21. package/build/components/conversation/attachments/generic_file_attachment.d.ts +7 -0
  22. package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -0
  23. package/build/components/conversation/attachments/generic_file_attachment.js +63 -0
  24. package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -0
  25. package/build/components/conversation/attachments/giphy_attachment.d.ts +6 -0
  26. package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -0
  27. package/build/components/conversation/attachments/giphy_attachment.js +42 -0
  28. package/build/components/conversation/attachments/giphy_attachment.js.map +1 -0
  29. package/build/components/conversation/attachments/image_attachment.d.ts +5 -0
  30. package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -0
  31. package/build/components/conversation/attachments/image_attachment.js +24 -0
  32. package/build/components/conversation/attachments/image_attachment.js.map +1 -0
  33. package/build/components/conversation/attachments/video_attachment.d.ts +6 -0
  34. package/build/components/conversation/attachments/video_attachment.d.ts.map +1 -0
  35. package/build/components/conversation/attachments/video_attachment.js +64 -0
  36. package/build/components/conversation/attachments/video_attachment.js.map +1 -0
  37. package/build/components/conversation/message.d.ts +1 -1
  38. package/build/components/conversation/message.d.ts.map +1 -1
  39. package/build/components/conversation/message.js +13 -7
  40. package/build/components/conversation/message.js.map +1 -1
  41. package/build/components/conversation/message_attachments.d.ts +6 -0
  42. package/build/components/conversation/message_attachments.d.ts.map +1 -0
  43. package/build/components/conversation/message_attachments.js +52 -0
  44. package/build/components/conversation/message_attachments.js.map +1 -0
  45. package/build/components/conversation/message_markdown.d.ts +7 -0
  46. package/build/components/conversation/message_markdown.d.ts.map +1 -0
  47. package/build/components/conversation/message_markdown.js +38 -0
  48. package/build/components/conversation/message_markdown.js.map +1 -0
  49. package/build/components/conversations/conversation_preview.d.ts +9 -0
  50. package/build/components/conversations/conversation_preview.d.ts.map +1 -0
  51. package/build/components/conversations/conversation_preview.js +58 -0
  52. package/build/components/conversations/conversation_preview.js.map +1 -0
  53. package/build/components/conversations/conversations.d.ts +8 -0
  54. package/build/components/conversations/conversations.d.ts.map +1 -0
  55. package/build/components/conversations/conversations.js +40 -0
  56. package/build/components/conversations/conversations.js.map +1 -0
  57. package/build/components/conversations/unread_count_badge.d.ts +5 -0
  58. package/build/components/conversations/unread_count_badge.d.ts.map +1 -0
  59. package/build/components/conversations/unread_count_badge.js +33 -0
  60. package/build/components/conversations/unread_count_badge.js.map +1 -0
  61. package/build/components/display/badge.d.ts +9 -1
  62. package/build/components/display/badge.d.ts.map +1 -1
  63. package/build/components/display/badge.js +22 -10
  64. package/build/components/display/badge.js.map +1 -1
  65. package/build/components/display/button.d.ts +1 -1
  66. package/build/components/display/button.d.ts.map +1 -1
  67. package/build/components/display/button.js.map +1 -1
  68. package/build/components/display/child_notice.js +2 -2
  69. package/build/components/display/child_notice.js.map +1 -1
  70. package/build/components/display/icon.d.ts.map +1 -1
  71. package/build/components/display/icon.js +10 -8
  72. package/build/components/display/icon.js.map +1 -1
  73. package/build/components/display/text.js +2 -8
  74. package/build/components/display/text.js.map +1 -1
  75. package/build/components/index.d.ts +1 -1
  76. package/build/components/index.d.ts.map +1 -1
  77. package/build/components/index.js +1 -1
  78. package/build/components/index.js.map +1 -1
  79. package/build/components/page/error_boundary.d.ts +1 -1
  80. package/build/hooks/use_api.d.ts +6 -4
  81. package/build/hooks/use_api.d.ts.map +1 -1
  82. package/build/hooks/use_api.js +5 -2
  83. package/build/hooks/use_api.js.map +1 -1
  84. package/build/hooks/use_api_client.d.ts +1 -2
  85. package/build/hooks/use_api_client.d.ts.map +1 -1
  86. package/build/hooks/use_api_client.js.map +1 -1
  87. package/build/hooks/use_conversation.js +1 -1
  88. package/build/hooks/use_conversation.js.map +1 -1
  89. package/build/hooks/use_conversation_jolt_events.js +1 -1
  90. package/build/hooks/use_conversation_jolt_events.js.map +1 -1
  91. package/build/hooks/use_conversation_messages_jolt_events.js +1 -1
  92. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
  93. package/build/hooks/use_conversations.d.ts +2 -3
  94. package/build/hooks/use_conversations.d.ts.map +1 -1
  95. package/build/hooks/use_conversations.js +3 -29
  96. package/build/hooks/use_conversations.js.map +1 -1
  97. package/build/hooks/use_groups.d.ts +214 -0
  98. package/build/hooks/use_groups.d.ts.map +1 -0
  99. package/build/hooks/use_groups.js +22 -0
  100. package/build/hooks/use_groups.js.map +1 -0
  101. package/build/hooks/use_groups_groups.d.ts +208 -0
  102. package/build/hooks/use_groups_groups.d.ts.map +1 -0
  103. package/build/hooks/use_groups_groups.js +18 -0
  104. package/build/hooks/use_groups_groups.js.map +1 -0
  105. package/build/hooks/use_services_team.d.ts +4 -0
  106. package/build/hooks/use_services_team.d.ts.map +1 -0
  107. package/build/hooks/use_services_team.js +22 -0
  108. package/build/hooks/use_services_team.js.map +1 -0
  109. package/build/hooks/use_suspense_api.d.ts +2 -1
  110. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  111. package/build/hooks/use_suspense_api.js +2 -1
  112. package/build/hooks/use_suspense_api.js.map +1 -1
  113. package/build/hooks/use_teams.d.ts +208 -0
  114. package/build/hooks/use_teams.d.ts.map +1 -0
  115. package/build/hooks/use_teams.js +22 -0
  116. package/build/hooks/use_teams.js.map +1 -0
  117. package/build/navigation/index.d.ts +11 -0
  118. package/build/navigation/index.d.ts.map +1 -1
  119. package/build/navigation/index.js +5 -0
  120. package/build/navigation/index.js.map +1 -1
  121. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  122. package/build/screens/conversation_details_screen.js +86 -62
  123. package/build/screens/conversation_details_screen.js.map +1 -1
  124. package/build/screens/conversation_filters_screen.d.ts +13 -0
  125. package/build/screens/conversation_filters_screen.d.ts.map +1 -0
  126. package/build/screens/conversation_filters_screen.js +346 -0
  127. package/build/screens/conversation_filters_screen.js.map +1 -0
  128. package/build/screens/conversation_screen.js +2 -1
  129. package/build/screens/conversation_screen.js.map +1 -1
  130. package/build/screens/conversations_screen.d.ts +4 -2
  131. package/build/screens/conversations_screen.d.ts.map +1 -1
  132. package/build/screens/conversations_screen.js +139 -11
  133. package/build/screens/conversations_screen.js.map +1 -1
  134. package/build/screens/create/conversation_select_recipients_screen.d.ts.map +1 -1
  135. package/build/screens/create/conversation_select_recipients_screen.js +3 -11
  136. package/build/screens/create/conversation_select_recipients_screen.js.map +1 -1
  137. package/build/types/resources/group_resource.d.ts +4 -2
  138. package/build/types/resources/group_resource.d.ts.map +1 -1
  139. package/build/types/resources/group_resource.js.map +1 -1
  140. package/build/types/resources/index.d.ts +1 -0
  141. package/build/types/resources/index.d.ts.map +1 -1
  142. package/build/types/resources/index.js +1 -0
  143. package/build/types/resources/index.js.map +1 -1
  144. package/build/types/resources/services/index.d.ts +2 -0
  145. package/build/types/resources/services/index.d.ts.map +1 -0
  146. package/build/types/resources/services/index.js +2 -0
  147. package/build/types/resources/services/index.js.map +1 -0
  148. package/build/types/resources/services/team_resource.d.ts +48 -0
  149. package/build/types/resources/services/team_resource.d.ts.map +1 -0
  150. package/build/types/resources/services/team_resource.js +7 -0
  151. package/build/types/resources/services/team_resource.js.map +1 -0
  152. package/build/utils/index.d.ts +1 -0
  153. package/build/utils/index.d.ts.map +1 -1
  154. package/build/utils/index.js +1 -0
  155. package/build/utils/index.js.map +1 -1
  156. package/build/utils/native_adapters/audio.d.ts +13 -0
  157. package/build/utils/native_adapters/audio.d.ts.map +1 -0
  158. package/build/utils/native_adapters/audio.js +7 -0
  159. package/build/utils/native_adapters/audio.js.map +1 -0
  160. package/build/utils/native_adapters/configuration.d.ts +7 -1
  161. package/build/utils/native_adapters/configuration.d.ts.map +1 -1
  162. package/build/utils/native_adapters/configuration.js +17 -1
  163. package/build/utils/native_adapters/configuration.js.map +1 -1
  164. package/build/utils/native_adapters/index.d.ts +2 -0
  165. package/build/utils/native_adapters/index.d.ts.map +1 -1
  166. package/build/utils/native_adapters/index.js +2 -0
  167. package/build/utils/native_adapters/index.js.map +1 -1
  168. package/build/utils/native_adapters/video.d.ts +25 -0
  169. package/build/utils/native_adapters/video.d.ts.map +1 -0
  170. package/build/utils/native_adapters/video.js +7 -0
  171. package/build/utils/native_adapters/video.js.map +1 -0
  172. package/build/utils/parse_simple_markdown.d.ts +7 -0
  173. package/build/utils/parse_simple_markdown.d.ts.map +1 -0
  174. package/build/utils/parse_simple_markdown.js +32 -0
  175. package/build/utils/parse_simple_markdown.js.map +1 -0
  176. package/build/utils/pluralize.d.ts +2 -0
  177. package/build/utils/pluralize.d.ts.map +1 -0
  178. package/build/utils/pluralize.js +10 -0
  179. package/build/utils/pluralize.js.map +1 -0
  180. package/build/utils/request/conversation.d.ts +10 -0
  181. package/build/utils/request/conversation.d.ts.map +1 -0
  182. package/build/utils/request/conversation.js +32 -0
  183. package/build/utils/request/conversation.js.map +1 -0
  184. package/build/utils/request/messages.d.ts +15 -0
  185. package/build/utils/request/messages.d.ts.map +1 -0
  186. package/build/utils/request/messages.js +22 -0
  187. package/build/utils/request/messages.js.map +1 -0
  188. package/build/utils/theme.d.ts +1 -1
  189. package/build/utils/theme.d.ts.map +1 -1
  190. package/build/utils/theme.js +1 -1
  191. package/build/utils/theme.js.map +1 -1
  192. package/package.json +2 -2
  193. package/src/__tests__/utils/parse_simple_markdown.ts +93 -0
  194. package/src/__tests__/utils/pluralize.tsx +17 -0
  195. package/src/components/conversation/attachments/attachment_card.tsx +46 -0
  196. package/src/components/conversation/attachments/audio_attachment.tsx +102 -0
  197. package/src/components/conversation/attachments/constants.ts +5 -0
  198. package/src/components/conversation/attachments/download_attachment_button.tsx +46 -0
  199. package/src/components/conversation/attachments/expanded_link.tsx +54 -0
  200. package/src/components/conversation/attachments/generic_file_attachment.tsx +75 -0
  201. package/src/components/conversation/attachments/giphy_attachment.tsx +56 -0
  202. package/src/components/conversation/attachments/image_attachment.tsx +31 -0
  203. package/src/components/conversation/attachments/video_attachment.tsx +92 -0
  204. package/src/components/conversation/message.tsx +15 -6
  205. package/src/components/conversation/message_attachments.tsx +61 -0
  206. package/src/components/conversation/message_markdown.tsx +52 -0
  207. package/src/components/conversations/conversation_preview.tsx +84 -0
  208. package/src/components/conversations/conversations.tsx +79 -0
  209. package/src/components/conversations/unread_count_badge.tsx +38 -0
  210. package/src/components/display/badge.tsx +41 -10
  211. package/src/components/display/button.tsx +1 -1
  212. package/src/components/display/child_notice.tsx +2 -2
  213. package/src/components/display/icon.tsx +10 -8
  214. package/src/components/display/text.tsx +1 -7
  215. package/src/components/index.tsx +1 -1
  216. package/src/hooks/use_api.ts +11 -10
  217. package/src/hooks/use_api_client.ts +1 -1
  218. package/src/hooks/use_conversation.ts +1 -1
  219. package/src/hooks/use_conversation_jolt_events.ts +1 -1
  220. package/src/hooks/use_conversation_messages_jolt_events.ts +1 -1
  221. package/src/hooks/use_conversations.ts +3 -31
  222. package/src/hooks/use_groups.ts +31 -0
  223. package/src/hooks/use_groups_groups.ts +20 -0
  224. package/src/hooks/use_services_team.ts +30 -0
  225. package/src/hooks/use_suspense_api.ts +4 -4
  226. package/src/hooks/use_teams.ts +25 -0
  227. package/src/navigation/index.tsx +8 -0
  228. package/src/screens/conversation_details_screen.tsx +149 -117
  229. package/src/screens/conversation_filters_screen.tsx +488 -0
  230. package/src/screens/conversation_screen.tsx +8 -1
  231. package/src/screens/conversations_screen.tsx +210 -13
  232. package/src/screens/create/conversation_select_recipients_screen.tsx +3 -11
  233. package/src/types/resources/group_resource.ts +5 -2
  234. package/src/types/resources/index.ts +1 -0
  235. package/src/types/resources/services/index.ts +1 -0
  236. package/src/types/resources/services/team_resource.ts +60 -0
  237. package/src/utils/client/types.d.ts +2 -1
  238. package/src/utils/index.ts +1 -0
  239. package/src/utils/native_adapters/audio.ts +15 -0
  240. package/src/utils/native_adapters/configuration.ts +24 -1
  241. package/src/utils/native_adapters/index.ts +2 -0
  242. package/src/utils/native_adapters/video.ts +30 -0
  243. package/src/utils/parse_simple_markdown.ts +40 -0
  244. package/src/utils/pluralize.ts +11 -0
  245. package/src/utils/request/conversation.ts +46 -0
  246. package/src/utils/request/messages.ts +21 -0
  247. package/src/utils/theme.ts +2 -2
  248. package/build/components/conversations.d.ts +0 -3
  249. package/build/components/conversations.d.ts.map +0 -1
  250. package/build/components/conversations.js +0 -100
  251. package/build/components/conversations.js.map +0 -1
  252. package/src/components/conversations.tsx +0 -144
@@ -6,6 +6,9 @@ import { StyleSheet, View } from 'react-native';
6
6
  import { MessageReaction } from '../../components/conversation/message_reaction';
7
7
  import { Avatar, Text } from '../../components/display';
8
8
  import { useTheme } from '../../hooks';
9
+ import { MessageAttachments } from './message_attachments';
10
+ import ErrorBoundary from '../page/error_boundary';
11
+ import { MessageMarkdown } from './message_markdown';
9
12
  /** Message
10
13
  * Component for display of a message within a conversation list
11
14
  */
@@ -26,8 +29,6 @@ export function Message(props) {
26
29
  reaction_value: reaction.value,
27
30
  });
28
31
  };
29
- if (!text)
30
- return null;
31
32
  return (<View style={styles.message}>
32
33
  {!props.mine && (<View style={styles.messageAuthor}>
33
34
  <Avatar size={'md'} sourceUri={props.author.avatar}/>
@@ -35,7 +36,12 @@ export function Message(props) {
35
36
  <View style={styles.messageContent}>
36
37
  {!props.mine && <Text variant="tertiary">{props.author.name}</Text>}
37
38
  <PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>
38
- <Text style={styles.messageText}>{text}</Text>
39
+ <ErrorBoundary>
40
+ <MessageAttachments attachments={props.attachments}/>
41
+ </ErrorBoundary>
42
+ {text && (<View style={styles.messageText}>
43
+ <MessageMarkdown text={text}/>
44
+ </View>)}
39
45
  </PlatformPressable>
40
46
  <View style={styles.messageReactions}>
41
47
  {reactionCounts.map(reaction => (<MessageReaction key={reaction.value} reaction={reaction} onPress={handleReactionPress}/>))}
@@ -61,12 +67,12 @@ const useMessageStyles = ({ mine }) => {
61
67
  },
62
68
  messageBubble: {
63
69
  backgroundColor: mine ? activeColor : colors.fillColorNeutral070,
64
- borderRadius: 12,
65
- paddingVertical: 6,
66
- paddingHorizontal: 8,
70
+ borderRadius: 8,
71
+ maxWidth: 232,
67
72
  },
68
73
  messageText: {
69
- color: colors.textColorDefaultPrimary,
74
+ paddingVertical: 6,
75
+ paddingHorizontal: 8,
70
76
  },
71
77
  messageReactions: {
72
78
  flexDirection: 'row',
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,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,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK;SAC5C;QACD,cAAc,EAAE;YACd,GAAG,EAAE,CAAC;YACN,UAAU,EAAE,CAAC;SACd;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE;YACb,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAChE,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;SACrB;QACD,WAAW,EAAE;YACX,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;QACD,gBAAgB,EAAE;YAChB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { useNavigation } from '@react-navigation/native'\nimport colorFunction from 'color'\nimport React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { MessageReaction } from '../../components/conversation/message_reaction'\nimport { Avatar, Text } from '../../components/display'\nimport { useTheme } from '../../hooks'\nimport { MessageResource } from '../../types'\nimport { ReactionCountResource } from '../../types/resources/reaction'\n\n/** Message\n * Component for display of a message within a conversation list\n */\nexport function Message(props: MessageResource & { conversation_id: number }) {\n const { text, conversation_id, reactionCounts } = props\n const styles = useMessageStyles(props)\n const navigation = useNavigation()\n const handleMessagePress = () => {\n navigation.navigate('MessageActions', {\n message_id: props.id,\n conversation_id,\n })\n }\n const handleReactionPress = (reaction: ReactionCountResource) => {\n navigation.navigate('Reactions', {\n message_id: props.id,\n conversation_id,\n reaction_value: reaction.value,\n })\n }\n if (!text) return null\n\n return (\n <View style={styles.message}>\n {!props.mine && (\n <View style={styles.messageAuthor}>\n <Avatar size={'md'} sourceUri={props.author.avatar} />\n </View>\n )}\n <View style={styles.messageContent}>\n {!props.mine && <Text variant=\"tertiary\">{props.author.name}</Text>}\n <PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>\n <Text style={styles.messageText}>{text}</Text>\n </PlatformPressable>\n <View style={styles.messageReactions}>\n {reactionCounts.map(reaction => (\n <MessageReaction\n key={reaction.value}\n reaction={reaction}\n onPress={handleReactionPress}\n />\n ))}\n </View>\n </View>\n </View>\n )\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n const activeColor = colorFunction(colors.interaction).alpha(0.2).string()\n\n return StyleSheet.create({\n message: {\n gap: 8,\n flexDirection: mine ? 'row-reverse' : 'row',\n },\n messageContent: {\n gap: 8,\n flexShrink: 1,\n },\n messageAuthor: {\n flexDirection: 'row',\n gap: 8,\n },\n messageBubble: {\n backgroundColor: mine ? activeColor : colors.fillColorNeutral070,\n borderRadius: 12,\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageText: {\n color: colors.textColorDefaultPrimary,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n })\n}\n"]}
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE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CAAC;YACN,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK;SAC5C;QACD,cAAc,EAAE;YACd,GAAG,EAAE,CAAC;YACN,UAAU,EAAE,CAAC;SACd;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE;YACb,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAChE,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,GAAG;SACd;QACD,WAAW,EAAE;YACX,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;SACrB;QACD,gBAAgB,EAAE;YAChB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { useNavigation } from '@react-navigation/native'\nimport colorFunction from 'color'\nimport React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { MessageReaction } from '../../components/conversation/message_reaction'\nimport { Avatar, Text } from '../../components/display'\nimport { useTheme } from '../../hooks'\nimport { MessageResource } from '../../types'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageAttachments } from './message_attachments'\nimport ErrorBoundary from '../page/error_boundary'\nimport { MessageMarkdown } from './message_markdown'\n\n/** Message\n * Component for display of a message within a conversation list\n */\nexport function Message(props: MessageResource & { conversation_id: number }) {\n const { text, conversation_id, reactionCounts } = props\n const styles = useMessageStyles(props)\n const navigation = useNavigation()\n const handleMessagePress = () => {\n navigation.navigate('MessageActions', {\n message_id: props.id,\n conversation_id,\n })\n }\n const handleReactionPress = (reaction: ReactionCountResource) => {\n navigation.navigate('Reactions', {\n message_id: props.id,\n conversation_id,\n reaction_value: reaction.value,\n })\n }\n\n return (\n <View style={styles.message}>\n {!props.mine && (\n <View style={styles.messageAuthor}>\n <Avatar size={'md'} sourceUri={props.author.avatar} />\n </View>\n )}\n <View style={styles.messageContent}>\n {!props.mine && <Text variant=\"tertiary\">{props.author.name}</Text>}\n <PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>\n <ErrorBoundary>\n <MessageAttachments attachments={props.attachments} />\n </ErrorBoundary>\n {text && (\n <View style={styles.messageText}>\n <MessageMarkdown text={text} />\n </View>\n )}\n </PlatformPressable>\n <View style={styles.messageReactions}>\n {reactionCounts.map(reaction => (\n <MessageReaction\n key={reaction.value}\n reaction={reaction}\n onPress={handleReactionPress}\n />\n ))}\n </View>\n </View>\n </View>\n )\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n const activeColor = colorFunction(colors.interaction).alpha(0.2).string()\n\n return StyleSheet.create({\n message: {\n gap: 8,\n flexDirection: mine ? 'row-reverse' : 'row',\n },\n messageContent: {\n gap: 8,\n flexShrink: 1,\n },\n messageAuthor: {\n flexDirection: 'row',\n gap: 8,\n },\n messageBubble: {\n backgroundColor: mine ? activeColor : colors.fillColorNeutral070,\n borderRadius: 8,\n maxWidth: 232,\n },\n messageText: {\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n })\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource';
3
+ export declare function MessageAttachments(props: {
4
+ attachments: DenormalizedAttachmentResource[];
5
+ }): React.JSX.Element | null;
6
+ //# sourceMappingURL=message_attachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_attachments.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,8BAA8B,EAAE,MAAM,wDAAwD,CAAA;AAQvG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,8BAA8B,EAAE,CAAA;CAAE,4BAyB1F"}
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { AudioAttachment } from './attachments/audio_attachment';
4
+ import { VideoAttachment } from './attachments/video_attachment';
5
+ import { GiphyAttachment } from './attachments/giphy_attachment';
6
+ import { GenericFileAttachment } from './attachments/generic_file_attachment';
7
+ import { ExpandedLink } from './attachments/expanded_link';
8
+ import { ImageAttachment } from './attachments/image_attachment';
9
+ export function MessageAttachments(props) {
10
+ const styles = useStyles();
11
+ const { attachments } = props;
12
+ if (!attachments || attachments.length === 0)
13
+ return null;
14
+ return (<View style={styles.attachmentsContainer}>
15
+ {attachments.map(attachment => {
16
+ switch (attachment.type) {
17
+ case 'MessageAttachment':
18
+ return <MessageAttachment key={attachment.id} attachment={attachment}/>;
19
+ case 'giphy':
20
+ return (<GiphyAttachment key={attachment.id || attachment.titleLink} attachment={attachment}/>);
21
+ case 'ExpandedLink':
22
+ return <ExpandedLink key={attachment.id} attachment={attachment}/>;
23
+ default:
24
+ return null;
25
+ }
26
+ })}
27
+ </View>);
28
+ }
29
+ function MessageAttachment({ attachment }) {
30
+ const { attributes } = attachment;
31
+ const contentType = attributes?.contentType;
32
+ const basicType = contentType ? contentType.split('/')[0] : '';
33
+ switch (basicType) {
34
+ case 'image':
35
+ return <ImageAttachment attachment={attachment}/>;
36
+ case 'video':
37
+ return <VideoAttachment attachment={attachment}/>;
38
+ case 'audio':
39
+ return <AudioAttachment attachment={attachment}/>;
40
+ default:
41
+ return <GenericFileAttachment attachment={attachment}/>;
42
+ }
43
+ }
44
+ const useStyles = () => {
45
+ return StyleSheet.create({
46
+ attachmentsContainer: {
47
+ gap: 4,
48
+ padding: 2,
49
+ },
50
+ });
51
+ };
52
+ //# sourceMappingURL=message_attachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_attachments.js","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,MAAM,UAAU,kBAAkB,CAAC,KAAwD;IACzF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;IAC7B,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CACvC;MAAA,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC5B,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;gBACxB,KAAK,mBAAmB;oBACtB,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;gBAC1E,KAAK,OAAO;oBACV,OAAO,CACL,CAAC,eAAe,CACd,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,UAAU,CAAC,SAAS,CAAC,CAC3C,UAAU,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAA;gBACH,KAAK,cAAc;oBACjB,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;gBACrE;oBACE,OAAO,IAAI,CAAA;YACf,CAAC;QACH,CAAC,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,EAAE,UAAU,EAAuB;IAC5D,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,WAAW,GAAG,UAAU,EAAE,WAAW,CAAA;IAC3C,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9D,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;QACpD,KAAK,OAAO;YACV,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;QACpD,KAAK,OAAO;YACV,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;QACpD;YACE,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,oBAAoB,EAAE;YACpB,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,CAAC;SACX;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, StyleSheet } from 'react-native'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { AudioAttachment } from './attachments/audio_attachment'\nimport { VideoAttachment } from './attachments/video_attachment'\nimport { GiphyAttachment } from './attachments/giphy_attachment'\nimport { GenericFileAttachment } from './attachments/generic_file_attachment'\nimport { ExpandedLink } from './attachments/expanded_link'\nimport { ImageAttachment } from './attachments/image_attachment'\n\nexport function MessageAttachments(props: { attachments: DenormalizedAttachmentResource[] }) {\n const styles = useStyles()\n const { attachments } = props\n if (!attachments || attachments.length === 0) return null\n return (\n <View style={styles.attachmentsContainer}>\n {attachments.map(attachment => {\n switch (attachment.type) {\n case 'MessageAttachment':\n return <MessageAttachment key={attachment.id} attachment={attachment} />\n case 'giphy':\n return (\n <GiphyAttachment\n key={attachment.id || attachment.titleLink}\n attachment={attachment}\n />\n )\n case 'ExpandedLink':\n return <ExpandedLink key={attachment.id} attachment={attachment} />\n default:\n return null\n }\n })}\n </View>\n )\n}\n\nfunction MessageAttachment({ attachment }: { attachment: any }) {\n const { attributes } = attachment\n const contentType = attributes?.contentType\n const basicType = contentType ? contentType.split('/')[0] : ''\n switch (basicType) {\n case 'image':\n return <ImageAttachment attachment={attachment} />\n case 'video':\n return <VideoAttachment attachment={attachment} />\n case 'audio':\n return <AudioAttachment attachment={attachment} />\n default:\n return <GenericFileAttachment attachment={attachment} />\n }\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n attachmentsContainer: {\n gap: 4,\n padding: 2,\n },\n })\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ text: string;
4
+ }
5
+ export declare function MessageMarkdown({ text }: Props): React.JSX.Element | null;
6
+ export {};
7
+ //# sourceMappingURL=message_markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_markdown.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,4BAoC9C"}
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { Linking, StyleSheet } from 'react-native';
3
+ import { Text } from '../display';
4
+ import { parseSimpleMarkdown } from '../../utils/parse_simple_markdown';
5
+ export function MessageMarkdown({ text }) {
6
+ if (!text)
7
+ return null;
8
+ // Skip markdown for excessively long messages for performance reasons
9
+ if (text.length > 5000)
10
+ return <Text>{text}</Text>;
11
+ const parsed = parseSimpleMarkdown(text);
12
+ return (<Text>
13
+ {parsed.map((part, i) => {
14
+ switch (part.type) {
15
+ case 'bold':
16
+ return (<Text key={i} style={styles.bold}>
17
+ {part.content}
18
+ </Text>);
19
+ case 'italic':
20
+ return (<Text key={i} style={styles.italic}>
21
+ {part.content}
22
+ </Text>);
23
+ case 'link':
24
+ return (<Text key={i} style={styles.link} onPress={() => Linking.openURL(part.content)}>
25
+ {part.content}
26
+ </Text>);
27
+ default:
28
+ return <Text key={i}>{part.content}</Text>;
29
+ }
30
+ })}
31
+ </Text>);
32
+ }
33
+ const styles = StyleSheet.create({
34
+ bold: { fontWeight: 'bold' },
35
+ italic: { fontStyle: 'italic' },
36
+ link: { color: 'blue', textDecorationLine: 'underline' },
37
+ });
38
+ //# sourceMappingURL=message_markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_markdown.js","sourceRoot":"","sources":["../../../src/components/conversation/message_markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAMvE,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAS;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,sEAAsE;IACtE,IAAI,IAAI,CAAC,MAAM,GAAG,I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,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;IAC5B,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;IAC/B,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE;CACzD,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Linking, StyleSheet } from 'react-native'\nimport { Text } from '../display'\nimport { parseSimpleMarkdown } from '../../utils/parse_simple_markdown'\n\ninterface Props {\n text: string\n}\n\nexport function MessageMarkdown({ text }: Props) {\n if (!text) return null\n\n // Skip markdown for excessively long messages for performance reasons\n if (text.length > 5000) return <Text>{text}</Text>\n\n const parsed = parseSimpleMarkdown(text)\n\n return (\n <Text>\n {parsed.map((part, i) => {\n switch (part.type) {\n case 'bold':\n return (\n <Text key={i} style={styles.bold}>\n {part.content}\n </Text>\n )\n case 'italic':\n return (\n <Text key={i} style={styles.italic}>\n {part.content}\n </Text>\n )\n case 'link':\n return (\n <Text key={i} style={styles.link} onPress={() => Linking.openURL(part.content)}>\n {part.content}\n </Text>\n )\n default:\n return <Text key={i}>{part.content}</Text>\n }\n })}\n </Text>\n )\n}\n\nconst styles = StyleSheet.create({\n bold: { fontWeight: 'bold' },\n italic: { fontStyle: 'italic' },\n link: { color: 'blue', textDecorationLine: 'underline' },\n})\n"]}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { ConversationResource } from '../../types';
3
+ interface ConversationPreviewProps {
4
+ conversation: ConversationResource;
5
+ onPress: () => void;
6
+ }
7
+ export declare const ConversationPreview: ({ conversation, onPress }: ConversationPreviewProps) => React.JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=conversation_preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation_preview.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversation_preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMlD,UAAU,wBAAwB;IAChC,YAAY,EAAE,oBAAoB,CAAA;IAClC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,eAAO,MAAM,mBAAmB,8BAA+B,wBAAwB,sBAuCtF,CAAA"}
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import { Pressable, StyleSheet, View } from 'react-native';
3
+ import { AvatarGroup, Heading, Text, Badge } from '../display';
4
+ import { formatDatePreview } from '../../utils/date';
5
+ import { useTheme } from '../../hooks';
6
+ import { UnreadCountBadge } from './unread_count_badge';
7
+ export const ConversationPreview = ({ conversation, onPress }) => {
8
+ const styles = useStyles();
9
+ const { lastMessageAuthorName, lastMessageCreatedAt, lastMessageTextPreview, previewAvatarUrls, title, unreadCount, badges, } = conversation;
10
+ return (<Pressable style={styles.previewRow} onPress={onPress}>
11
+ <AvatarGroup size="lg" sourceUris={previewAvatarUrls || []}/>
12
+ <View style={styles.conversationBody}>
13
+ <Heading numberOfLines={1} variant="h3" style={styles.title}>
14
+ {title}
15
+ </Heading>
16
+ <Text variant="tertiary" numberOfLines={2}>
17
+ {lastMessageAuthorName}: {lastMessageTextPreview}
18
+ </Text>
19
+ <View style={styles.badges}>
20
+ {badges?.map(badge => (<Badge key={badge.text} variant="meta" productLogoName={badge.appName} label={badge.pcoResourceType} metaLabel={badge.text || ''}/>))}
21
+ </View>
22
+ </View>
23
+ <View style={styles.metaContainer}>
24
+ <Text variant="tertiary">{formatDatePreview(lastMessageCreatedAt)}</Text>
25
+ <UnreadCountBadge count={unreadCount}/>
26
+ </View>
27
+ </Pressable>);
28
+ };
29
+ const useStyles = () => {
30
+ const { colors } = useTheme();
31
+ return StyleSheet.create({
32
+ previewRow: {
33
+ flexDirection: 'row',
34
+ gap: 8,
35
+ borderBottomWidth: 1,
36
+ borderBottomColor: colors.borderColorDefaultDim,
37
+ paddingTop: 12,
38
+ paddingBottom: 12,
39
+ paddingHorizontal: 16,
40
+ },
41
+ title: {
42
+ fontSize: 16,
43
+ color: colors.textColorDefaultPrimary,
44
+ },
45
+ conversationBody: {
46
+ flex: 1,
47
+ rowGap: 2,
48
+ },
49
+ metaContainer: {
50
+ rowGap: 4,
51
+ },
52
+ badges: {
53
+ marginTop: 4,
54
+ alignItems: 'flex-start',
55
+ },
56
+ });
57
+ };
58
+ //# sourceMappingURL=conversation_preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation_preview.js","sourceRoot":"","sources":["../../../src/components/conversations/conversation_preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAOvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,EAA4B,EAAE,EAAE;IACzF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EACJ,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,MAAM,GACP,GAAG,YAAY,CAAA;IAChB,OAAO,CACL,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CACpD;MAAA,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,iBAAiB,IAAI,EAAE,CAAC,EAC3D;MAAA,CAAC,IAAI,CAAC,KAAK,CAAC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AA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,UAAU,EAAE;YACV,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,qBAAqB;YAC/C,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,EAAE;SACtB;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;SACV;QACD,aAAa,EAAE;YACb,MAAM,EAAE,CAAC;SACV;QACD,MAAM,EAAE;YACN,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,YAAY;SACzB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport { ConversationResource } from '../../types'\nimport { AvatarGroup, Heading, Text, Badge } from '../display'\nimport { formatDatePreview } from '../../utils/date'\nimport { useTheme } from '../../hooks'\nimport { UnreadCountBadge } from './unread_count_badge'\n\ninterface ConversationPreviewProps {\n conversation: ConversationResource\n onPress: () => void\n}\n\nexport const ConversationPreview = ({ conversation, onPress }: ConversationPreviewProps) => {\n const styles = useStyles()\n const {\n lastMessageAuthorName,\n lastMessageCreatedAt,\n lastMessageTextPreview,\n previewAvatarUrls,\n title,\n unreadCount,\n badges,\n } = conversation\n return (\n <Pressable style={styles.previewRow} onPress={onPress}>\n <AvatarGroup size=\"lg\" sourceUris={previewAvatarUrls || []} />\n <View style={styles.conversationBody}>\n <Heading numberOfLines={1} variant=\"h3\" style={styles.title}>\n {title}\n </Heading>\n <Text variant=\"tertiary\" numberOfLines={2}>\n {lastMessageAuthorName}: {lastMessageTextPreview}\n </Text>\n <View style={styles.badges}>\n {badges?.map(badge => (\n <Badge\n key={badge.text}\n variant=\"meta\"\n productLogoName={badge.appName}\n label={badge.pcoResourceType}\n metaLabel={badge.text || ''}\n />\n ))}\n </View>\n </View>\n <View style={styles.metaContainer}>\n <Text variant=\"tertiary\">{formatDatePreview(lastMessageCreatedAt)}</Text>\n <UnreadCountBadge count={unreadCount} />\n </View>\n </Pressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n previewRow: {\n flexDirection: 'row',\n gap: 8,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultDim,\n paddingTop: 12,\n paddingBottom: 12,\n paddingHorizontal: 16,\n },\n title: {\n fontSize: 16,\n color: colors.textColorDefaultPrimary,\n },\n conversationBody: {\n flex: 1,\n rowGap: 2,\n },\n metaContainer: {\n rowGap: 4,\n },\n badges: {\n marginTop: 4,\n alignItems: 'flex-start',\n },\n })\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ConversationRequestArgs } from '../../utils/request/conversation';
3
+ interface ConversationsProps extends Partial<ConversationRequestArgs> {
4
+ ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined;
5
+ }
6
+ export declare const Conversations: ({ ListHeaderComponent, filter, group, gids, group_source_app_name, }: ConversationsProps) => React.JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAG1E,UAAU,kBAAmB,SAAQ,OAAO,CAAC,uBAAuB,CAAC;IACnE,mBAAmB,CAAC,EAChB,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GACxB,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAClE,IAAI,GACJ,SAAS,CAAA;CACd;AAED,eAAO,MAAM,aAAa,yEAMvB,kBAAkB,sBAqCpB,CAAA"}
@@ -0,0 +1,40 @@
1
+ import { useNavigation } from '@react-navigation/native';
2
+ import { FlashList } from '@shopify/flash-list';
3
+ import React from 'react';
4
+ import { StyleSheet, View } from 'react-native';
5
+ import { useTheme } from '../../hooks';
6
+ import { useConversationsJoltEvents } from '../../hooks/use_conversation_jolt_events';
7
+ import { useConversations } from '../../hooks/use_conversations';
8
+ import { Text } from '../display';
9
+ import { ConversationPreview } from './conversation_preview';
10
+ export const Conversations = ({ ListHeaderComponent, filter, group, gids, group_source_app_name, }) => {
11
+ const styles = useStyles();
12
+ const { conversations, fetchNextPage, refetch, isRefetching, isFetched } = useConversations({
13
+ filter,
14
+ group,
15
+ gids,
16
+ group_source_app_name,
17
+ });
18
+ const navigation = useNavigation();
19
+ useConversationsJoltEvents();
20
+ return (<View style={styles.container}>
21
+ <FlashList data={conversations} estimatedItemSize={97} contentContainerStyle={styles.contentContainer} onRefresh={refetch} refreshing={!isFetched && isRefetching} ListHeaderComponent={ListHeaderComponent} ListEmptyComponent={<View style={styles.listEmpty}>
22
+ <Text variant="secondary">No conversations found</Text>
23
+ </View>} renderItem={({ item }) => (<ConversationPreview conversation={item} onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}/>)} onEndReached={() => fetchNextPage()}/>
24
+ </View>);
25
+ };
26
+ const useStyles = () => {
27
+ const { colors } = useTheme();
28
+ return StyleSheet.create({
29
+ container: { flex: 1 },
30
+ contentContainer: { paddingVertical: 16 },
31
+ listItem: { color: colors.fillColorNeutral020 },
32
+ listEmpty: {
33
+ flex: 1,
34
+ justifyContent: 'center',
35
+ alignItems: 'center',
36
+ paddingVertical: 16,
37
+ },
38
+ });
39
+ };
40
+ //# sourceMappingURL=conversations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../../src/components/conversations/con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AmB,CAAC,CACzC,kBAAkB,CAAC,CACjB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAC5B;YAAA,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,sBAAsB,EAAE,IAAI,CACxD;UAAA,EAAE,IAAI,CACR,CAAC,CACD,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CACxB,CAAC,mBAAmB,CAClB,YAAY,CAAC,CAAC,IAAI,CAAC,CACnB,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EACjF,CACH,CAAC,CACF,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,EAExC;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;QACtB,gBAAgB,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;QACzC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,mBAAmB,EAAE;QAC/C,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;SACpB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport { FlashList } from '@shopify/flash-list'\nimport React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { useTheme } from '../../hooks'\nimport { useConversationsJoltEvents } from '../../hooks/use_conversation_jolt_events'\nimport { useConversations } from '../../hooks/use_conversations'\nimport { Text } from '../display'\nimport { ConversationRequestArgs } from '../../utils/request/conversation'\nimport { ConversationPreview } from './conversation_preview'\n\ninterface ConversationsProps extends Partial<ConversationRequestArgs> {\n ListHeaderComponent?:\n | React.ComponentType<any>\n | React.ReactElement<any, string | React.JSXElementConstructor<any>>\n | null\n | undefined\n}\n\nexport const Conversations = ({\n ListHeaderComponent,\n filter,\n group,\n gids,\n group_source_app_name,\n}: ConversationsProps) => {\n const styles = useStyles()\n\n const { conversations, fetchNextPage, refetch, isRefetching, isFetched } = useConversations({\n filter,\n group,\n gids,\n group_source_app_name,\n })\n const navigation = useNavigation()\n\n useConversationsJoltEvents()\n\n return (\n <View style={styles.container}>\n <FlashList\n data={conversations}\n estimatedItemSize={97}\n contentContainerStyle={styles.contentContainer}\n onRefresh={refetch}\n refreshing={!isFetched && isRefetching}\n ListHeaderComponent={ListHeaderComponent}\n ListEmptyComponent={\n <View style={styles.listEmpty}>\n <Text variant=\"secondary\">No conversations found</Text>\n </View>\n }\n renderItem={({ item }) => (\n <ConversationPreview\n conversation={item}\n onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}\n />\n )}\n onEndReached={() => fetchNextPage()}\n />\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: { flex: 1 },\n contentContainer: { paddingVertical: 16 },\n listItem: { color: colors.fillColorNeutral020 },\n listEmpty: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n paddingVertical: 16,\n },\n })\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const UnreadCountBadge: ({ count }: {
3
+ count: number;
4
+ }) => React.JSX.Element | null;
5
+ //# sourceMappingURL=unread_count_badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unread_count_badge.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/unread_count_badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,eAAO,MAAM,gBAAgB,cAAe;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,6BAa5D,CAAA"}
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import { Text } from '../display';
4
+ import { useTheme } from '../../hooks';
5
+ import { platformFontWeightBold } from '../../utils';
6
+ export const UnreadCountBadge = ({ count }) => {
7
+ const styles = useStyles();
8
+ const displayCount = count > 99 ? '99+' : count;
9
+ if (count === 0)
10
+ return null;
11
+ return (<View style={styles.badge}>
12
+ <Text variant="footnote" style={styles.count}>
13
+ {displayCount}
14
+ </Text>
15
+ </View>);
16
+ };
17
+ const useStyles = () => {
18
+ const { colors } = useTheme();
19
+ return StyleSheet.create({
20
+ badge: {
21
+ alignSelf: 'flex-end',
22
+ backgroundColor: colors.fillColorInteractionDefault,
23
+ paddingVertical: 2,
24
+ paddingHorizontal: 8,
25
+ borderRadius: 24,
26
+ },
27
+ count: {
28
+ fontWeight: platformFontWeightBold,
29
+ color: 'white',
30
+ },
31
+ });
32
+ };
33
+ //# sourceMappingURL=unread_count_badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unread_count_badge.js","sourceRoot":"","sources":["../../../src/components/conversations/unread_count_badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IAC/D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,YAAY,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;IAE/C,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE5B,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACxB;MAAA,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3C;QAAA,CAAC,YAAY,CACf;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE;YACL,SAAS,EAAE,UAAU;YACrB,eAAe,EAAE,MAAM,CAAC,2BAA2B;YACnD,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;YACpB,YAAY,EAAE,EAAE;SACjB;QACD,KAAK,EAAE;YACL,UAAU,EAAE,sBAAsB;YAClC,KAAK,EAAE,OAAO;SACf;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { Text } from '../display'\nimport { useTheme } from '../../hooks'\nimport { platformFontWeightBold } from '../../utils'\n\nexport const UnreadCountBadge = ({ count }: { count: number }) => {\n const styles = useStyles()\n const displayCount = count > 99 ? '99+' : count\n\n if (count === 0) return null\n\n return (\n <View style={styles.badge}>\n <Text variant=\"footnote\" style={styles.count}>\n {displayCount}\n </Text>\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n badge: {\n alignSelf: 'flex-end',\n backgroundColor: colors.fillColorInteractionDefault,\n paddingVertical: 2,\n paddingHorizontal: 8,\n borderRadius: 24,\n },\n count: {\n fontWeight: platformFontWeightBold,\n color: 'white',\n },\n })\n}\n"]}
@@ -33,6 +33,10 @@ interface BadgeProps {
33
33
  * Shows an icon of the user choice to the left of the text.
34
34
  */
35
35
  iconName?: string;
36
+ /**
37
+ * Shows an icon of the user choice to the right of the text.
38
+ */
39
+ iconNameRight?: string;
36
40
  /**
37
41
  * Styles badge wrapper.
38
42
  */
@@ -41,7 +45,11 @@ interface BadgeProps {
41
45
  * Specifies the maximum size a font can reach when allowFontScaling is enabled.
42
46
  */
43
47
  maxFontSizeMultiplier?: number;
48
+ /**
49
+ * Callback function when the badge is pressed.
50
+ */
51
+ onPress?: () => void;
44
52
  }
45
- export declare function Badge({ appearance, metaLabel, style, iconName, label, productLogoName, variant, maxFontSizeMultiplier, }: BadgeProps): React.JSX.Element;
53
+ export declare function Badge({ appearance, metaLabel, style, iconName, iconNameRight, label, productLogoName, variant, maxFontSizeMultiplier, onPress, }: BadgeProps): React.JSX.Element;
46
54
  export {};
47
55
  //# sourceMappingURL=badge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/components/display/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,cAAc,CAAA;AAOxD,OAAO,EAA+B,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAM/F,QAAA,MAAM,QAAQ;;;;CAIJ,CAAA;AAEV,KAAK,YAAY,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAA;AAiB5D,KAAK,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAA;AAWpE,UAAU,UAAU;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,YA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,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,wBAAgB,KAAK,CAAC,EACpB,UAAsB,EACtB,SAAS,EACT,KAAK,EACL,QAAQ,EACR,aAAa,EACb,KAAK,EACL,eAAe,EACf,OAAmB,EACnB,qBAAqB,EACrB,OAAO,GACR,EAAE,UAAU,qBA4BZ"}
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import { StyleSheet, View } from 'react-native';
3
- import Svg, { Path, Defs, LinearGradient, Stop } from 'react-native-svg';
2
+ import { Pressable, StyleSheet, View } from 'react-native';
3
+ import Svg, { Defs, LinearGradient, Path, Stop } from 'react-native-svg';
4
4
  import { useFontScale, useTheme } from '../../hooks';
5
- import { Icon } from './icon';
6
- import { Text } from './text';
7
5
  import { platformFontWeightMedium, space } from '../../utils';
8
6
  import { tokens } from '../../vendor/tapestry/tokens';
7
+ import { Icon } from './icon';
8
+ import { Text } from './text';
9
9
  import { useStatusColorAppearanceMap } from './utils/status_colors';
10
10
  // =================================
11
11
  // ====== Constants ================
@@ -19,28 +19,36 @@ const PRODUCT_LOGO_COMPONENT_MAP = {
19
19
  groups: GroupsLogo,
20
20
  services: ServicesIcon,
21
21
  };
22
- export function Badge({ appearance = 'neutral', metaLabel, style, iconName, label, productLogoName, variant = 'default', maxFontSizeMultiplier, }) {
22
+ export function Badge({ appearance = 'neutral', metaLabel, style, iconName, iconNameRight, label, productLogoName, variant = 'default', maxFontSizeMultiplier, onPress, }) {
23
23
  const styles = useStyles({ appearance, maxFontSizeMultiplier, variant });
24
- const { showBadgeLogo } = useTheme();
24
+ const { showBadgeProductLogo } = useTheme();
25
25
  const isMetaSubtle = variant === 'metaSubtle';
26
- const isMeta = variant === 'meta';
27
26
  const hasMetaLabel = Boolean(metaLabel);
28
- const showLogo = showBadgeLogo && productLogoName && isMeta;
27
+ const showLogo = showBadgeProductLogo && productLogoName;
29
28
  const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName?.toLowerCase()];
30
29
  const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label;
31
- return (<View style={[styles.badgeWrapper, style]}>
30
+ return (<BadgeWrapper style={[styles.badgeWrapper, style]} onPress={onPress} accessibilityRole="button">
32
31
  <View style={styles.badge}>
33
32
  {showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize}/>}
34
33
  {iconName && <Icon name={iconName} style={styles.icon}/>}
35
34
  <Text variant="footnote" style={styles.label}>
36
35
  {badgeLabel}
37
36
  </Text>
37
+ {iconNameRight && <Icon name={iconNameRight} style={styles.iconRight}/>}
38
38
  </View>
39
39
  {hasMetaLabel && (<Text variant="footnote" style={styles.metaLabel} numberOfLines={1}>
40
40
  {metaLabel}
41
41
  </Text>)}
42
- </View>);
42
+ </BadgeWrapper>);
43
43
  }
44
+ const BadgeWrapper = ({ children, onPress, accessibilityRole, ...restProps }) => {
45
+ if (onPress) {
46
+ return (<Pressable accessibilityRole={accessibilityRole} onPress={onPress} {...restProps}>
47
+ {children}
48
+ </Pressable>);
49
+ }
50
+ return <View {...restProps}>{children}</View>;
51
+ };
44
52
  // =================================
45
53
  // ====== Styles ===================
46
54
  // =================================
@@ -110,6 +118,10 @@ const useStyles = ({ appearance = 'neutral', maxFontSizeMultiplier, variant = 'd
110
118
  color: statusColorMap[appearance].icon,
111
119
  fontSize: badgeFontSize,
112
120
  },
121
+ iconRight: {
122
+ color: statusColorMap[appearance].icon,
123
+ fontSize: badgeFontSize - 2,
124
+ },
113
125
  logo: {
114
126
  fontSize: badgeFontSize * fontScale,
115
127
  },
@@ -1 +1 @@
1
- {"version":3,"file":"badge.js","sourceRoot":"","sources":["../../../src/components/display/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,GAAG,EAAE,EAAE,IAA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B,CACznB,IAAI,CAAC,gCAAgC,EAEvC;MAAA,CAAC,IAAI,CACH;QAAA,CAAC,cAAc,CACb,EAAE,CAAC,0BAA0B,CAC7B,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CACb,EAAE,CAAC,CAAC,MAAM,CAAC,CACX,EAAE,CAAC,CAAC,OAAO,CAAC,CACZ,EAAE,CAAC,CAAC,OAAO,CAAC,CACZ,aAAa,CAAC,gBAAgB,CAE9B;UAAA,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EACzB;UAAA,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EACtC;QAAA,EAAE,cAAc,CAClB;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport type { ViewStyle, TextStyle } from 'react-native'\nimport Svg, { Path, Defs, LinearGradient, Stop } from 'react-native-svg'\nimport { useFontScale, useTheme } from '../../hooks'\nimport { Icon } from './icon'\nimport { Text } from './text'\nimport { platformFontWeightMedium, space } from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { useStatusColorAppearanceMap, type StatusAppearanceUnion } from './utils/status_colors'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst VARIANTS = {\n default: 'default',\n meta: 'meta',\n metaSubtle: 'metaSubtle',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\n\ntype VariantStyles = Record<\n VariantUnion,\n {\n backgroundColor: string\n paddingHorizontal: number\n paddingVertical: number\n borderWidth: number\n borderRadius: number\n textColor: string\n gap: number\n metaLabelPaddingLeft: number\n fontWeight: TextStyle['fontWeight']\n }\n>\n\ntype ProductLogoName = 'Groups' | 'Services' | 'groups' | 'services'\n\nconst PRODUCT_LOGO_COMPONENT_MAP = {\n groups: GroupsLogo,\n services: ServicesIcon,\n} as const\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface BadgeProps {\n /**\n * Renders the main text.\n */\n label: string\n /**\n * Renders secondary meta text to the right of the label.\n */\n metaLabel?: string\n /**\n * Changes the status color for the badge and icon.\n */\n appearance?: StatusAppearanceUnion\n /**\n * Changes form of the logo to support a meta label and badge\n */\n variant?: VariantUnion\n /**\n * Adds a product logo to the left of the text.\n */\n productLogoName?: ProductLogoName\n /**\n * Shows an icon of the user choice to the left of the text.\n */\n iconName?: string\n /**\n * Styles badge wrapper.\n */\n style?: ViewStyle\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n}\n\nexport function Badge({\n appearance = 'neutral',\n metaLabel,\n style,\n iconName,\n label,\n productLogoName,\n variant = 'default',\n maxFontSizeMultiplier,\n}: BadgeProps) {\n const styles = useStyles({ appearance, maxFontSizeMultiplier, variant })\n const { showBadgeLogo } = useTheme()\n\n const isMetaSubtle = variant === 'metaSubtle'\n const isMeta = variant === 'meta'\n const hasMetaLabel = Boolean(metaLabel)\n\n const showLogo = showBadgeLogo && productLogoName && isMeta\n const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName?.toLowerCase()]\n const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label\n\n return (\n <View style={[styles.badgeWrapper, style]}>\n <View style={styles.badge}>\n {showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize} />}\n {iconName && <Icon name={iconName} style={styles.icon} />}\n <Text variant=\"footnote\" style={styles.label}>\n {badgeLabel}\n </Text>\n </View>\n {hasMetaLabel && (\n <Text variant=\"footnote\" style={styles.metaLabel} numberOfLines={1}>\n {metaLabel}\n </Text>\n )}\n </View>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'neutral',\n maxFontSizeMultiplier,\n variant = 'default',\n}: Partial<BadgeProps>) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n const statusColorMap = useStatusColorAppearanceMap()\n\n const badgePaddingHorizontal = space(1) * fontScale\n const badgePaddingVertical = space(0.5) * fontScale\n const badgeGap = space(0.5) * fontScale\n const badgeFontSize = 12\n\n const variantStylesMap: VariantStyles = {\n default: {\n gap: badgeGap,\n backgroundColor: statusColorMap[appearance].background,\n metaLabelPaddingLeft: badgePaddingHorizontal,\n paddingHorizontal: badgePaddingHorizontal,\n paddingVertical: badgePaddingVertical,\n borderWidth: tokens.borderSizeDefault * fontScale,\n borderRadius: tokens.borderRadiusMd,\n textColor: statusColorMap[appearance].text,\n fontWeight: 'normal',\n },\n meta: {\n gap: badgeGap,\n backgroundColor: statusColorMap[appearance].background,\n metaLabelPaddingLeft: badgePaddingHorizontal,\n paddingHorizontal: badgePaddingHorizontal,\n paddingVertical: badgePaddingVertical,\n borderWidth: tokens.borderSizeDefault * fontScale,\n borderRadius: tokens.borderRadiusMd,\n textColor: statusColorMap[appearance].text,\n fontWeight: platformFontWeightMedium,\n },\n metaSubtle: {\n gap: badgeGap,\n backgroundColor: 'transparent',\n metaLabelPaddingLeft: badgeGap,\n paddingHorizontal: 0,\n paddingVertical: 0,\n borderWidth: 0,\n borderRadius: 0,\n textColor: colors.textColorDefaultSecondary,\n fontWeight: platformFontWeightMedium,\n },\n }\n\n return StyleSheet.create({\n badgeWrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n alignSelf: 'flex-start',\n borderRadius: variantStylesMap[variant].borderRadius,\n borderWidth: variantStylesMap[variant].borderWidth,\n borderColor: statusColorMap[appearance].background,\n },\n badge: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: variantStylesMap[variant].gap,\n paddingVertical: variantStylesMap[variant].paddingVertical,\n paddingHorizontal: variantStylesMap[variant].paddingHorizontal,\n backgroundColor: variantStylesMap[variant].backgroundColor,\n borderRadius: variantStylesMap[variant].borderRadius - 2,\n },\n icon: {\n color: statusColorMap[appearance].icon,\n fontSize: badgeFontSize,\n },\n logo: {\n fontSize: badgeFontSize * fontScale,\n },\n label: {\n color: variantStylesMap[variant].textColor,\n fontWeight: variantStylesMap[variant].fontWeight,\n fontSize: badgeFontSize,\n lineHeight: 15 * fontScale,\n },\n metaLabel: {\n paddingHorizontal: variantStylesMap[variant].paddingHorizontal,\n fontSize: badgeFontSize,\n flexShrink: 1,\n paddingLeft: variantStylesMap[variant].metaLabelPaddingLeft,\n lineHeight: 15 * fontScale,\n },\n })\n}\n\n// =================================\n// ====== Product Logos ============\n// =================================\n\ninterface ProductLogoProps {\n logoSize: number\n}\n\nfunction GroupsLogo({ logoSize }: ProductLogoProps) {\n return (\n <Svg width={logoSize} height={logoSize} viewBox=\"0 0 16 16\" fill=\"none\">\n <Path\n d=\"M9.06 6.14H6.94c-.152.36-.438.646-.797.798v2.12c.359.152.645.438.797.797h2.117c.152-.359.437-.645.796-.797V6.94a1.502 1.502 0 01-.793-.8zM8 0C1.6 0 0 1.595 0 8s1.6 8 8 8 8-1.595 8-8-1.595-8-8-8zm3.939 10.44a1.5 1.5 0 01-2.882.585H6.94a1.5 1.5 0 11-1.963-1.963v-2.12A1.501 1.501 0 116.94 4.98h2.12a1.5 1.5 0 111.963 1.968v2.11a1.501 1.501 0 01.916 1.383z\"\n fill=\"url(#paint0_linear_2632_26363)\"\n />\n <Defs>\n <LinearGradient\n id=\"paint0_linear_2632_26363\"\n x1={-5.6338}\n y1={5.6338}\n x2={5.6338}\n y2={16.9014}\n gradientUnits=\"userSpaceOnUse\"\n >\n <Stop stopColor=\"#FF962D\" />\n <Stop offset={1} stopColor=\"#FC7638\" />\n </LinearGradient>\n </Defs>\n </Svg>\n )\n}\n\nfunction ServicesIcon({ logoSize }: ProductLogoProps) {\n return (\n <Svg width={logoSize} height={logoSize} viewBox=\"0 0 16 16\" fill=\"none\">\n <Path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M.116 8c0-6.4 1.6-8 8-8s8 1.6 8 8-1.6 8-8 8-8-1.6-8-8zm4.123 3.464a.848.848 0 10.943-1.41.848.848 0 00-.943 1.41zm.001-2.76a.848.848 0 10.948-1.408.848.848 0 00-.948 1.407zm0-2.759a.849.849 0 10.948-1.408.849.849 0 00-.948 1.408zm8.1 5.34a.388.388 0 00.03-.149v-.755a.39.39 0 00-.39-.39H6.87a.39.39 0 00-.39.39v.755a.39.39 0 00.39.39h5.11a.39.39 0 00.36-.24zm0-2.758a.388.388 0 00.03-.149v-.757a.387.387 0 00-.39-.388H6.87a.388.388 0 00-.39.388v.757a.388.388 0 00.39.388h5.11a.388.388 0 00.36-.24zm0-2.76a.388.388 0 00.03-.148v-.754a.39.39 0 00-.39-.389H6.87a.39.39 0 00-.39.387v.756a.39.39 0 00.39.39h5.11a.389.389 0 00.36-.241z\"\n fill=\"url(#paint0_linear_2632_56586)\"\n />\n <Defs>\n <LinearGradient\n id=\"paint0_linear_2632_56586\"\n x1={-5.51759}\n y1={5.6338}\n x2={5.75001}\n y2={16.9014}\n gradientUnits=\"userSpaceOnUse\"\n >\n <Stop stopColor=\"#6BB23D\" />\n <Stop offset={1} stopColor=\"#659630\" />\n </LinearGradient>\n </Defs>\n </Svg>\n )\n}\n"]}
1
+ {"version":3,"file":"badge.js","sourceRoot":"","sources":["../../../src/components/display/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,wBAAwB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAA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AAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EACtC;QAAA,EAAE,cAAc,CAClB;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,QAAQ,EAAoB;IAClD,OAAO,CACL,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CACrE;MAAA,CAAC,IAAI,CACH,QAAQ,CAAC,SAAS,CAClB,QAAQ,CAAC,SAAS,CAClB,CAAC,CAAC,unBAAunB,CACznB,IAAI,CAAC,gCAAgC,EAEvC;MAAA,CAAC,IAAI,CACH;QAAA,CAAC,cAAc,CACb,EAAE,CAAC,0BAA0B,CAC7B,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CACb,EAAE,CAAC,CAAC,MAAM,CAAC,CACX,EAAE,CAAC,CAAC,OAAO,CAAC,CACZ,EAAE,CAAC,CAAC,OAAO,CAAC,CACZ,aAAa,CAAC,gBAAgB,CAE9B;UAAA,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EACzB;UAAA,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EACtC;QAAA,EAAE,cAAc,CAClB;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC","sourcesContent":["import React from 'react'\nimport type { TextStyle, ViewProps, ViewStyle } from 'react-native'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport Svg, { Defs, LinearGradient, Path, Stop } from 'react-native-svg'\nimport { useFontScale, useTheme } from '../../hooks'\nimport { platformFontWeightMedium, space } from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Icon } from './icon'\nimport { Text } from './text'\nimport { useStatusColorAppearanceMap, type StatusAppearanceUnion } from './utils/status_colors'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst VARIANTS = {\n default: 'default',\n meta: 'meta',\n metaSubtle: 'metaSubtle',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\n\ntype VariantStyles = Record<\n VariantUnion,\n {\n backgroundColor: string\n paddingHorizontal: number\n paddingVertical: number\n borderWidth: number\n borderRadius: number\n textColor: string\n gap: number\n metaLabelPaddingLeft: number\n fontWeight: TextStyle['fontWeight']\n }\n>\n\ntype ProductLogoName = 'Groups' | 'Services' | 'groups' | 'services'\n\nconst PRODUCT_LOGO_COMPONENT_MAP = {\n groups: GroupsLogo,\n services: ServicesIcon,\n} as const\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface BadgeProps {\n /**\n * Renders the main text.\n */\n label: string\n /**\n * Renders secondary meta text to the right of the label.\n */\n metaLabel?: string\n /**\n * Changes the status color for the badge and icon.\n */\n appearance?: StatusAppearanceUnion\n /**\n * Changes form of the logo to support a meta label and badge\n */\n variant?: VariantUnion\n /**\n * Adds a product logo to the left of the text.\n */\n productLogoName?: ProductLogoName\n /**\n * Shows an icon of the user choice to the left of the text.\n */\n iconName?: string\n /**\n * Shows an icon of the user choice to the right of the text.\n */\n iconNameRight?: string\n /**\n * Styles badge wrapper.\n */\n style?: ViewStyle\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Callback function when the badge is pressed.\n */\n onPress?: () => void\n}\n\nexport function Badge({\n appearance = 'neutral',\n metaLabel,\n style,\n iconName,\n iconNameRight,\n label,\n productLogoName,\n variant = 'default',\n maxFontSizeMultiplier,\n onPress,\n}: BadgeProps) {\n const styles = useStyles({ appearance, maxFontSizeMultiplier, variant })\n const { showBadgeProductLogo } = useTheme()\n\n const isMetaSubtle = variant === 'metaSubtle'\n const hasMetaLabel = Boolean(metaLabel)\n\n const showLogo = showBadgeProductLogo && productLogoName\n const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName?.toLowerCase()]\n const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label\n\n return (\n <BadgeWrapper style={[styles.badgeWrapper, style]} onPress={onPress} accessibilityRole=\"button\">\n <View style={styles.badge}>\n {showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize} />}\n {iconName && <Icon name={iconName} style={styles.icon} />}\n <Text variant=\"footnote\" style={styles.label}>\n {badgeLabel}\n </Text>\n {iconNameRight && <Icon name={iconNameRight} style={styles.iconRight} />}\n </View>\n {hasMetaLabel && (\n <Text variant=\"footnote\" style={styles.metaLabel} numberOfLines={1}>\n {metaLabel}\n </Text>\n )}\n </BadgeWrapper>\n )\n}\n\nconst BadgeWrapper = ({\n children,\n onPress,\n accessibilityRole,\n ...restProps\n}: ViewProps & Pick<BadgeProps, 'onPress'>) => {\n if (onPress) {\n return (\n <Pressable accessibilityRole={accessibilityRole} onPress={onPress} {...restProps}>\n {children}\n </Pressable>\n )\n }\n\n return <View {...restProps}>{children}</View>\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'neutral',\n maxFontSizeMultiplier,\n variant = 'default',\n}: Partial<BadgeProps>) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n const statusColorMap = useStatusColorAppearanceMap()\n\n const badgePaddingHorizontal = space(1) * fontScale\n const badgePaddingVertical = space(0.5) * fontScale\n const badgeGap = space(0.5) * fontScale\n const badgeFontSize = 12\n\n const variantStylesMap: VariantStyles = {\n default: {\n gap: badgeGap,\n backgroundColor: statusColorMap[appearance].background,\n metaLabelPaddingLeft: badgePaddingHorizontal,\n paddingHorizontal: badgePaddingHorizontal,\n paddingVertical: badgePaddingVertical,\n borderWidth: tokens.borderSizeDefault * fontScale,\n borderRadius: tokens.borderRadiusMd,\n textColor: statusColorMap[appearance].text,\n fontWeight: 'normal',\n },\n meta: {\n gap: badgeGap,\n backgroundColor: statusColorMap[appearance].background,\n metaLabelPaddingLeft: badgePaddingHorizontal,\n paddingHorizontal: badgePaddingHorizontal,\n paddingVertical: badgePaddingVertical,\n borderWidth: tokens.borderSizeDefault * fontScale,\n borderRadius: tokens.borderRadiusMd,\n textColor: statusColorMap[appearance].text,\n fontWeight: platformFontWeightMedium,\n },\n metaSubtle: {\n gap: badgeGap,\n backgroundColor: 'transparent',\n metaLabelPaddingLeft: badgeGap,\n paddingHorizontal: 0,\n paddingVertical: 0,\n borderWidth: 0,\n borderRadius: 0,\n textColor: colors.textColorDefaultSecondary,\n fontWeight: platformFontWeightMedium,\n },\n }\n\n return StyleSheet.create({\n badgeWrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n alignSelf: 'flex-start',\n borderRadius: variantStylesMap[variant].borderRadius,\n borderWidth: variantStylesMap[variant].borderWidth,\n borderColor: statusColorMap[appearance].background,\n },\n badge: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: variantStylesMap[variant].gap,\n paddingVertical: variantStylesMap[variant].paddingVertical,\n paddingHorizontal: variantStylesMap[variant].paddingHorizontal,\n backgroundColor: variantStylesMap[variant].backgroundColor,\n borderRadius: variantStylesMap[variant].borderRadius - 2,\n },\n icon: {\n color: statusColorMap[appearance].icon,\n fontSize: badgeFontSize,\n },\n iconRight: {\n color: statusColorMap[appearance].icon,\n fontSize: badgeFontSize - 2,\n },\n logo: {\n fontSize: badgeFontSize * fontScale,\n },\n label: {\n color: variantStylesMap[variant].textColor,\n fontWeight: variantStylesMap[variant].fontWeight,\n fontSize: badgeFontSize,\n lineHeight: 15 * fontScale,\n },\n metaLabel: {\n paddingHorizontal: variantStylesMap[variant].paddingHorizontal,\n fontSize: badgeFontSize,\n flexShrink: 1,\n paddingLeft: variantStylesMap[variant].metaLabelPaddingLeft,\n lineHeight: 15 * fontScale,\n },\n })\n}\n\n// =================================\n// ====== Product Logos ============\n// =================================\n\ninterface ProductLogoProps {\n logoSize: number\n}\n\nfunction GroupsLogo({ logoSize }: ProductLogoProps) {\n return (\n <Svg width={logoSize} height={logoSize} viewBox=\"0 0 16 16\" fill=\"none\">\n <Path\n d=\"M9.06 6.14H6.94c-.152.36-.438.646-.797.798v2.12c.359.152.645.438.797.797h2.117c.152-.359.437-.645.796-.797V6.94a1.502 1.502 0 01-.793-.8zM8 0C1.6 0 0 1.595 0 8s1.6 8 8 8 8-1.595 8-8-1.595-8-8-8zm3.939 10.44a1.5 1.5 0 01-2.882.585H6.94a1.5 1.5 0 11-1.963-1.963v-2.12A1.501 1.501 0 116.94 4.98h2.12a1.5 1.5 0 111.963 1.968v2.11a1.501 1.501 0 01.916 1.383z\"\n fill=\"url(#paint0_linear_2632_26363)\"\n />\n <Defs>\n <LinearGradient\n id=\"paint0_linear_2632_26363\"\n x1={-5.6338}\n y1={5.6338}\n x2={5.6338}\n y2={16.9014}\n gradientUnits=\"userSpaceOnUse\"\n >\n <Stop stopColor=\"#FF962D\" />\n <Stop offset={1} stopColor=\"#FC7638\" />\n </LinearGradient>\n </Defs>\n </Svg>\n )\n}\n\nfunction ServicesIcon({ logoSize }: ProductLogoProps) {\n return (\n <Svg width={logoSize} height={logoSize} viewBox=\"0 0 16 16\" fill=\"none\">\n <Path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M.116 8c0-6.4 1.6-8 8-8s8 1.6 8 8-1.6 8-8 8-8-1.6-8-8zm4.123 3.464a.848.848 0 10.943-1.41.848.848 0 00-.943 1.41zm.001-2.76a.848.848 0 10.948-1.408.848.848 0 00-.948 1.407zm0-2.759a.849.849 0 10.948-1.408.849.849 0 00-.948 1.408zm8.1 5.34a.388.388 0 00.03-.149v-.755a.39.39 0 00-.39-.39H6.87a.39.39 0 00-.39.39v.755a.39.39 0 00.39.39h5.11a.39.39 0 00.36-.24zm0-2.758a.388.388 0 00.03-.149v-.757a.387.387 0 00-.39-.388H6.87a.388.388 0 00-.39.388v.757a.388.388 0 00.39.388h5.11a.388.388 0 00.36-.24zm0-2.76a.388.388 0 00.03-.148v-.754a.39.39 0 00-.39-.389H6.87a.39.39 0 00-.39.387v.756a.39.39 0 00.39.39h5.11a.389.389 0 00.36-.241z\"\n fill=\"url(#paint0_linear_2632_56586)\"\n />\n <Defs>\n <LinearGradient\n id=\"paint0_linear_2632_56586\"\n x1={-5.51759}\n y1={5.6338}\n x2={5.75001}\n y2={16.9014}\n gradientUnits=\"userSpaceOnUse\"\n >\n <Stop stopColor=\"#6BB23D\" />\n <Stop offset={1} stopColor=\"#659630\" />\n </LinearGradient>\n </Defs>\n </Svg>\n )\n}\n"]}