@repzo/widget-react-native 1.0.9 → 1.2.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 (191) hide show
  1. package/CHANGELOG.md +400 -0
  2. package/README.md +104 -5
  3. package/lib/commonjs/agent-ui-blocks.js +2 -1
  4. package/lib/commonjs/agent-ui-blocks.js.map +1 -1
  5. package/lib/commonjs/api/client.js +25 -0
  6. package/lib/commonjs/api/client.js.map +1 -1
  7. package/lib/commonjs/attachments/pickers.js +3 -6
  8. package/lib/commonjs/attachments/pickers.js.map +1 -1
  9. package/lib/commonjs/device-id.js +31 -3
  10. package/lib/commonjs/device-id.js.map +1 -1
  11. package/lib/commonjs/i18n.js +40 -4
  12. package/lib/commonjs/i18n.js.map +1 -1
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/locales.js +34 -1
  15. package/lib/commonjs/locales.js.map +1 -1
  16. package/lib/commonjs/push/push-notifications.js +9 -8
  17. package/lib/commonjs/push/push-notifications.js.map +1 -1
  18. package/lib/commonjs/state/widget-store.js +507 -26
  19. package/lib/commonjs/state/widget-store.js.map +1 -1
  20. package/lib/commonjs/storage.js +13 -1
  21. package/lib/commonjs/storage.js.map +1 -1
  22. package/lib/commonjs/types.js +20 -2
  23. package/lib/commonjs/types.js.map +1 -1
  24. package/lib/commonjs/ui/WidgetProvider.js +138 -49
  25. package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
  26. package/lib/commonjs/ui/components/AgentUiBlocks.js +35 -15
  27. package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -1
  28. package/lib/commonjs/ui/components/Launcher.js +4 -1
  29. package/lib/commonjs/ui/components/Launcher.js.map +1 -1
  30. package/lib/commonjs/ui/components/Markdown.js +32 -2
  31. package/lib/commonjs/ui/components/Markdown.js.map +1 -1
  32. package/lib/commonjs/ui/components/Post.js +1241 -0
  33. package/lib/commonjs/ui/components/Post.js.map +1 -0
  34. package/lib/commonjs/ui/components/RatingCard.js +6 -3
  35. package/lib/commonjs/ui/components/RatingCard.js.map +1 -1
  36. package/lib/commonjs/ui/hooks/use-widget-insets.js +0 -1
  37. package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -1
  38. package/lib/commonjs/ui/screens/chat/ChatView.js +67 -29
  39. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
  40. package/lib/commonjs/ui/utils/html.js +9 -1
  41. package/lib/commonjs/ui/utils/html.js.map +1 -1
  42. package/lib/commonjs/ui/utils/native-gradient.js +0 -1
  43. package/lib/commonjs/ui/utils/native-gradient.js.map +1 -1
  44. package/lib/commonjs/ui/utils/post-html.js +276 -0
  45. package/lib/commonjs/ui/utils/post-html.js.map +1 -0
  46. package/lib/commonjs/ui/utils/safe-url.js +16 -0
  47. package/lib/commonjs/ui/utils/safe-url.js.map +1 -1
  48. package/lib/module/agent-ui-blocks.js +2 -1
  49. package/lib/module/agent-ui-blocks.js.map +1 -1
  50. package/lib/module/api/client.js +25 -0
  51. package/lib/module/api/client.js.map +1 -1
  52. package/lib/module/attachments/pickers.js +3 -6
  53. package/lib/module/attachments/pickers.js.map +1 -1
  54. package/lib/module/device-id.js +31 -3
  55. package/lib/module/device-id.js.map +1 -1
  56. package/lib/module/i18n.js +40 -4
  57. package/lib/module/i18n.js.map +1 -1
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/locales.js +34 -1
  60. package/lib/module/locales.js.map +1 -1
  61. package/lib/module/push/push-notifications.js +9 -8
  62. package/lib/module/push/push-notifications.js.map +1 -1
  63. package/lib/module/state/widget-store.js +507 -25
  64. package/lib/module/state/widget-store.js.map +1 -1
  65. package/lib/module/storage.js +13 -1
  66. package/lib/module/storage.js.map +1 -1
  67. package/lib/module/types.js +20 -2
  68. package/lib/module/types.js.map +1 -1
  69. package/lib/module/ui/WidgetProvider.js +139 -50
  70. package/lib/module/ui/WidgetProvider.js.map +1 -1
  71. package/lib/module/ui/components/AgentUiBlocks.js +35 -15
  72. package/lib/module/ui/components/AgentUiBlocks.js.map +1 -1
  73. package/lib/module/ui/components/Launcher.js +4 -1
  74. package/lib/module/ui/components/Launcher.js.map +1 -1
  75. package/lib/module/ui/components/Markdown.js +32 -3
  76. package/lib/module/ui/components/Markdown.js.map +1 -1
  77. package/lib/module/ui/components/Post.js +1236 -0
  78. package/lib/module/ui/components/Post.js.map +1 -0
  79. package/lib/module/ui/components/RatingCard.js +6 -3
  80. package/lib/module/ui/components/RatingCard.js.map +1 -1
  81. package/lib/module/ui/hooks/use-widget-insets.js +0 -1
  82. package/lib/module/ui/hooks/use-widget-insets.js.map +1 -1
  83. package/lib/module/ui/screens/chat/ChatView.js +68 -30
  84. package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
  85. package/lib/module/ui/utils/html.js +9 -2
  86. package/lib/module/ui/utils/html.js.map +1 -1
  87. package/lib/module/ui/utils/native-gradient.js +0 -1
  88. package/lib/module/ui/utils/native-gradient.js.map +1 -1
  89. package/lib/module/ui/utils/post-html.js +271 -0
  90. package/lib/module/ui/utils/post-html.js.map +1 -0
  91. package/lib/module/ui/utils/safe-url.js +15 -0
  92. package/lib/module/ui/utils/safe-url.js.map +1 -1
  93. package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/api/client.d.ts +19 -1
  95. package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/attachments/pickers.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/device-id.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/i18n.d.ts +35 -1
  99. package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/index.d.ts +1 -1
  101. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/locales.d.ts.map +1 -1
  103. package/lib/typescript/commonjs/push/push-notifications.d.ts +6 -2
  104. package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/state/widget-store.d.ts +97 -8
  106. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/storage.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/types.d.ts +91 -8
  109. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +14 -0
  112. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/ui/components/Markdown.d.ts +8 -0
  115. package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/ui/components/Post.d.ts +69 -0
  117. package/lib/typescript/commonjs/ui/components/Post.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +10 -0
  122. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/ui/utils/html.d.ts +1 -0
  124. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/ui/utils/post-html.d.ts +54 -0
  127. package/lib/typescript/commonjs/ui/utils/post-html.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +6 -0
  129. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -1
  130. package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -1
  131. package/lib/typescript/module/api/client.d.ts +19 -1
  132. package/lib/typescript/module/api/client.d.ts.map +1 -1
  133. package/lib/typescript/module/attachments/pickers.d.ts.map +1 -1
  134. package/lib/typescript/module/device-id.d.ts.map +1 -1
  135. package/lib/typescript/module/i18n.d.ts +35 -1
  136. package/lib/typescript/module/i18n.d.ts.map +1 -1
  137. package/lib/typescript/module/index.d.ts +1 -1
  138. package/lib/typescript/module/index.d.ts.map +1 -1
  139. package/lib/typescript/module/locales.d.ts.map +1 -1
  140. package/lib/typescript/module/push/push-notifications.d.ts +6 -2
  141. package/lib/typescript/module/push/push-notifications.d.ts.map +1 -1
  142. package/lib/typescript/module/state/widget-store.d.ts +97 -8
  143. package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
  144. package/lib/typescript/module/storage.d.ts.map +1 -1
  145. package/lib/typescript/module/types.d.ts +91 -8
  146. package/lib/typescript/module/types.d.ts.map +1 -1
  147. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
  148. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +14 -0
  149. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -1
  150. package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -1
  151. package/lib/typescript/module/ui/components/Markdown.d.ts +8 -0
  152. package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -1
  153. package/lib/typescript/module/ui/components/Post.d.ts +69 -0
  154. package/lib/typescript/module/ui/components/Post.d.ts.map +1 -0
  155. package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -1
  156. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -1
  157. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
  158. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +10 -0
  159. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  160. package/lib/typescript/module/ui/utils/html.d.ts +1 -0
  161. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -1
  162. package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -1
  163. package/lib/typescript/module/ui/utils/post-html.d.ts +54 -0
  164. package/lib/typescript/module/ui/utils/post-html.d.ts.map +1 -0
  165. package/lib/typescript/module/ui/utils/safe-url.d.ts +6 -0
  166. package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -1
  167. package/package.json +14 -4
  168. package/src/agent-ui-blocks.ts +2 -1
  169. package/src/api/client.ts +27 -0
  170. package/src/attachments/pickers.ts +3 -6
  171. package/src/device-id.ts +34 -3
  172. package/src/i18n.ts +39 -2
  173. package/src/index.tsx +4 -0
  174. package/src/locales.ts +33 -0
  175. package/src/push/push-notifications.ts +10 -8
  176. package/src/state/widget-store.ts +480 -24
  177. package/src/storage.ts +18 -1
  178. package/src/types.ts +91 -8
  179. package/src/ui/WidgetProvider.tsx +166 -48
  180. package/src/ui/components/AgentUiBlocks.tsx +40 -12
  181. package/src/ui/components/Launcher.tsx +6 -1
  182. package/src/ui/components/Markdown.tsx +34 -3
  183. package/src/ui/components/Post.tsx +943 -0
  184. package/src/ui/components/RatingCard.tsx +6 -2
  185. package/src/ui/hooks/use-widget-insets.ts +0 -1
  186. package/src/ui/screens/chat/ChatView.tsx +77 -42
  187. package/src/ui/screens/chat/ChatView.types.ts +10 -0
  188. package/src/ui/utils/html.ts +10 -2
  189. package/src/ui/utils/native-gradient.ts +0 -1
  190. package/src/ui/utils/post-html.ts +256 -0
  191. package/src/ui/utils/safe-url.ts +15 -0
package/src/i18n.ts CHANGED
@@ -32,16 +32,17 @@ export function createTranslator(config: WidgetConfig | null, locale: string): T
32
32
  /**
33
33
  * Dashboard copy that's written per language: the default language's text is
34
34
  * the plain config field and every other enabled language's lives under the
35
- * same key in `translations`.
35
+ * same key in `translations`. The offline message is written the same way.
36
36
  */
37
37
  const WELCOME_TEXT_KEYS = [
38
38
  'welcomeHeading',
39
39
  'welcomeSubheading',
40
40
  'startConversationLabel',
41
41
  'replyTimeLabel',
42
+ 'offlineMessage',
42
43
  ] as const;
43
44
 
44
- /** The config with its welcome text in the active locale. */
45
+ /** The config with its welcome text and offline message in the active locale. */
45
46
  export function localizeWelcomeText(config: WidgetConfig | null, locale: string): WidgetConfig | null {
46
47
  if (!config) return config;
47
48
  const translate = createTranslator(config, locale);
@@ -136,6 +137,14 @@ export const DEFAULT_LABELS = {
136
137
  // Forms.
137
138
  procedureSend: 'Send details',
138
139
  procedureSent: 'Sent',
140
+ procedureShareDetails: 'Share details',
141
+ procedureDetailsSent: 'Details sent',
142
+ procedureHide: 'Hide',
143
+ procedureFieldCount: '{count} fields',
144
+ procedureFieldCountOne: '1 field',
145
+ procedureTitle: 'Details',
146
+ procedureEmailPlaceholder: 'name@example.com',
147
+ procedurePhonePlaceholder: '+962 7...',
139
148
  fieldRequired: '{field} is required',
140
149
  invalidEmail: 'Enter a valid email address',
141
150
  working: 'Working...',
@@ -148,12 +157,40 @@ export const DEFAULT_LABELS = {
148
157
  notificationNewReply: 'New reply',
149
158
  notificationAttachment: 'Sent an attachment',
150
159
  notificationOpenHint: 'Opens the conversation',
160
+ // Send posts over the app.
161
+ postFrom: '{name} from {workspace}',
162
+ postNewMessage: 'New message',
163
+ postOpenHint: 'Opens the message',
164
+ postClose: 'Close',
165
+ postMinimize: 'Minimize',
166
+ postReplyPlaceholder: 'Write a reply…',
167
+ postSend: 'Send',
168
+ postSent: 'Sent',
169
+ postReplyFailed: "Couldn't send your reply. Try again.",
170
+ postReactions: 'Reactions',
171
+ postThanks: 'Thanks for your feedback!',
172
+ postConversation: 'Your conversation',
173
+ postContinueChat: 'Continue in Messenger',
151
174
  // Rich blocks an agent can send.
152
175
  blockService: 'Service',
153
176
  blockProduct: 'Product',
154
177
  blockChooseTime: 'Choose a time',
155
178
  blockProfessional: 'Professional',
156
179
  blockPriceOffer: 'Price offer',
180
+ blockSubtotal: 'Subtotal',
181
+ blockDiscount: 'Discount',
182
+ blockTax: 'Tax',
183
+ blockShipping: 'Shipping',
184
+ blockTotal: 'Total',
185
+ blockMinutes: '{count} min',
186
+ blockSave: 'Save',
187
+ blockAnyAvailable: 'Any available',
188
+ blockWithProvider: 'With {name}',
189
+ blockBookTime: 'Book this time',
190
+ blockValidUntil: 'Valid until {date}',
191
+ // Floating launcher button (screen reader names).
192
+ launcherOpen: 'Open chat',
193
+ launcherClose: 'Close chat',
157
194
  } as const;
158
195
 
159
196
  export type LabelKey = keyof typeof DEFAULT_LABELS;
package/src/index.tsx CHANGED
@@ -33,6 +33,9 @@ export type {
33
33
  InAppNotification,
34
34
  Message,
35
35
  OutboundMessage,
36
+ PostInteractionKind,
37
+ PostReply,
38
+ PostThreadMessage,
36
39
  PreChatField,
37
40
  RepzoPickedFile,
38
41
  RepzoWidgetAttachmentOptions,
@@ -41,6 +44,7 @@ export type {
41
44
  WidgetAttachment,
42
45
  WidgetConfig,
43
46
  WidgetCustomAttributes,
47
+ WidgetPost,
44
48
  WidgetSpace,
45
49
  WidgetSpaceType,
46
50
  WidgetState,
package/src/locales.ts CHANGED
@@ -90,6 +90,13 @@ const ar: LabelMap = {
90
90
  rating5: 'ممتاز',
91
91
  procedureSend: 'إرسال التفاصيل',
92
92
  procedureSent: 'تم الإرسال',
93
+ procedureShareDetails: 'مشاركة التفاصيل',
94
+ procedureDetailsSent: 'تم إرسال التفاصيل',
95
+ procedureHide: 'إخفاء',
96
+ // "Fields: 5" sidesteps Arabic's count-dependent plural forms.
97
+ procedureFieldCount: 'الحقول: {count}',
98
+ procedureFieldCountOne: 'حقل واحد',
99
+ procedureTitle: 'التفاصيل',
93
100
  fieldRequired: '{field} مطلوب',
94
101
  invalidEmail: 'أدخل بريدًا إلكترونيًا صالحًا',
95
102
  working: 'جارٍ العمل...',
@@ -100,11 +107,37 @@ const ar: LabelMap = {
100
107
  notificationNewReply: 'رد جديد',
101
108
  notificationAttachment: 'أرسل مرفقًا',
102
109
  notificationOpenHint: 'يفتح المحادثة',
110
+ postFrom: '{name} من {workspace}',
111
+ postNewMessage: 'رسالة جديدة',
112
+ postOpenHint: 'يفتح الرسالة',
113
+ postClose: 'إغلاق',
114
+ postMinimize: 'تصغير',
115
+ postReplyPlaceholder: 'اكتب ردًا…',
116
+ postSend: 'إرسال',
117
+ postSent: 'تم الإرسال',
118
+ postReplyFailed: 'تعذّر إرسال ردك. حاول مرة أخرى.',
119
+ postReactions: 'التفاعلات',
120
+ postThanks: 'شكراً على ملاحظاتك!',
121
+ postConversation: 'محادثتك',
122
+ postContinueChat: 'تابع في المحادثة',
103
123
  blockService: 'خدمة',
104
124
  blockProduct: 'منتج',
105
125
  blockChooseTime: 'اختر وقتًا',
106
126
  blockProfessional: 'الموظف',
107
127
  blockPriceOffer: 'عرض سعر',
128
+ blockSubtotal: 'المجموع الفرعي',
129
+ blockDiscount: 'الخصم',
130
+ blockTax: 'الضريبة',
131
+ blockShipping: 'الشحن',
132
+ blockTotal: 'الإجمالي',
133
+ blockMinutes: '{count} دقيقة',
134
+ blockSave: 'حفظ',
135
+ blockAnyAvailable: 'أي موظف متاح',
136
+ blockWithProvider: 'مع {name}',
137
+ blockBookTime: 'احجز هذا الموعد',
138
+ blockValidUntil: 'صالح حتى {date}',
139
+ launcherOpen: 'فتح المحادثة',
140
+ launcherClose: 'إغلاق المحادثة',
108
141
  };
109
142
 
110
143
  export const BUNDLED_TRANSLATIONS: Record<string, LabelMap> = { ar };
@@ -50,7 +50,6 @@ interface MessagingHandle {
50
50
 
51
51
  function resolveMessaging(): MessagingHandle | null {
52
52
  try {
53
- // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
54
53
  const mod = require('@react-native-firebase/messaging');
55
54
 
56
55
  // Modular API — the only one in RNFB v26+ (the namespaced default export
@@ -110,7 +109,8 @@ export class PushManager {
110
109
 
111
110
  constructor(
112
111
  private client: WidgetApiClient,
113
- private openConversation: (conversationId: string) => void
112
+ private openConversation: (conversationId: string) => void,
113
+ private openPost: (campaignId: string) => void = () => {}
114
114
  ) {}
115
115
 
116
116
  /** Remember the boot options; actual work happens in start() post-init. */
@@ -242,13 +242,15 @@ export class PushManager {
242
242
  .catch(() => {});
243
243
  }
244
244
 
245
- /** Only widget pushes are ours — host app notifications pass through. */
245
+ /**
246
+ * Only widget pushes are ours — host app notifications pass through. A team
247
+ * reply opens its conversation; a Send post opens the post.
248
+ */
246
249
  private handleTap(remoteMessage: any) {
247
250
  const data = remoteMessage?.data;
248
- if (data?.document_type !== 'widget_message') return;
249
- const conversationId = data?.document_id;
250
- if (typeof conversationId === 'string' && conversationId) {
251
- this.openConversation(conversationId);
252
- }
251
+ const documentId = data?.document_id;
252
+ if (typeof documentId !== 'string' || !documentId) return;
253
+ if (data?.document_type === 'widget_message') this.openConversation(documentId);
254
+ else if (data?.document_type === 'send_post') this.openPost(documentId);
253
255
  }
254
256
  }