@repzo/widget-react-native 1.3.0 → 1.4.0

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 (251) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/README.md +72 -16
  3. package/lib/commonjs/api/client.js +113 -0
  4. package/lib/commonjs/api/client.js.map +1 -1
  5. package/lib/commonjs/attachments/file-size.js +52 -0
  6. package/lib/commonjs/attachments/file-size.js.map +1 -0
  7. package/lib/commonjs/attachments/local-previews.js +40 -0
  8. package/lib/commonjs/attachments/local-previews.js.map +1 -0
  9. package/lib/commonjs/attachments/pickers.js +76 -28
  10. package/lib/commonjs/attachments/pickers.js.map +1 -1
  11. package/lib/commonjs/i18n.js +24 -3
  12. package/lib/commonjs/i18n.js.map +1 -1
  13. package/lib/commonjs/locales.js +13 -3
  14. package/lib/commonjs/locales.js.map +1 -1
  15. package/lib/commonjs/state/widget-store.js +486 -63
  16. package/lib/commonjs/state/widget-store.js.map +1 -1
  17. package/lib/commonjs/storage.js +3 -1
  18. package/lib/commonjs/storage.js.map +1 -1
  19. package/lib/commonjs/types.js.map +1 -1
  20. package/lib/commonjs/ui/WidgetProvider.js +40 -16
  21. package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
  22. package/lib/commonjs/ui/components/AttachmentChips.js +109 -40
  23. package/lib/commonjs/ui/components/AttachmentChips.js.map +1 -1
  24. package/lib/commonjs/ui/components/ConversationRow.js +65 -10
  25. package/lib/commonjs/ui/components/ConversationRow.js.map +1 -1
  26. package/lib/commonjs/ui/components/ImageViewer.js +231 -25
  27. package/lib/commonjs/ui/components/ImageViewer.js.map +1 -1
  28. package/lib/commonjs/ui/components/RatingCard.js +5 -2
  29. package/lib/commonjs/ui/components/RatingCard.js.map +1 -1
  30. package/lib/commonjs/ui/components/ZoomableImage.js +58 -10
  31. package/lib/commonjs/ui/components/ZoomableImage.js.map +1 -1
  32. package/lib/commonjs/ui/components/icons.js +22 -16
  33. package/lib/commonjs/ui/components/icons.js.map +1 -1
  34. package/lib/commonjs/ui/hooks/use-retained-state.js +39 -0
  35. package/lib/commonjs/ui/hooks/use-retained-state.js.map +1 -0
  36. package/lib/commonjs/ui/screens/chat/ChatView.js +666 -171
  37. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
  38. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +150 -3
  39. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -1
  40. package/lib/commonjs/ui/screens/conversations/ConversationsList.js +1 -0
  41. package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -1
  42. package/lib/commonjs/ui/screens/home/HomeView.js +38 -55
  43. package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -1
  44. package/lib/commonjs/ui/screens/home/HomeView.styles.js +36 -45
  45. package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -1
  46. package/lib/commonjs/ui/styles/theme.js +1 -0
  47. package/lib/commonjs/ui/styles/theme.js.map +1 -1
  48. package/lib/commonjs/ui/utils/conversations.js +17 -1
  49. package/lib/commonjs/ui/utils/conversations.js.map +1 -1
  50. package/lib/commonjs/ui/utils/html.js +13 -0
  51. package/lib/commonjs/ui/utils/html.js.map +1 -1
  52. package/lib/commonjs/ui/utils/image-load-queue.js +114 -0
  53. package/lib/commonjs/ui/utils/image-load-queue.js.map +1 -0
  54. package/lib/commonjs/ui/utils/inline-attachments.js +88 -0
  55. package/lib/commonjs/ui/utils/inline-attachments.js.map +1 -0
  56. package/lib/module/api/client.js +113 -0
  57. package/lib/module/api/client.js.map +1 -1
  58. package/lib/module/attachments/file-size.js +47 -0
  59. package/lib/module/attachments/file-size.js.map +1 -0
  60. package/lib/module/attachments/local-previews.js +33 -0
  61. package/lib/module/attachments/local-previews.js.map +1 -0
  62. package/lib/module/attachments/pickers.js +74 -27
  63. package/lib/module/attachments/pickers.js.map +1 -1
  64. package/lib/module/i18n.js +24 -3
  65. package/lib/module/i18n.js.map +1 -1
  66. package/lib/module/locales.js +13 -3
  67. package/lib/module/locales.js.map +1 -1
  68. package/lib/module/state/widget-store.js +488 -65
  69. package/lib/module/state/widget-store.js.map +1 -1
  70. package/lib/module/storage.js +2 -0
  71. package/lib/module/storage.js.map +1 -1
  72. package/lib/module/types.js.map +1 -1
  73. package/lib/module/ui/WidgetProvider.js +40 -16
  74. package/lib/module/ui/WidgetProvider.js.map +1 -1
  75. package/lib/module/ui/components/AttachmentChips.js +111 -42
  76. package/lib/module/ui/components/AttachmentChips.js.map +1 -1
  77. package/lib/module/ui/components/ConversationRow.js +65 -10
  78. package/lib/module/ui/components/ConversationRow.js.map +1 -1
  79. package/lib/module/ui/components/ImageViewer.js +233 -27
  80. package/lib/module/ui/components/ImageViewer.js.map +1 -1
  81. package/lib/module/ui/components/RatingCard.js +5 -2
  82. package/lib/module/ui/components/RatingCard.js.map +1 -1
  83. package/lib/module/ui/components/ZoomableImage.js +58 -10
  84. package/lib/module/ui/components/ZoomableImage.js.map +1 -1
  85. package/lib/module/ui/components/icons.js +21 -15
  86. package/lib/module/ui/components/icons.js.map +1 -1
  87. package/lib/module/ui/hooks/use-retained-state.js +34 -0
  88. package/lib/module/ui/hooks/use-retained-state.js.map +1 -0
  89. package/lib/module/ui/screens/chat/ChatView.js +672 -177
  90. package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
  91. package/lib/module/ui/screens/chat/ChatView.styles.js +152 -4
  92. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -1
  93. package/lib/module/ui/screens/conversations/ConversationsList.js +1 -0
  94. package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -1
  95. package/lib/module/ui/screens/home/HomeView.js +40 -57
  96. package/lib/module/ui/screens/home/HomeView.js.map +1 -1
  97. package/lib/module/ui/screens/home/HomeView.styles.js +36 -45
  98. package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -1
  99. package/lib/module/ui/styles/theme.js +1 -0
  100. package/lib/module/ui/styles/theme.js.map +1 -1
  101. package/lib/module/ui/utils/conversations.js +15 -1
  102. package/lib/module/ui/utils/conversations.js.map +1 -1
  103. package/lib/module/ui/utils/html.js +12 -0
  104. package/lib/module/ui/utils/html.js.map +1 -1
  105. package/lib/module/ui/utils/image-load-queue.js +109 -0
  106. package/lib/module/ui/utils/image-load-queue.js.map +1 -0
  107. package/lib/module/ui/utils/inline-attachments.js +85 -0
  108. package/lib/module/ui/utils/inline-attachments.js.map +1 -0
  109. package/lib/typescript/commonjs/api/client.d.ts +35 -1
  110. package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/attachments/file-size.d.ts +15 -0
  112. package/lib/typescript/commonjs/attachments/file-size.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/attachments/local-previews.d.ts +14 -0
  114. package/lib/typescript/commonjs/attachments/local-previews.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/attachments/pickers.d.ts +35 -10
  116. package/lib/typescript/commonjs/attachments/pickers.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/i18n.d.ts +13 -3
  118. package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/locales.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/state/widget-store.d.ts +67 -4
  121. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/storage.d.ts +2 -0
  123. package/lib/typescript/commonjs/storage.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/types.d.ts +58 -0
  125. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts +13 -3
  128. package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +15 -1
  130. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts +26 -6
  132. package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts +10 -1
  135. package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/ui/components/icons.d.ts +2 -1
  137. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts +11 -0
  139. package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +4 -4
  141. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +154 -2
  143. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +30 -1
  145. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
  148. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +7 -5
  150. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +30 -35
  152. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +5 -6
  154. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/ui/styles/theme.d.ts +2 -0
  156. package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/ui/utils/conversations.d.ts +10 -2
  158. package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/ui/utils/html.d.ts +5 -0
  160. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -1
  161. package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts +44 -0
  162. package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts +29 -0
  164. package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts.map +1 -0
  165. package/lib/typescript/module/api/client.d.ts +35 -1
  166. package/lib/typescript/module/api/client.d.ts.map +1 -1
  167. package/lib/typescript/module/attachments/file-size.d.ts +15 -0
  168. package/lib/typescript/module/attachments/file-size.d.ts.map +1 -0
  169. package/lib/typescript/module/attachments/local-previews.d.ts +14 -0
  170. package/lib/typescript/module/attachments/local-previews.d.ts.map +1 -0
  171. package/lib/typescript/module/attachments/pickers.d.ts +35 -10
  172. package/lib/typescript/module/attachments/pickers.d.ts.map +1 -1
  173. package/lib/typescript/module/i18n.d.ts +13 -3
  174. package/lib/typescript/module/i18n.d.ts.map +1 -1
  175. package/lib/typescript/module/locales.d.ts.map +1 -1
  176. package/lib/typescript/module/state/widget-store.d.ts +67 -4
  177. package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
  178. package/lib/typescript/module/storage.d.ts +2 -0
  179. package/lib/typescript/module/storage.d.ts.map +1 -1
  180. package/lib/typescript/module/types.d.ts +58 -0
  181. package/lib/typescript/module/types.d.ts.map +1 -1
  182. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
  183. package/lib/typescript/module/ui/components/AttachmentChips.d.ts +13 -3
  184. package/lib/typescript/module/ui/components/AttachmentChips.d.ts.map +1 -1
  185. package/lib/typescript/module/ui/components/ConversationRow.d.ts +15 -1
  186. package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -1
  187. package/lib/typescript/module/ui/components/ImageViewer.d.ts +26 -6
  188. package/lib/typescript/module/ui/components/ImageViewer.d.ts.map +1 -1
  189. package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -1
  190. package/lib/typescript/module/ui/components/ZoomableImage.d.ts +10 -1
  191. package/lib/typescript/module/ui/components/ZoomableImage.d.ts.map +1 -1
  192. package/lib/typescript/module/ui/components/icons.d.ts +2 -1
  193. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -1
  194. package/lib/typescript/module/ui/hooks/use-retained-state.d.ts +11 -0
  195. package/lib/typescript/module/ui/hooks/use-retained-state.d.ts.map +1 -0
  196. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +4 -4
  197. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
  198. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +154 -2
  199. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
  200. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +30 -1
  201. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  202. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
  203. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
  204. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
  205. package/lib/typescript/module/ui/screens/home/HomeView.d.ts +7 -5
  206. package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -1
  207. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +30 -35
  208. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -1
  209. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +5 -6
  210. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -1
  211. package/lib/typescript/module/ui/styles/theme.d.ts +2 -0
  212. package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -1
  213. package/lib/typescript/module/ui/utils/conversations.d.ts +10 -2
  214. package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -1
  215. package/lib/typescript/module/ui/utils/html.d.ts +5 -0
  216. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -1
  217. package/lib/typescript/module/ui/utils/image-load-queue.d.ts +44 -0
  218. package/lib/typescript/module/ui/utils/image-load-queue.d.ts.map +1 -0
  219. package/lib/typescript/module/ui/utils/inline-attachments.d.ts +29 -0
  220. package/lib/typescript/module/ui/utils/inline-attachments.d.ts.map +1 -0
  221. package/package.json +1 -1
  222. package/src/api/client.ts +148 -2
  223. package/src/attachments/file-size.ts +42 -0
  224. package/src/attachments/local-previews.ts +32 -0
  225. package/src/attachments/pickers.ts +90 -30
  226. package/src/i18n.ts +24 -3
  227. package/src/locales.ts +13 -3
  228. package/src/state/widget-store.ts +519 -70
  229. package/src/storage.ts +2 -0
  230. package/src/types.ts +58 -0
  231. package/src/ui/WidgetProvider.tsx +50 -12
  232. package/src/ui/components/AttachmentChips.tsx +100 -29
  233. package/src/ui/components/ConversationRow.tsx +90 -9
  234. package/src/ui/components/ImageViewer.tsx +250 -28
  235. package/src/ui/components/RatingCard.tsx +5 -2
  236. package/src/ui/components/ZoomableImage.tsx +58 -5
  237. package/src/ui/components/icons.tsx +10 -12
  238. package/src/ui/hooks/use-retained-state.ts +35 -0
  239. package/src/ui/screens/chat/ChatView.styles.ts +151 -3
  240. package/src/ui/screens/chat/ChatView.tsx +760 -213
  241. package/src/ui/screens/chat/ChatView.types.ts +30 -1
  242. package/src/ui/screens/conversations/ConversationsList.tsx +1 -0
  243. package/src/ui/screens/conversations/ConversationsList.types.ts +2 -0
  244. package/src/ui/screens/home/HomeView.styles.ts +36 -45
  245. package/src/ui/screens/home/HomeView.tsx +54 -70
  246. package/src/ui/screens/home/HomeView.types.ts +5 -6
  247. package/src/ui/styles/theme.ts +6 -0
  248. package/src/ui/utils/conversations.ts +16 -2
  249. package/src/ui/utils/html.ts +26 -0
  250. package/src/ui/utils/image-load-queue.ts +108 -0
  251. package/src/ui/utils/inline-attachments.ts +71 -0
@@ -15,6 +15,7 @@ import { forwardDirection, START_ALIGN } from "../utils/rtl.js";
15
15
  import { fontSize, palette, spacing } from "../styles/theme.js";
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  const AVATAR_SIZE = 40;
18
+ const CARD_AVATAR_SIZE = 32;
18
19
  export function ConversationRow({
19
20
  conversation,
20
21
  color,
@@ -22,47 +23,59 @@ export function ConversationRow({
22
23
  timeLabels,
23
24
  unreadCount = 0,
24
25
  unreadLabel,
26
+ lastMessageLabels,
25
27
  horizontalPadding = spacing.xl,
28
+ variant = 'list',
26
29
  onPress
27
30
  }) {
31
+ const card = variant === 'card';
28
32
  const displayName = conversation.agentName || fallbackName;
29
33
  const hasUnread = unreadCount > 0;
30
34
  const unreadSuffix = hasUnread && unreadLabel ? `. ${formatLabel(unreadLabel, {
31
35
  count: unreadCount
32
36
  })}` : '';
37
+ const attachment = conversation.lastMessageAttachment;
38
+ // "Photo" or "File" over Workstation's "2 attachments".
39
+ const snippet = attachment && lastMessageLabels?.[attachment] || conversation.snippet || '';
40
+ // "You: " is drawn a shade stronger than the message, so it reads as a label.
41
+ const [youBefore, youAfter] = snippet && conversation.lastMessageFromVisitor && lastMessageLabels?.you ? splitAround(lastMessageLabels.you, '{message}') : ['', ''];
42
+ const snippetLabel = `${youBefore}${snippet}${youAfter}`;
33
43
  return /*#__PURE__*/_jsxs(Pressable, {
34
44
  onPress: onPress,
35
45
  accessibilityRole: "button",
36
- accessibilityLabel: `${conversation.snippet ? `${displayName}. ${conversation.snippet}` : displayName}${unreadSuffix}`,
46
+ accessibilityLabel: `${snippet ? `${displayName}. ${snippetLabel}` : displayName}${unreadSuffix}`,
37
47
  android_ripple: {
38
48
  color: palette.borderSoft
39
49
  },
40
50
  style: ({
41
51
  pressed
42
- }) => [styles.row, {
52
+ }) => [styles.row, card && cardStyles.row, {
43
53
  paddingHorizontal: horizontalPadding
44
54
  }, pressed && styles.rowPressed],
45
55
  children: [/*#__PURE__*/_jsx(Avatar, {
46
56
  avatar: conversation.agentAvatar,
47
57
  name: conversation.agentName,
48
- size: AVATAR_SIZE,
58
+ size: card ? CARD_AVATAR_SIZE : AVATAR_SIZE,
49
59
  color: color
50
60
  }), /*#__PURE__*/_jsxs(View, {
51
61
  style: styles.content,
52
62
  children: [/*#__PURE__*/_jsxs(View, {
53
- style: styles.topLine,
63
+ style: [styles.topLine, card && cardStyles.topLine],
54
64
  children: [/*#__PURE__*/_jsx(Text, {
55
- style: [styles.name, hasUnread && styles.nameUnread],
65
+ style: card ? [cardStyles.name, hasUnread && cardStyles.nameUnread] : [styles.name, hasUnread && styles.nameUnread],
56
66
  numberOfLines: 1,
57
67
  children: displayName
58
68
  }), /*#__PURE__*/_jsx(Text, {
59
- style: styles.time,
69
+ style: [styles.time, card && cardStyles.time],
60
70
  children: conversation.lastMessageAt ? formatRelativeTime(conversation.lastMessageAt, timeLabels) : ''
61
71
  })]
62
- }), conversation.snippet ? /*#__PURE__*/_jsx(Text, {
63
- style: [styles.snippet, hasUnread && styles.snippetUnread],
72
+ }), snippet ? /*#__PURE__*/_jsxs(Text, {
73
+ style: [styles.snippet, card && cardStyles.snippet, hasUnread && styles.snippetUnread],
64
74
  numberOfLines: 2,
65
- children: conversation.snippet
75
+ children: [youBefore ? /*#__PURE__*/_jsx(Text, {
76
+ style: styles.snippetYou,
77
+ children: youBefore
78
+ }) : null, snippet, youAfter]
66
79
  }) : null]
67
80
  }), hasUnread ? /*#__PURE__*/_jsx(View, {
68
81
  style: [styles.badge, {
@@ -72,7 +85,7 @@ export function ConversationRow({
72
85
  style: styles.badgeLabel,
73
86
  children: unreadCount > 9 ? '9+' : unreadCount
74
87
  })
75
- }) : /*#__PURE__*/_jsx(ChevronIcon, {
88
+ }) : card ? null : /*#__PURE__*/_jsx(ChevronIcon, {
76
89
  size: 16,
77
90
  direction: forwardDirection(),
78
91
  color: palette.textSubtle
@@ -80,6 +93,13 @@ export function ConversationRow({
80
93
  });
81
94
  }
82
95
 
96
+ /** `'You: {message}'` → `['You: ', '']`; a template without the token goes in front. */
97
+ function splitAround(template, token) {
98
+ const index = template.indexOf(token);
99
+ if (index < 0) return [`${template} `, ''];
100
+ return [template.slice(0, index), template.slice(index + token.length)];
101
+ }
102
+
83
103
  /** Where a divider should start so it sits under the text, not the avatar. */
84
104
  export function rowDividerInset(horizontalPadding = spacing.xl) {
85
105
  return horizontalPadding + AVATAR_SIZE + spacing.md;
@@ -131,6 +151,10 @@ const styles = StyleSheet.create({
131
151
  color: palette.text,
132
152
  fontWeight: '500'
133
153
  },
154
+ snippetYou: {
155
+ color: palette.text,
156
+ fontWeight: '600'
157
+ },
134
158
  // Replaces the chevron rather than crowding beside it, so the row keeps
135
159
  // the same width whether or not there is anything unread.
136
160
  badge: {
@@ -147,4 +171,35 @@ const styles = StyleSheet.create({
147
171
  fontWeight: '700'
148
172
  }
149
173
  });
174
+
175
+ // Overrides for the `card` variant. It sits under the card's title, so it
176
+ // drops the list's minimum height, and its name, time and last message share
177
+ // one size, the way the Home design draws them.
178
+ const cardStyles = StyleSheet.create({
179
+ row: {
180
+ minHeight: 0,
181
+ paddingVertical: spacing.sm
182
+ },
183
+ // The time follows the name instead of being pushed to the far edge.
184
+ topLine: {
185
+ justifyContent: 'flex-start'
186
+ },
187
+ name: {
188
+ textAlign: START_ALIGN,
189
+ flexShrink: 1,
190
+ fontSize: fontSize.body,
191
+ color: palette.ink
192
+ },
193
+ nameUnread: {
194
+ fontWeight: '600'
195
+ },
196
+ time: {
197
+ fontSize: fontSize.body
198
+ },
199
+ snippet: {
200
+ fontSize: fontSize.body,
201
+ lineHeight: fontSize.body * 1.35,
202
+ color: palette.textSubtle
203
+ }
204
+ });
150
205
  //# sourceMappingURL=ConversationRow.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Pressable","StyleSheet","Text","View","Avatar","formatLabel","formatRelativeTime","ChevronIcon","forwardDirection","START_ALIGN","fontSize","palette","spacing","jsx","_jsx","jsxs","_jsxs","AVATAR_SIZE","ConversationRow","conversation","color","fallbackName","timeLabels","unreadCount","unreadLabel","horizontalPadding","xl","onPress","displayName","agentName","hasUnread","unreadSuffix","count","accessibilityRole","accessibilityLabel","snippet","android_ripple","borderSoft","style","pressed","styles","row","paddingHorizontal","rowPressed","children","avatar","agentAvatar","name","size","content","topLine","nameUnread","numberOfLines","time","lastMessageAt","snippetUnread","badge","backgroundColor","badgeLabel","direction","textSubtle","rowDividerInset","md","create","flexDirection","alignItems","gap","minHeight","paddingVertical","white","surface","flex","minWidth","justifyContent","sm","textAlign","body","fontWeight","ink","caption","meta","lineHeight","textMuted","marginTop","text","height","borderRadius","xs","micro"],"sourceRoot":"../../../../src","sources":["ui/components/ConversationRow.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAGhE,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,WAAW,QAAQ,eAAY;AACxC,SAASC,kBAAkB,QAAiC,2BAAwB;AACpF,SAASC,WAAW,QAAQ,YAAS;AACrC,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iBAAc;AAC5D,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE7D,MAAMC,WAAW,GAAG,EAAE;AAiBtB,OAAO,SAASC,eAAeA,CAAC;EAC9BC,YAAY;EACZC,KAAK;EACLC,YAAY;EACZC,UAAU;EACVC,WAAW,GAAG,CAAC;EACfC,WAAW;EACXC,iBAAiB,GAAGb,OAAO,CAACc,EAAE;EAC9BC;AACoB,CAAC,EAAE;EACvB,MAAMC,WAAW,GAAGT,YAAY,CAACU,SAAS,IAAIR,YAAY;EAC1D,MAAM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AAK,EAAET,OAAO,CAAC0D,KAAK;IACpB3D,QAAQ,EAAEA,QAAQ,CAAC8E,KAAK;IACxBX,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Pressable","StyleSheet","Text","View","Avatar","formatLabel","formatRelativeTime","ChevronIcon","forwardDirection","START_ALIGN","fontSize","palette","spacing","jsx","_jsx","jsxs","_jsxs","AVATAR_SIZE","CARD_AVATAR_SIZE","ConversationRow","conversation","color","fallbackName","timeLabels","unreadCount","unreadLabel","lastMessageLabels","horizontalPadding","xl","variant","onPress","card","displayName","agentName","hasUnread","unreadSuffix","count","attachment","lastMessageAttachment","snippet","youBefore","youAfter","lastMessageFromVisitor","you","splitAround","snippetLabel","accessibilityRole","accessibilityLabel","android_ripple","borderSoft","style","pressed","styles","row","cardStyles","paddingHorizontal","rowPressed","children","avatar","agentAvatar","name","size","content","topLine","nameUnread","numberOfLines","time","lastMessageAt","snippetUnread","snippetYou","badge","backgroundColor","badgeLabel","direction","textSubtle","template","token","index","indexOf","slice","length","rowDividerInset","md","create","flexDirection","alignItems","gap","minHeight","paddingVertical","white","surface","flex","minWidth","justifyContent","sm","textAlign","body","fontWeight","ink","caption","meta","lineHeight","textMuted","marginTop","text","height","borderRadius","xs","micro","flexShrink"],"sourceRoot":"../../../../src","sources":["ui/components/ConversationRow.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAGhE,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,WAAW,QAAQ,eAAY;AACxC,SAASC,kBAAkB,QAAiC,2BAAwB;AACpF,SAASC,WAAW,QAAQ,YAAS;AACrC,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iBAAc;AAC5D,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC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;IACvBK,UAAU,EAAE3F,QAAQ,CAACsF,IAAI,GAAG,IAAI;IAChC3E,KAAK,EAAEV,OAAO,CAAC+D;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -3,29 +3,137 @@
3
3
  /**
4
4
  * Full-screen viewer for image attachments, so a tap on a photo the agent sent
5
5
  * stays inside the messenger instead of bouncing to the browser. Pinch, drag
6
- * and double-tap zoom work on iOS and Android (see ZoomableImage).
6
+ * and double-tap zoom work on iOS and Android (see ZoomableImage). With
7
+ * several photos in one message, a sideways swipe moves between them.
7
8
  */
8
9
 
9
- import { useState } from 'react';
10
- import { ActivityIndicator, Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native';
10
+ import { useLayoutEffect, useRef, useState } from 'react';
11
+ import { ActivityIndicator, Animated, Image, Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native';
12
+ import { formatLabel } from "../../i18n.js";
13
+ import { useReduceMotion } from "../hooks/use-reduce-motion.js";
11
14
  import { useWidgetInsets } from "../hooks/use-widget-insets.js";
12
15
  import { fontSize, palette, spacing } from "../styles/theme.js";
16
+ import { isRTL } from "../utils/rtl.js";
17
+ import { isHttpUrl } from "../utils/safe-url.js";
13
18
  import { CloseIcon } from "./icons.js";
14
19
  import { ZoomableImage } from "./ZoomableImage.js";
20
+
21
+ /** The photos of one message, opened at the one tapped. */
15
22
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
+ /** A swipe changes photo past this share of the screen, or this fast (px/ms). */
24
+ const SWIPE_DISTANCE = 0.25;
25
+ const SWIPE_VELOCITY = 0.5;
26
+ /** Past the first or last photo the strip only gives this much. */
27
+ const EDGE_RESISTANCE = 0.25;
16
28
  export function ImageViewer({
17
- image,
29
+ gallery,
18
30
  labels,
19
31
  onClose,
20
32
  onOpenExternally
21
33
  }) {
22
34
  const insets = useWidgetInsets();
23
- // Keyed by URL so opening another image starts from a clean loading state.
35
+ const reduceMotion = useReduceMotion();
36
+ // The photo on screen, for the gallery it belongs to: a new gallery opens at its own.
37
+ const [position, setPosition] = useState({
38
+ of: null,
39
+ index: 0
40
+ });
41
+ const images = gallery?.images ?? [];
42
+ const index = position.of === gallery ? position.index : gallery?.index ?? 0;
43
+ const image = images[index] ?? null;
44
+ // Photos whose own URL failed, now shown from their fallback.
45
+ const [fellBack, setFellBack] = useState(() => new Set());
46
+ const sourceOf = photo => photo.fallbackUrl && fellBack.has(photo.url) ? photo.fallbackUrl : photo.url;
47
+ const source = image ? sourceOf(image) : null;
48
+ // Keyed by URL so each photo starts from a clean loading state.
24
49
  const [status, setStatus] = useState({
25
50
  url: null,
26
51
  state: 'loading'
27
52
  });
28
- const state = status.url === image?.url ? status.state : 'loading';
53
+ const state = status.url === source ? status.state : 'loading';
54
+ // False once there's nothing left to try, so the caller shows the failure.
55
+ const fallBack = photo => {
56
+ if (!photo.fallbackUrl || fellBack.has(photo.url)) return false;
57
+ setFellBack(current => new Set(current).add(photo.url));
58
+ return true;
59
+ };
60
+ // Photos whose screen-size copy is drawn: no spinner over those while the full one decodes.
61
+ const [previewed, setPreviewed] = useState(() => new Set());
62
+ const markPreviewed = url => setPreviewed(current => current.has(url) ? current : new Set(current).add(url));
63
+ const [width, setWidth] = useState(0);
64
+ // One page per photo, never reordered: a swipe slides the strip to the photo
65
+ // it lands on and leaves it there. (Re-centring three pages instead showed the
66
+ // wrong photo, then a black frame, for a moment on Android.)
67
+ const [offset] = useState(() => new Animated.Value(0));
68
+ const rtl = isRTL();
69
+ // Pages run left to right in every language; in Arabic the first photo is the rightmost.
70
+ const restingAt = photo => -(rtl ? images.length - 1 - photo : photo) * width;
71
+ const swiping = useRef(false);
72
+ // Closing the viewer mid-swipe stops the slide unfinished, so it never
73
+ // settles: the next gallery is placed afresh.
74
+ useLayoutEffect(() => {
75
+ swiping.current = false;
76
+ }, [gallery]);
77
+ // Places the strip when the viewer opens, the screen turns or the screen reader
78
+ // moves; after a swipe it is already there.
79
+ useLayoutEffect(() => {
80
+ if (!swiping.current) offset.setValue(restingAt(index));
81
+ });
82
+
83
+ // In Arabic the next photo is the one on the left.
84
+ const step = rtl ? -1 : 1;
85
+ const neighbour = side => {
86
+ const next = index + side * step;
87
+ return next >= 0 && next < images.length ? next : null;
88
+ };
89
+ const show = next => {
90
+ if (next !== null) setPosition({
91
+ of: gallery,
92
+ index: next
93
+ });
94
+ };
95
+ const swipe = {
96
+ move: dx => {
97
+ swiping.current = true;
98
+ const resisted = neighbour(dx < 0 ? 1 : -1) === null ? dx * EDGE_RESISTANCE : dx;
99
+ offset.setValue(restingAt(index) + resisted);
100
+ },
101
+ end: (dx, vx) => {
102
+ const next = neighbour(dx < 0 ? 1 : -1);
103
+ const far = Math.abs(dx) > width * SWIPE_DISTANCE || Math.abs(vx) > SWIPE_VELOCITY && Math.sign(vx) === Math.sign(dx);
104
+ const target = next !== null && dx !== 0 && far ? next : index;
105
+ const toValue = restingAt(target);
106
+ // Switched as the finger lifts: the counter changes at once, and the full
107
+ // photo decodes while the strip is still sliding to it.
108
+ show(target === index ? null : target);
109
+ if (reduceMotion !== false) {
110
+ offset.setValue(toValue);
111
+ swiping.current = false;
112
+ return;
113
+ }
114
+ const animation = target === index ? Animated.spring(offset, {
115
+ toValue,
116
+ useNativeDriver: true,
117
+ bounciness: 0,
118
+ speed: 18
119
+ }) : Animated.timing(offset, {
120
+ toValue,
121
+ duration: 180,
122
+ useNativeDriver: true
123
+ });
124
+ // A swipe that starts before this one lands takes over the strip; it settles it.
125
+ animation.start(({
126
+ finished
127
+ }) => {
128
+ if (finished) swiping.current = false;
129
+ });
130
+ }
131
+ };
132
+ const several = images.length > 1;
133
+ const handleAccessibilityAction = event => {
134
+ if (event.nativeEvent.actionName === 'increment' && index < images.length - 1) show(index + 1);
135
+ if (event.nativeEvent.actionName === 'decrement' && index > 0) show(index - 1);
136
+ };
29
137
  return /*#__PURE__*/_jsx(Modal, {
30
138
  visible: !!image,
31
139
  transparent: true,
@@ -35,30 +143,98 @@ export function ImageViewer({
35
143
  children: /*#__PURE__*/_jsxs(View, {
36
144
  style: styles.backdrop,
37
145
  accessibilityViewIsModal: true,
38
- children: [image ?
39
- /*#__PURE__*/
40
- // Keyed by URL so the next image opens at 1×, not at the last one's zoom.
41
- _jsx(ZoomableImage, {
42
- uri: image.url,
43
- accessibilityLabel: image.name,
44
- onLoad: () => setStatus({
45
- url: image.url,
46
- state: 'ready'
47
- }),
48
- onError: () => setStatus({
49
- url: image.url,
50
- state: 'failed'
146
+ onLayout: event => setWidth(event.nativeEvent.layout.width),
147
+ children: [image && width > 0 ? /*#__PURE__*/_jsx(Animated.View, {
148
+ style: [styles.strip, {
149
+ width: width * images.length,
150
+ transform: [{
151
+ translateX: offset
152
+ }]
153
+ }],
154
+ children: (rtl ? [...images].reverse() : images).map(photo => {
155
+ const page = images.indexOf(photo);
156
+ const centre = page === index;
157
+ const uri = sourceOf(photo);
158
+ // Only the photo on screen and the ones a swipe reveals are drawn.
159
+ const near = Math.abs(page - index) <= 1;
160
+ return /*#__PURE__*/_jsxs(View, {
161
+ style: [styles.page, {
162
+ width
163
+ }],
164
+ ...(centre && several ? {
165
+ accessible: true,
166
+ accessibilityRole: 'adjustable',
167
+ accessibilityLabel: photo.name,
168
+ accessibilityValue: {
169
+ text: formatLabel(labels.position, {
170
+ current: index + 1,
171
+ total: images.length
172
+ })
173
+ },
174
+ accessibilityActions: [{
175
+ name: 'increment'
176
+ }, {
177
+ name: 'decrement'
178
+ }],
179
+ onAccessibilityAction: handleAccessibilityAction
180
+ } : null),
181
+ children: [!near ? null : photo.large ? centre ? null : /*#__PURE__*/_jsx(ActivityIndicator, {
182
+ style: styles.layer,
183
+ color: palette.white
184
+ }) :
185
+ /*#__PURE__*/
186
+ // Decoded at the screen's size, so it's ready mid-swipe, and shown
187
+ // until the full photo on top has decoded.
188
+ _jsx(Image, {
189
+ source: {
190
+ uri
191
+ },
192
+ style: [styles.layer, centre && state === 'ready' && styles.covered],
193
+ resizeMode: "contain",
194
+ resizeMethod: "resize",
195
+ onLoad: () => markPreviewed(uri),
196
+ onError: () => fallBack(photo),
197
+ importantForAccessibility: "no",
198
+ accessibilityIgnoresInvertColors: true
199
+ }), centre ?
200
+ /*#__PURE__*/
201
+ // Keyed by URL so each photo opens at 1×, not at the last one's zoom.
202
+ _jsx(View, {
203
+ style: styles.layer,
204
+ children: /*#__PURE__*/_jsx(ZoomableImage, {
205
+ uri: uri,
206
+ accessibilityLabel: photo.name,
207
+ onLoad: () => setStatus({
208
+ url: uri,
209
+ state: 'ready'
210
+ }),
211
+ onError: () => {
212
+ if (!fallBack(photo)) setStatus({
213
+ url: uri,
214
+ state: 'failed'
215
+ });
216
+ },
217
+ onSwipe: several ? swipe : undefined
218
+ })
219
+ }, uri) : null]
220
+ }, `${page}:${photo.url}`);
51
221
  })
52
- }, image.url) : null, image && state === 'loading' ? /*#__PURE__*/_jsx(ActivityIndicator, {
222
+ }) : null, image && source && state === 'loading' && !previewed.has(source) ? /*#__PURE__*/_jsx(View, {
53
223
  style: StyleSheet.absoluteFill,
54
- color: palette.white
55
- }) : null, image && state === 'failed' ? /*#__PURE__*/_jsxs(View, {
224
+ pointerEvents: "none",
225
+ children: /*#__PURE__*/_jsx(ActivityIndicator, {
226
+ style: StyleSheet.absoluteFill,
227
+ color: palette.white
228
+ })
229
+ }) : null, image && source && state === 'failed' ? /*#__PURE__*/_jsxs(View, {
56
230
  style: [StyleSheet.absoluteFill, styles.center, styles.failed],
231
+ pointerEvents: "box-none",
57
232
  children: [/*#__PURE__*/_jsx(Text, {
58
233
  style: styles.failedText,
234
+ pointerEvents: "none",
59
235
  children: labels.loadFailed
60
- }), /*#__PURE__*/_jsx(Pressable, {
61
- onPress: () => onOpenExternally(image.url),
236
+ }), isHttpUrl(source) ? /*#__PURE__*/_jsx(Pressable, {
237
+ onPress: () => onOpenExternally(source),
62
238
  accessibilityRole: "button",
63
239
  style: ({
64
240
  pressed
@@ -67,7 +243,7 @@ export function ImageViewer({
67
243
  style: styles.externalLabel,
68
244
  children: labels.openExternally
69
245
  })
70
- })]
246
+ }) : null]
71
247
  }) : null, /*#__PURE__*/_jsxs(View, {
72
248
  style: [styles.header, {
73
249
  paddingTop: insets.top + spacing.sm
@@ -77,7 +253,12 @@ export function ImageViewer({
77
253
  style: styles.title,
78
254
  numberOfLines: 1,
79
255
  children: image?.name ?? ''
80
- }), /*#__PURE__*/_jsx(Pressable, {
256
+ }), several ? /*#__PURE__*/_jsxs(Text, {
257
+ style: styles.counter,
258
+ accessibilityElementsHidden: true,
259
+ importantForAccessibility: "no",
260
+ children: [index + 1, " / ", images.length]
261
+ }) : null, /*#__PURE__*/_jsx(Pressable, {
81
262
  onPress: onClose,
82
263
  accessibilityRole: "button",
83
264
  accessibilityLabel: labels.close,
@@ -97,7 +278,27 @@ export function ImageViewer({
97
278
  const styles = StyleSheet.create({
98
279
  backdrop: {
99
280
  flex: 1,
100
- backgroundColor: '#000000'
281
+ backgroundColor: '#000000',
282
+ overflow: 'hidden'
283
+ },
284
+ // One screen per photo, laid out left to right in every language (see `restingAt`).
285
+ strip: {
286
+ position: 'absolute',
287
+ top: 0,
288
+ bottom: 0,
289
+ left: 0,
290
+ flexDirection: 'row',
291
+ direction: 'ltr'
292
+ },
293
+ page: {
294
+ height: '100%'
295
+ },
296
+ layer: {
297
+ ...StyleSheet.absoluteFillObject
298
+ },
299
+ // Hidden, not removed: it shows again the moment its page stops being the middle one.
300
+ covered: {
301
+ opacity: 0
101
302
  },
102
303
  center: {
103
304
  flexGrow: 1,
@@ -123,6 +324,11 @@ const styles = StyleSheet.create({
123
324
  fontSize: fontSize.body,
124
325
  fontWeight: '600'
125
326
  },
327
+ counter: {
328
+ color: 'rgba(255,255,255,0.8)',
329
+ fontSize: fontSize.meta,
330
+ fontVariant: ['tabular-nums']
331
+ },
126
332
  closeButton: {
127
333
  width: 36,
128
334
  height: 36,
@@ -1 +1 @@
1
- {"version":3,"names":["useState","ActivityIndicator","Modal","Platform","Pressable","StyleSheet","Text","View","useWidgetInsets","fontSize","palette","spacing","CloseIcon","ZoomableImage","jsx","_jsx","jsxs","_jsxs","ImageViewer","image","labels","onClose","onOpenExternally","insets","status","setStatus","url","state","visible","transparent","animationType","statusBarTranslucent","onRequestClose","children","style","styles","backdrop","accessibilityViewIsModal","uri","accessibilityLabel","name","onLoad","onError","absoluteFill","color","white","center","failed","failedText","loadFailed","onPress","accessibilityRole","pressed","externalButton","externalLabel","openExternally","header","paddingTop","top","sm","pointerEvents","title","numberOfLines","close","hitSlop","closeButton","size","create","flex","backgroundColor","flexGrow","alignItems","justifyContent","position","left","right","flexDirection","gap","md","paddingHorizontal","lg","paddingBottom","minWidth","body","fontWeight","width","height","borderRadius","opacity","xxl","textAlign","paddingVertical","borderWidth","hairlineWidth","borderColor","meta","OS"],"sourceRoot":"../../../../src","sources":["ui/components/ImageViewer.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SACEC,iBAAiB,EACjBC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,IAAI,EACJC,IAAI,QACC,cAAc;AAErB,SAASC,eAAe,QAAQ,+BAA4B;AAC5D,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,oBAAiB;AAC5D,SAASC,SAAS,QAAQ,YAAS;AACnC,SAASC,aAAa,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAgBhD,OAAO,SAASC,WAAWA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC,OAAO;EAAEC;AAAmC,CAAC,EAAE;EAC1F,MAAMC,MAAM,GAAGf,eAAe,CAAC,CAAC;EAChC;EACA,MAAM,CAACgB,MAAM,EAAEC,SAAS,CAAC,GAAGzB,QAAQ,CAClC;IAAE0B,GAAG,EAAE,IAAI;IAAEC,KAAK,EAAE;EAAU,CAChC,CAAC;EACD,MAAMA,KAAK,GAAGH,MAAM,CAACE,GAAG,KAAKP,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rC,cAAc,EAAE;IACd0B,iBAAiB,EAAEpE,OAAO,CAACqE,EAAE;IAC7BW,eAAe,EAAEhF,OAAO,CAACgD,EAAE;IAC3B4B,YAAY,EAAE,GAAG;IACjBK,WAAW,EAAEvF,UAAU,CAACwF,aAAa;IACrCC,WAAW,EAAE;EACf,CAAC;EACDxC,aAAa,EAAE;IACbV,KAAK,EAAElC,OAAO,CAACmC,KAAK;IACpBpC,QAAQ,EAAEA,QAAQ,CAACsF,IAAI;IACvBX,UAAU,EAAEjF,QAAQ,CAAC6F,EAAE,KAAK,KAAK,GAAG,KAAK,GAAG;EAC9C;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useLayoutEffect","useRef","useState","ActivityIndicator","Animated","Image","Modal","Platform","Pressable","StyleSheet","Text","View","formatLabel","useReduceMotion","useWidgetInsets","fontSize","palette","spacing","isRTL","isHttpUrl","CloseIcon","ZoomableImage","jsx","_jsx","jsxs","_jsxs","SWIPE_DISTANCE","SWIPE_VELOCITY","EDGE_RESISTANCE","ImageViewer","gallery","labels","onClose","onOpenExternally","insets","reduceMotion","position","setPosition","of","index","images","image","fellBack","setFellBack","Set","sourceOf","photo","fallbackUrl","has","url","source","status","setStatus","state","fallBack","current","add","previewed","setPreviewed","markPreviewed","width","setWidth","offset","Value","rtl","restingAt","length","swiping","setValue","step","neighbour","side","next","show","swipe","move","dx","resisted","end","vx","far","Math","abs","sign","target","toValue","animation","spring","useNativeDriver","bounciness","speed","timing","duration","start","finished","several","handleAccessibilityAction","event","nativeEvent","actionName","visible","transparent","animationType","statusBarTranslucent","onRequestClose","children","style","styles","backdrop","accessibilityViewIsModal","onLayout","layout","strip","transform","translateX","reverse","map","page","indexOf","centre","uri","near","accessible","accessibilityRole","accessibilityLabel","name","accessibilityValue","text","total","accessibilityActions","onAccessibilityAction","large","layer","color","white","covered","resizeMode","resizeMethod","onLoad","onError","importantForAccessibility","accessibilityIgnoresInvertColors","onSwipe","undefined","absoluteFill","pointerEvents","center","failed","failedText","loadFailed","onPress","pressed","externalButton","externalLabel","openExternally","header","paddingTop","top","sm","title","numberOfLines","counter","accessibilityElementsHidden","close","hitSlop","closeButton","size","create","flex","backgroundColor","overflow","bottom","left","flexDirection","direction","height","absoluteFillObject","opacity","flexGrow","alignItems","justifyContent","right","gap","md","paddingHorizontal","lg","paddingBottom","minWidth","body","fontWeight","meta","fontVariant","borderRadius","xxl","textAlign","paddingVertical","borderWidth","hairlineWidth","borderColor","OS"],"sourceRoot":"../../../../src","sources":["ui/components/ImageViewer.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzD,SACEC,iBAAiB,EACjBC,QAAQ,EACRC,KAAK,EACLC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,IAAI,EACJC,IAAI,QAEC,cAAc;AAErB,SAASC,WAAW,QAAQ,eAAY;AACxC,SAASC,eAAe,QAAQ,+BAA4B;AAC5D,SAASC,eAAe,QAAQ,+BAA4B;AAC5D,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,oBAAiB;AAC5D,SAASC,KAAK,QAAQ,iBAAc;AACpC,SAASC,SAAS,QAAQ,sBAAmB;AAC7C,SAASC,SAAS,QAAQ,YAAS;AACnC,SAASC,aAAa,QAA4B,oBAAiB;;AA0BnE;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAMA;AACA,MAAMC,cAAc,GAAG,IAAI;AAC3B,MAAMC,cAAc,GAAG,GAAG;AAC1B;AACA,MAAMC,eAAe,GAAG,IAAI;AAU5B,OAAO,SAASC,WAAWA,CAAC;EAAEC,OAAO;EAAEC,MAAM;EAAEC,OAAO;EAAEC;AAAmC,CAAC,EAAE;EAC5F,MAAMC,MAAM,GAAGpB,eAAe,CAAC,CAAC;EAChC,MAAMqB,YAAY,GAAGtB,eAAe,CAAC,CAAC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AAU,EAAE;EACd,CAAC;EACD5B,OAAO,EAAE;IACP5B,KAAK,EAAE,uBAAuB;IAC9BtH,QAAQ,EAAEA,QAAQ,CAAC+K,IAAI;IACvBC,WAAW,EAAE,CAAC,cAAc;EAC9B,CAAC;EACD1B,WAAW,EAAE;IACXzG,KAAK,EAAE,EAAE;IACTmH,MAAM,EAAE,EAAE;IACViB,YAAY,EAAE,EAAE;IAChBb,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBX,eAAe,EAAE;EACnB,CAAC;EACDlB,OAAO,EAAE;IACP0B,OAAO,EAAE;EACX,CAAC;EACD9B,MAAM,EAAE;IACNmC,GAAG,EAAErK,OAAO,CAACsK,EAAE;IACfC,iBAAiB,EAAEvK,OAAO,CAACgL;EAC7B,CAAC;EACD7C,UAAU,EAAE;IACVf,KAAK,EAAErH,OAAO,CAACsH,KAAK;IACpBvH,QAAQ,EAAEA,QAAQ,CAAC6K,IAAI;IACvBM,SAAS,EAAE;EACb,CAAC;EACD1C,cAAc,EAAE;IACdgC,iBAAiB,EAAEvK,OAAO,CAACwK,EAAE;IAC7BU,eAAe,EAAElL,OAAO,CAAC6I,EAAE;IAC3BkC,YAAY,EAAE,GAAG;IACjBI,WAAW,EAAE3L,UAAU,CAAC4L,aAAa;IACrCC,WAAW,EAAE;EACf,CAAC;EACD7C,aAAa,EAAE;IACbpB,KAAK,EAAErH,OAAO,CAACsH,KAAK;IACpBvH,QAAQ,EAAEA,QAAQ,CAAC+K,IAAI;IACvBD,UAAU,EAAEtL,QAAQ,CAACgM,EAAE,KAAK,KAAK,GAAG,KAAK,GAAG;EAC9C;AACF,CAAC,CAAC","ignoreList":[]}
@@ -12,6 +12,7 @@
12
12
 
13
13
  import { useState } from 'react';
14
14
  import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
15
+ import { useRetainedState } from "../hooks/use-retained-state.js";
15
16
  import { contrastingTextColor, fontSize, palette, radius, spacing, withAlpha } from "../styles/theme.js";
16
17
 
17
18
  /** 1..5, worst to best — Intercom's five faces. */
@@ -78,12 +79,14 @@ export function RatingCard({
78
79
  const [rating, setRating] = useState(initialRating);
79
80
  const [reason, setReason] = useState(initialReason);
80
81
  const [comment, setComment] = useState(initialComment);
81
- const [draft, setDraft] = useState('');
82
+ // Kept while the thread unmounts the card far off screen; the rating
83
+ // itself is saved on the message.
84
+ const [draft, setDraft] = useRetainedState(`${ratingId}:draft`, '');
82
85
  // The comment is optional: "Done" with nothing typed just closes the box —
83
86
  // the face (and reason) are already saved. A card that opens with a saved
84
87
  // rating starts closed too, so "Done" sticks when the thread is reopened;
85
88
  // tapping the chosen face opens the box again.
86
- const [finished, setFinished] = useState(initialRating != null);
89
+ const [finished, setFinished] = useRetainedState(`${ratingId}:finished`, initialRating != null);
87
90
  const [pending, setPending] = useState(false);
88
91
  const [closedReason, setClosedReason] = useState(initialComment ? 'locked' : null);
89
92
  const [failed, setFailed] = useState(false);