@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.
- package/CHANGELOG.md +400 -0
- package/README.md +104 -5
- package/lib/commonjs/agent-ui-blocks.js +2 -1
- package/lib/commonjs/agent-ui-blocks.js.map +1 -1
- package/lib/commonjs/api/client.js +25 -0
- package/lib/commonjs/api/client.js.map +1 -1
- package/lib/commonjs/attachments/pickers.js +3 -6
- package/lib/commonjs/attachments/pickers.js.map +1 -1
- package/lib/commonjs/device-id.js +31 -3
- package/lib/commonjs/device-id.js.map +1 -1
- package/lib/commonjs/i18n.js +40 -4
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/locales.js +34 -1
- package/lib/commonjs/locales.js.map +1 -1
- package/lib/commonjs/push/push-notifications.js +9 -8
- package/lib/commonjs/push/push-notifications.js.map +1 -1
- package/lib/commonjs/state/widget-store.js +507 -26
- package/lib/commonjs/state/widget-store.js.map +1 -1
- package/lib/commonjs/storage.js +13 -1
- package/lib/commonjs/storage.js.map +1 -1
- package/lib/commonjs/types.js +20 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui/WidgetProvider.js +138 -49
- package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
- package/lib/commonjs/ui/components/AgentUiBlocks.js +35 -15
- package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -1
- package/lib/commonjs/ui/components/Launcher.js +4 -1
- package/lib/commonjs/ui/components/Launcher.js.map +1 -1
- package/lib/commonjs/ui/components/Markdown.js +32 -2
- package/lib/commonjs/ui/components/Markdown.js.map +1 -1
- package/lib/commonjs/ui/components/Post.js +1241 -0
- package/lib/commonjs/ui/components/Post.js.map +1 -0
- package/lib/commonjs/ui/components/RatingCard.js +6 -3
- package/lib/commonjs/ui/components/RatingCard.js.map +1 -1
- package/lib/commonjs/ui/hooks/use-widget-insets.js +0 -1
- package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -1
- package/lib/commonjs/ui/screens/chat/ChatView.js +67 -29
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/commonjs/ui/utils/html.js +9 -1
- package/lib/commonjs/ui/utils/html.js.map +1 -1
- package/lib/commonjs/ui/utils/native-gradient.js +0 -1
- package/lib/commonjs/ui/utils/native-gradient.js.map +1 -1
- package/lib/commonjs/ui/utils/post-html.js +276 -0
- package/lib/commonjs/ui/utils/post-html.js.map +1 -0
- package/lib/commonjs/ui/utils/safe-url.js +16 -0
- package/lib/commonjs/ui/utils/safe-url.js.map +1 -1
- package/lib/module/agent-ui-blocks.js +2 -1
- package/lib/module/agent-ui-blocks.js.map +1 -1
- package/lib/module/api/client.js +25 -0
- package/lib/module/api/client.js.map +1 -1
- package/lib/module/attachments/pickers.js +3 -6
- package/lib/module/attachments/pickers.js.map +1 -1
- package/lib/module/device-id.js +31 -3
- package/lib/module/device-id.js.map +1 -1
- package/lib/module/i18n.js +40 -4
- package/lib/module/i18n.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/locales.js +34 -1
- package/lib/module/locales.js.map +1 -1
- package/lib/module/push/push-notifications.js +9 -8
- package/lib/module/push/push-notifications.js.map +1 -1
- package/lib/module/state/widget-store.js +507 -25
- package/lib/module/state/widget-store.js.map +1 -1
- package/lib/module/storage.js +13 -1
- package/lib/module/storage.js.map +1 -1
- package/lib/module/types.js +20 -2
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui/WidgetProvider.js +139 -50
- package/lib/module/ui/WidgetProvider.js.map +1 -1
- package/lib/module/ui/components/AgentUiBlocks.js +35 -15
- package/lib/module/ui/components/AgentUiBlocks.js.map +1 -1
- package/lib/module/ui/components/Launcher.js +4 -1
- package/lib/module/ui/components/Launcher.js.map +1 -1
- package/lib/module/ui/components/Markdown.js +32 -3
- package/lib/module/ui/components/Markdown.js.map +1 -1
- package/lib/module/ui/components/Post.js +1236 -0
- package/lib/module/ui/components/Post.js.map +1 -0
- package/lib/module/ui/components/RatingCard.js +6 -3
- package/lib/module/ui/components/RatingCard.js.map +1 -1
- package/lib/module/ui/hooks/use-widget-insets.js +0 -1
- package/lib/module/ui/hooks/use-widget-insets.js.map +1 -1
- package/lib/module/ui/screens/chat/ChatView.js +68 -30
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/module/ui/utils/html.js +9 -2
- package/lib/module/ui/utils/html.js.map +1 -1
- package/lib/module/ui/utils/native-gradient.js +0 -1
- package/lib/module/ui/utils/native-gradient.js.map +1 -1
- package/lib/module/ui/utils/post-html.js +271 -0
- package/lib/module/ui/utils/post-html.js.map +1 -0
- package/lib/module/ui/utils/safe-url.js +15 -0
- package/lib/module/ui/utils/safe-url.js.map +1 -1
- package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -1
- package/lib/typescript/commonjs/api/client.d.ts +19 -1
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/attachments/pickers.d.ts.map +1 -1
- package/lib/typescript/commonjs/device-id.d.ts.map +1 -1
- package/lib/typescript/commonjs/i18n.d.ts +35 -1
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/locales.d.ts.map +1 -1
- package/lib/typescript/commonjs/push/push-notifications.d.ts +6 -2
- package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -1
- package/lib/typescript/commonjs/state/widget-store.d.ts +97 -8
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/storage.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +91 -8
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +14 -0
- package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/Markdown.d.ts +8 -0
- package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/Post.d.ts +69 -0
- package/lib/typescript/commonjs/ui/components/Post.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +10 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/html.d.ts +1 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/post-html.d.ts +54 -0
- package/lib/typescript/commonjs/ui/utils/post-html.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +6 -0
- package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -1
- package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -1
- package/lib/typescript/module/api/client.d.ts +19 -1
- package/lib/typescript/module/api/client.d.ts.map +1 -1
- package/lib/typescript/module/attachments/pickers.d.ts.map +1 -1
- package/lib/typescript/module/device-id.d.ts.map +1 -1
- package/lib/typescript/module/i18n.d.ts +35 -1
- package/lib/typescript/module/i18n.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/locales.d.ts.map +1 -1
- package/lib/typescript/module/push/push-notifications.d.ts +6 -2
- package/lib/typescript/module/push/push-notifications.d.ts.map +1 -1
- package/lib/typescript/module/state/widget-store.d.ts +97 -8
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/module/storage.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +91 -8
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +14 -0
- package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/Markdown.d.ts +8 -0
- package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/Post.d.ts +69 -0
- package/lib/typescript/module/ui/components/Post.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +10 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/html.d.ts +1 -0
- package/lib/typescript/module/ui/utils/html.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/post-html.d.ts +54 -0
- package/lib/typescript/module/ui/utils/post-html.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/safe-url.d.ts +6 -0
- package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -1
- package/package.json +14 -4
- package/src/agent-ui-blocks.ts +2 -1
- package/src/api/client.ts +27 -0
- package/src/attachments/pickers.ts +3 -6
- package/src/device-id.ts +34 -3
- package/src/i18n.ts +39 -2
- package/src/index.tsx +4 -0
- package/src/locales.ts +33 -0
- package/src/push/push-notifications.ts +10 -8
- package/src/state/widget-store.ts +480 -24
- package/src/storage.ts +18 -1
- package/src/types.ts +91 -8
- package/src/ui/WidgetProvider.tsx +166 -48
- package/src/ui/components/AgentUiBlocks.tsx +40 -12
- package/src/ui/components/Launcher.tsx +6 -1
- package/src/ui/components/Markdown.tsx +34 -3
- package/src/ui/components/Post.tsx +943 -0
- package/src/ui/components/RatingCard.tsx +6 -2
- package/src/ui/hooks/use-widget-insets.ts +0 -1
- package/src/ui/screens/chat/ChatView.tsx +77 -42
- package/src/ui/screens/chat/ChatView.types.ts +10 -0
- package/src/ui/utils/html.ts +10 -2
- package/src/ui/utils/native-gradient.ts +0 -1
- package/src/ui/utils/post-html.ts +256 -0
- 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
|
-
/**
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
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
|
}
|