@repzo/widget-react-native 1.0.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/README.md +482 -0
- package/lib/commonjs/agent-ui-blocks.js +159 -0
- package/lib/commonjs/agent-ui-blocks.js.map +1 -0
- package/lib/commonjs/api/client.js +267 -0
- package/lib/commonjs/api/client.js.map +1 -0
- package/lib/commonjs/api/realtime.js +193 -0
- package/lib/commonjs/api/realtime.js.map +1 -0
- package/lib/commonjs/api/sse-parser.js +58 -0
- package/lib/commonjs/api/sse-parser.js.map +1 -0
- package/lib/commonjs/controller.js +23 -0
- package/lib/commonjs/controller.js.map +1 -0
- package/lib/commonjs/device-id.js +75 -0
- package/lib/commonjs/device-id.js.map +1 -0
- package/lib/commonjs/events.js +49 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/i18n.js +106 -0
- package/lib/commonjs/i18n.js.map +1 -0
- package/lib/commonjs/index.js +98 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/locales.js +85 -0
- package/lib/commonjs/locales.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/push/push-notifications.js +208 -0
- package/lib/commonjs/push/push-notifications.js.map +1 -0
- package/lib/commonjs/state/use-widget-state.js +23 -0
- package/lib/commonjs/state/use-widget-state.js.map +1 -0
- package/lib/commonjs/state/widget-store.js +1682 -0
- package/lib/commonjs/state/widget-store.js.map +1 -0
- package/lib/commonjs/storage.js +147 -0
- package/lib/commonjs/storage.js.map +1 -0
- package/lib/commonjs/types.js +44 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/ui/WidgetProvider.js +404 -0
- package/lib/commonjs/ui/WidgetProvider.js.map +1 -0
- package/lib/commonjs/ui/components/AgentUiBlocks.js +864 -0
- package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -0
- package/lib/commonjs/ui/components/Avatar.js +76 -0
- package/lib/commonjs/ui/components/Avatar.js.map +1 -0
- package/lib/commonjs/ui/components/ConversationRow.js +155 -0
- package/lib/commonjs/ui/components/ConversationRow.js.map +1 -0
- package/lib/commonjs/ui/components/ErrorBoundary.js +44 -0
- package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
- package/lib/commonjs/ui/components/Gradient.js +168 -0
- package/lib/commonjs/ui/components/Gradient.js.map +1 -0
- package/lib/commonjs/ui/components/Launcher.js +125 -0
- package/lib/commonjs/ui/components/Launcher.js.map +1 -0
- package/lib/commonjs/ui/components/Markdown.js +257 -0
- package/lib/commonjs/ui/components/Markdown.js.map +1 -0
- package/lib/commonjs/ui/components/OutboundMessageCard.js +157 -0
- package/lib/commonjs/ui/components/OutboundMessageCard.js.map +1 -0
- package/lib/commonjs/ui/components/WidgetPanel.js +131 -0
- package/lib/commonjs/ui/components/WidgetPanel.js.map +1 -0
- package/lib/commonjs/ui/components/icons.js +383 -0
- package/lib/commonjs/ui/components/icons.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-keyboard-overlap.js +113 -0
- package/lib/commonjs/ui/hooks/use-keyboard-overlap.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-reduce-motion.js +38 -0
- package/lib/commonjs/ui/hooks/use-reduce-motion.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-widget-insets.js +41 -0
- package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js +590 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js +362 -0
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.types.js +6 -0
- package/lib/commonjs/ui/screens/chat/ChatView.types.js.map +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js +150 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js +118 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js +6 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js.map +1 -0
- package/lib/commonjs/ui/screens/home/HomeView.js +336 -0
- package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -0
- package/lib/commonjs/ui/screens/home/HomeView.styles.js +245 -0
- package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/home/HomeView.types.js +6 -0
- package/lib/commonjs/ui/screens/home/HomeView.types.js.map +1 -0
- package/lib/commonjs/ui/screens/home/greeting.js +49 -0
- package/lib/commonjs/ui/screens/home/greeting.js.map +1 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js +229 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js.map +1 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js +125 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js +6 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
- package/lib/commonjs/ui/styles/global.js +55 -0
- package/lib/commonjs/ui/styles/global.js.map +1 -0
- package/lib/commonjs/ui/styles/theme.js +148 -0
- package/lib/commonjs/ui/styles/theme.js.map +1 -0
- package/lib/commonjs/ui/utils/conversations.js +125 -0
- package/lib/commonjs/ui/utils/conversations.js.map +1 -0
- package/lib/commonjs/ui/utils/html.js +44 -0
- package/lib/commonjs/ui/utils/html.js.map +1 -0
- package/lib/commonjs/ui/utils/native-gradient.js +65 -0
- package/lib/commonjs/ui/utils/native-gradient.js.map +1 -0
- package/lib/commonjs/ui/utils/rtl.js +56 -0
- package/lib/commonjs/ui/utils/rtl.js.map +1 -0
- package/lib/commonjs/ui/utils/safe-url.js +67 -0
- package/lib/commonjs/ui/utils/safe-url.js.map +1 -0
- package/lib/module/agent-ui-blocks.js +152 -0
- package/lib/module/agent-ui-blocks.js.map +1 -0
- package/lib/module/api/client.js +261 -0
- package/lib/module/api/client.js.map +1 -0
- package/lib/module/api/realtime.js +189 -0
- package/lib/module/api/realtime.js.map +1 -0
- package/lib/module/api/sse-parser.js +53 -0
- package/lib/module/api/sse-parser.js.map +1 -0
- package/lib/module/controller.js +19 -0
- package/lib/module/controller.js.map +1 -0
- package/lib/module/device-id.js +69 -0
- package/lib/module/device-id.js.map +1 -0
- package/lib/module/events.js +44 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/i18n.js +99 -0
- package/lib/module/i18n.js.map +1 -0
- package/lib/module/index.js +55 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/locales.js +80 -0
- package/lib/module/locales.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/push/push-notifications.js +204 -0
- package/lib/module/push/push-notifications.js.map +1 -0
- package/lib/module/state/use-widget-state.js +18 -0
- package/lib/module/state/use-widget-state.js.map +1 -0
- package/lib/module/state/widget-store.js +1677 -0
- package/lib/module/state/widget-store.js.map +1 -0
- package/lib/module/storage.js +141 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/types.js +40 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/ui/WidgetProvider.js +400 -0
- package/lib/module/ui/WidgetProvider.js.map +1 -0
- package/lib/module/ui/components/AgentUiBlocks.js +857 -0
- package/lib/module/ui/components/AgentUiBlocks.js.map +1 -0
- package/lib/module/ui/components/Avatar.js +71 -0
- package/lib/module/ui/components/Avatar.js.map +1 -0
- package/lib/module/ui/components/ConversationRow.js +150 -0
- package/lib/module/ui/components/ConversationRow.js.map +1 -0
- package/lib/module/ui/components/ErrorBoundary.js +39 -0
- package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
- package/lib/module/ui/components/Gradient.js +165 -0
- package/lib/module/ui/components/Gradient.js.map +1 -0
- package/lib/module/ui/components/Launcher.js +121 -0
- package/lib/module/ui/components/Launcher.js.map +1 -0
- package/lib/module/ui/components/Markdown.js +253 -0
- package/lib/module/ui/components/Markdown.js.map +1 -0
- package/lib/module/ui/components/OutboundMessageCard.js +153 -0
- package/lib/module/ui/components/OutboundMessageCard.js.map +1 -0
- package/lib/module/ui/components/WidgetPanel.js +127 -0
- package/lib/module/ui/components/WidgetPanel.js.map +1 -0
- package/lib/module/ui/components/icons.js +370 -0
- package/lib/module/ui/components/icons.js.map +1 -0
- package/lib/module/ui/hooks/use-keyboard-overlap.js +109 -0
- package/lib/module/ui/hooks/use-keyboard-overlap.js.map +1 -0
- package/lib/module/ui/hooks/use-reduce-motion.js +34 -0
- package/lib/module/ui/hooks/use-reduce-motion.js.map +1 -0
- package/lib/module/ui/hooks/use-widget-insets.js +37 -0
- package/lib/module/ui/hooks/use-widget-insets.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.js +586 -0
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.styles.js +358 -0
- package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.types.js +4 -0
- package/lib/module/ui/screens/chat/ChatView.types.js.map +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.js +146 -0
- package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.styles.js +114 -0
- package/lib/module/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.types.js +4 -0
- package/lib/module/ui/screens/conversations/ConversationsList.types.js.map +1 -0
- package/lib/module/ui/screens/home/HomeView.js +332 -0
- package/lib/module/ui/screens/home/HomeView.js.map +1 -0
- package/lib/module/ui/screens/home/HomeView.styles.js +242 -0
- package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -0
- package/lib/module/ui/screens/home/HomeView.types.js +4 -0
- package/lib/module/ui/screens/home/HomeView.types.js.map +1 -0
- package/lib/module/ui/screens/home/greeting.js +44 -0
- package/lib/module/ui/screens/home/greeting.js.map +1 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.js +225 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.js.map +1 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js +121 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.types.js +4 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
- package/lib/module/ui/styles/global.js +51 -0
- package/lib/module/ui/styles/global.js.map +1 -0
- package/lib/module/ui/styles/theme.js +137 -0
- package/lib/module/ui/styles/theme.js.map +1 -0
- package/lib/module/ui/utils/conversations.js +115 -0
- package/lib/module/ui/utils/conversations.js.map +1 -0
- package/lib/module/ui/utils/html.js +39 -0
- package/lib/module/ui/utils/html.js.map +1 -0
- package/lib/module/ui/utils/native-gradient.js +60 -0
- package/lib/module/ui/utils/native-gradient.js.map +1 -0
- package/lib/module/ui/utils/rtl.js +49 -0
- package/lib/module/ui/utils/rtl.js.map +1 -0
- package/lib/module/ui/utils/safe-url.js +59 -0
- package/lib/module/ui/utils/safe-url.js.map +1 -0
- package/lib/typescript/commonjs/agent-ui-blocks.d.ts +20 -0
- package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -0
- package/lib/typescript/commonjs/api/client.d.ts +115 -0
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/api/realtime.d.ts +39 -0
- package/lib/typescript/commonjs/api/realtime.d.ts.map +1 -0
- package/lib/typescript/commonjs/api/sse-parser.d.ts +13 -0
- package/lib/typescript/commonjs/api/sse-parser.d.ts.map +1 -0
- package/lib/typescript/commonjs/controller.d.ts +15 -0
- package/lib/typescript/commonjs/controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/device-id.d.ts +15 -0
- package/lib/typescript/commonjs/device-id.d.ts.map +1 -0
- package/lib/typescript/commonjs/events.d.ts +41 -0
- package/lib/typescript/commonjs/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/i18n.d.ts +78 -0
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +103 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/locales.d.ts +18 -0
- package/lib/typescript/commonjs/locales.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/push/push-notifications.d.ts +71 -0
- package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/use-widget-state.d.ts +10 -0
- package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/widget-store.d.ts +227 -0
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/storage.d.ts +42 -0
- package/lib/typescript/commonjs/storage.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +391 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts +15 -0
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +27 -0
- package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Avatar.d.ts +19 -0
- package/lib/typescript/commonjs/ui/components/Avatar.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +26 -0
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +27 -0
- package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Gradient.d.ts +33 -0
- package/lib/typescript/commonjs/ui/components/Gradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Launcher.d.ts +18 -0
- package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Markdown.d.ts +19 -0
- package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts +20 -0
- package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts +26 -0
- package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/icons.d.ts +38 -0
- package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts +33 -0
- package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts +11 -0
- package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts +16 -0
- package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +11 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +349 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +48 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts +10 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +17 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +227 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +40 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts +19 -0
- package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/styles/global.d.ts +46 -0
- package/lib/typescript/commonjs/ui/styles/global.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts +103 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts +41 -0
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts +10 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts +61 -0
- package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/rtl.d.ts +33 -0
- package/lib/typescript/commonjs/ui/utils/rtl.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +21 -0
- package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -0
- package/lib/typescript/module/agent-ui-blocks.d.ts +20 -0
- package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -0
- package/lib/typescript/module/api/client.d.ts +115 -0
- package/lib/typescript/module/api/client.d.ts.map +1 -0
- package/lib/typescript/module/api/realtime.d.ts +39 -0
- package/lib/typescript/module/api/realtime.d.ts.map +1 -0
- package/lib/typescript/module/api/sse-parser.d.ts +13 -0
- package/lib/typescript/module/api/sse-parser.d.ts.map +1 -0
- package/lib/typescript/module/controller.d.ts +15 -0
- package/lib/typescript/module/controller.d.ts.map +1 -0
- package/lib/typescript/module/device-id.d.ts +15 -0
- package/lib/typescript/module/device-id.d.ts.map +1 -0
- package/lib/typescript/module/events.d.ts +41 -0
- package/lib/typescript/module/events.d.ts.map +1 -0
- package/lib/typescript/module/i18n.d.ts +78 -0
- package/lib/typescript/module/i18n.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +103 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/locales.d.ts +18 -0
- package/lib/typescript/module/locales.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/push/push-notifications.d.ts +71 -0
- package/lib/typescript/module/push/push-notifications.d.ts.map +1 -0
- package/lib/typescript/module/state/use-widget-state.d.ts +10 -0
- package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -0
- package/lib/typescript/module/state/widget-store.d.ts +227 -0
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -0
- package/lib/typescript/module/storage.d.ts +42 -0
- package/lib/typescript/module/storage.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +391 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/ui/WidgetProvider.d.ts +15 -0
- package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +27 -0
- package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Avatar.d.ts +19 -0
- package/lib/typescript/module/ui/components/Avatar.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/ConversationRow.d.ts +26 -0
- package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +27 -0
- package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Gradient.d.ts +33 -0
- package/lib/typescript/module/ui/components/Gradient.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Launcher.d.ts +18 -0
- package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Markdown.d.ts +19 -0
- package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts +20 -0
- package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/WidgetPanel.d.ts +26 -0
- package/lib/typescript/module/ui/components/WidgetPanel.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/icons.d.ts +38 -0
- package/lib/typescript/module/ui/components/icons.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts +33 -0
- package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts +11 -0
- package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts +16 -0
- package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +11 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +349 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +48 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts +10 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts +17 -0
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +227 -0
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +40 -0
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/greeting.d.ts +19 -0
- package/lib/typescript/module/ui/screens/home/greeting.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/styles/global.d.ts +46 -0
- package/lib/typescript/module/ui/styles/global.d.ts.map +1 -0
- package/lib/typescript/module/ui/styles/theme.d.ts +103 -0
- package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/conversations.d.ts +41 -0
- package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/html.d.ts +10 -0
- package/lib/typescript/module/ui/utils/html.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/native-gradient.d.ts +61 -0
- package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/rtl.d.ts +33 -0
- package/lib/typescript/module/ui/utils/rtl.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/safe-url.d.ts +21 -0
- package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -0
- package/metro.js +40 -0
- package/package.json +116 -0
- package/src/agent-ui-blocks.ts +302 -0
- package/src/api/client.ts +332 -0
- package/src/api/realtime.ts +225 -0
- package/src/api/sse-parser.ts +51 -0
- package/src/controller.ts +20 -0
- package/src/device-id.ts +71 -0
- package/src/events.ts +74 -0
- package/src/i18n.ts +114 -0
- package/src/index.tsx +199 -0
- package/src/locales.ts +80 -0
- package/src/push/push-notifications.ts +254 -0
- package/src/state/use-widget-state.ts +20 -0
- package/src/state/widget-store.ts +1815 -0
- package/src/storage.ts +153 -0
- package/src/types.ts +445 -0
- package/src/ui/WidgetProvider.tsx +434 -0
- package/src/ui/components/AgentUiBlocks.tsx +912 -0
- package/src/ui/components/Avatar.tsx +86 -0
- package/src/ui/components/ConversationRow.tsx +163 -0
- package/src/ui/components/ErrorBoundary.tsx +49 -0
- package/src/ui/components/Gradient.tsx +165 -0
- package/src/ui/components/Launcher.tsx +128 -0
- package/src/ui/components/Markdown.tsx +291 -0
- package/src/ui/components/OutboundMessageCard.tsx +154 -0
- package/src/ui/components/WidgetPanel.tsx +133 -0
- package/src/ui/components/icons.tsx +315 -0
- package/src/ui/hooks/use-keyboard-overlap.ts +134 -0
- package/src/ui/hooks/use-reduce-motion.ts +39 -0
- package/src/ui/hooks/use-widget-insets.ts +44 -0
- package/src/ui/screens/chat/ChatView.styles.ts +357 -0
- package/src/ui/screens/chat/ChatView.tsx +690 -0
- package/src/ui/screens/chat/ChatView.types.ts +46 -0
- package/src/ui/screens/conversations/ConversationsList.styles.ts +111 -0
- package/src/ui/screens/conversations/ConversationsList.tsx +144 -0
- package/src/ui/screens/conversations/ConversationsList.types.ts +33 -0
- package/src/ui/screens/home/HomeView.styles.ts +246 -0
- package/src/ui/screens/home/HomeView.tsx +336 -0
- package/src/ui/screens/home/HomeView.types.ts +42 -0
- package/src/ui/screens/home/greeting.ts +50 -0
- package/src/ui/screens/pre-chat/PreChatForm.styles.ts +120 -0
- package/src/ui/screens/pre-chat/PreChatForm.tsx +221 -0
- package/src/ui/screens/pre-chat/PreChatForm.types.ts +22 -0
- package/src/ui/styles/global.ts +50 -0
- package/src/ui/styles/theme.ts +155 -0
- package/src/ui/utils/conversations.ts +122 -0
- package/src/ui/utils/html.ts +58 -0
- package/src/ui/utils/native-gradient.ts +60 -0
- package/src/ui/utils/rtl.ts +43 -0
- package/src/ui/utils/safe-url.ts +63 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Home space — branded greeting header, the "start a conversation" card, a
|
|
3
|
+
* preview of recent threads and a team/availability strip.
|
|
4
|
+
* Port of `client/src/widget/components/HomeView.tsx`.
|
|
5
|
+
*
|
|
6
|
+
* The header meets the white body on a straight seam, the same as the web
|
|
7
|
+
* widget. Whether that seam is a hard edge or the background washing out into
|
|
8
|
+
* white is the dashboard's `homeBackgroundFade` toggle, and the start card sits
|
|
9
|
+
* astride it either way: top over the brand background, bottom over white.
|
|
10
|
+
*
|
|
11
|
+
* Everything on this screen comes from the widget config or the conversations
|
|
12
|
+
* the visitor already has; nothing here assumes a field the backend does not
|
|
13
|
+
* send today.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Fragment, useEffect, useRef, type ReactNode } from 'react';
|
|
17
|
+
import {
|
|
18
|
+
Animated,
|
|
19
|
+
Easing,
|
|
20
|
+
Image,
|
|
21
|
+
Pressable,
|
|
22
|
+
ScrollView,
|
|
23
|
+
StyleSheet,
|
|
24
|
+
Text,
|
|
25
|
+
View,
|
|
26
|
+
} from 'react-native';
|
|
27
|
+
|
|
28
|
+
import type { WidgetConfig } from '../../../types';
|
|
29
|
+
import { Avatar } from '../../components/Avatar';
|
|
30
|
+
import { ConversationRow } from '../../components/ConversationRow';
|
|
31
|
+
import { FadeOverlay, GradientBackground } from '../../components/Gradient';
|
|
32
|
+
import {
|
|
33
|
+
AlertIcon,
|
|
34
|
+
ArrowRightIcon,
|
|
35
|
+
ChatIcon,
|
|
36
|
+
ChatOutlineIcon,
|
|
37
|
+
CloseIcon,
|
|
38
|
+
} from '../../components/icons';
|
|
39
|
+
import { useReduceMotion } from '../../hooks/use-reduce-motion';
|
|
40
|
+
import { globalStyles } from '../../styles/global';
|
|
41
|
+
import { contrastingTextColor, palette, spacing, withAlpha } from '../../styles/theme';
|
|
42
|
+
import { flipForRTL } from '../../utils/rtl';
|
|
43
|
+
import { personalizeGreeting } from './greeting';
|
|
44
|
+
import {
|
|
45
|
+
CLOSE_ICON_SIZE,
|
|
46
|
+
HEADER_BOTTOM_PADDING,
|
|
47
|
+
HEADER_FADE_HEIGHT,
|
|
48
|
+
START_CARD_LIFT,
|
|
49
|
+
styles,
|
|
50
|
+
} from './HomeView.styles';
|
|
51
|
+
import type { HomeViewProps } from './HomeView.types';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The admin's explicit black/white toggle always wins. Older configs can omit
|
|
55
|
+
* it, and defaulting to dark text over a dark brand header is unreadable, so
|
|
56
|
+
* derive something legible from the background instead.
|
|
57
|
+
*/
|
|
58
|
+
function resolveHeaderTextColor(config: WidgetConfig | null, fallbackColor: string): string {
|
|
59
|
+
if (config?.homeHeaderTextColor === 'white') return palette.white;
|
|
60
|
+
if (config?.homeHeaderTextColor === 'black') return palette.ink;
|
|
61
|
+
if (config?.homeBackgroundType === 'image') return palette.white;
|
|
62
|
+
if (config?.homeBackgroundType === 'gradient') {
|
|
63
|
+
return contrastingTextColor(config.homeBackgroundGradientStart || fallbackColor);
|
|
64
|
+
}
|
|
65
|
+
return contrastingTextColor(config?.homeBackgroundColor || fallbackColor);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function HomeView({
|
|
69
|
+
config,
|
|
70
|
+
color,
|
|
71
|
+
visitorName,
|
|
72
|
+
conversationCount,
|
|
73
|
+
recentConversations,
|
|
74
|
+
unreadByConversation,
|
|
75
|
+
teamAgents,
|
|
76
|
+
isOnline,
|
|
77
|
+
offlineMessage,
|
|
78
|
+
startConversationLabel,
|
|
79
|
+
replyTimeLabel,
|
|
80
|
+
allowNewConversations,
|
|
81
|
+
showPreviousConversations,
|
|
82
|
+
labels,
|
|
83
|
+
onClose,
|
|
84
|
+
onStartConversation,
|
|
85
|
+
onViewConversations,
|
|
86
|
+
onOpenConversation,
|
|
87
|
+
}: HomeViewProps) {
|
|
88
|
+
const heading = personalizeGreeting(config?.welcomeHeading, visitorName, 'Hi there');
|
|
89
|
+
// Both lines render exactly as the dashboard sent them, so the admin sees the
|
|
90
|
+
// same header in the preview and on the phone, even when the subheading
|
|
91
|
+
// repeats the reply time printed on the start card below.
|
|
92
|
+
const subheading = config?.welcomeSubheading || 'How can we help?';
|
|
93
|
+
|
|
94
|
+
const textColor = resolveHeaderTextColor(config, color);
|
|
95
|
+
const secondaryTextColor =
|
|
96
|
+
textColor === palette.white ? withAlpha(palette.white, 0.8) : 'rgba(26,26,26,0.58)';
|
|
97
|
+
// A pale brand color would otherwise put a white glyph on a near-white disc.
|
|
98
|
+
const startIconColor = contrastingTextColor(color);
|
|
99
|
+
|
|
100
|
+
const backgroundType = config?.homeBackgroundType ?? 'solid';
|
|
101
|
+
const gradientColors = [
|
|
102
|
+
config?.homeBackgroundGradientStart || '#f2f2f2',
|
|
103
|
+
config?.homeBackgroundGradientMiddle || '',
|
|
104
|
+
config?.homeBackgroundGradientEnd || '#bfbfbf',
|
|
105
|
+
].filter(Boolean);
|
|
106
|
+
// Off, the background stops dead at the seam. On, it washes out into the body
|
|
107
|
+
// colour over the bottom of the header, so the start card lands on near-white.
|
|
108
|
+
const fade = config?.homeBackgroundFade ? <FadeOverlay height={HEADER_FADE_HEIGHT} /> : null;
|
|
109
|
+
|
|
110
|
+
const showRecent = showPreviousConversations && recentConversations.length > 0;
|
|
111
|
+
const showViewAll = conversationCount > recentConversations.length;
|
|
112
|
+
const showEmptyHint =
|
|
113
|
+
showPreviousConversations && conversationCount === 0 && allowNewConversations;
|
|
114
|
+
// One agent already has their face in the row above; repeating it reads as a bug.
|
|
115
|
+
const showAvatarStack = teamAgents.length >= 2;
|
|
116
|
+
|
|
117
|
+
// The start card is pulled up over the seam by a fixed amount, so the header
|
|
118
|
+
// pads its bottom by that same amount and the greeting never slides under it.
|
|
119
|
+
const headerStyle = [
|
|
120
|
+
styles.header,
|
|
121
|
+
allowNewConversations ? { paddingBottom: HEADER_BOTTOM_PADDING + START_CARD_LIFT } : null,
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
const headerContent = (
|
|
125
|
+
<>
|
|
126
|
+
<View style={styles.headerTop}>
|
|
127
|
+
{config?.homeLogoUrl ? (
|
|
128
|
+
<Image
|
|
129
|
+
source={{ uri: config.homeLogoUrl }}
|
|
130
|
+
style={styles.logo}
|
|
131
|
+
resizeMode="contain"
|
|
132
|
+
accessibilityIgnoresInvertColors
|
|
133
|
+
/>
|
|
134
|
+
) : (
|
|
135
|
+
<View />
|
|
136
|
+
)}
|
|
137
|
+
<Pressable
|
|
138
|
+
onPress={onClose}
|
|
139
|
+
accessibilityRole="button"
|
|
140
|
+
accessibilityLabel={labels.close}
|
|
141
|
+
hitSlop={12}
|
|
142
|
+
style={styles.closeButton}>
|
|
143
|
+
<CloseIcon size={CLOSE_ICON_SIZE} color={textColor} />
|
|
144
|
+
</Pressable>
|
|
145
|
+
</View>
|
|
146
|
+
<View style={styles.headerSpacer} />
|
|
147
|
+
<FadeSlideIn>
|
|
148
|
+
<Text style={[styles.heading, { color: textColor }]}>{heading}</Text>
|
|
149
|
+
<Text style={[styles.subheading, { color: secondaryTextColor }]}>{subheading}</Text>
|
|
150
|
+
</FadeSlideIn>
|
|
151
|
+
</>
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<ScrollView
|
|
156
|
+
style={globalStyles.screen}
|
|
157
|
+
contentContainerStyle={styles.contentContainer}
|
|
158
|
+
keyboardShouldPersistTaps="handled">
|
|
159
|
+
{backgroundType === 'image' && config?.homeBackgroundImageUrl ? (
|
|
160
|
+
<View style={headerStyle}>
|
|
161
|
+
<Image
|
|
162
|
+
source={{ uri: config.homeBackgroundImageUrl }}
|
|
163
|
+
style={StyleSheet.absoluteFill}
|
|
164
|
+
resizeMode="cover"
|
|
165
|
+
accessibilityIgnoresInvertColors
|
|
166
|
+
/>
|
|
167
|
+
<View style={styles.imageScrim} />
|
|
168
|
+
{headerContent}
|
|
169
|
+
{fade}
|
|
170
|
+
</View>
|
|
171
|
+
) : backgroundType === 'gradient' ? (
|
|
172
|
+
<GradientBackground colors={gradientColors} style={headerStyle}>
|
|
173
|
+
{headerContent}
|
|
174
|
+
{fade}
|
|
175
|
+
</GradientBackground>
|
|
176
|
+
) : (
|
|
177
|
+
<View style={[headerStyle, { backgroundColor: config?.homeBackgroundColor || '#f2f2f2' }]}>
|
|
178
|
+
{headerContent}
|
|
179
|
+
{fade}
|
|
180
|
+
</View>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
<View style={styles.body}>
|
|
184
|
+
{allowNewConversations ? (
|
|
185
|
+
<View style={styles.startCardSlot}>
|
|
186
|
+
<FadeSlideIn delay={40}>
|
|
187
|
+
<Pressable
|
|
188
|
+
onPress={onStartConversation}
|
|
189
|
+
accessibilityRole="button"
|
|
190
|
+
android_ripple={{ color: palette.borderSoft }}
|
|
191
|
+
style={({ pressed }) => [styles.startCard, pressed && styles.startCardPressed]}>
|
|
192
|
+
<View style={[styles.startIcon, { backgroundColor: color }]}>
|
|
193
|
+
<ChatIcon size={18} color={startIconColor} />
|
|
194
|
+
</View>
|
|
195
|
+
<View style={styles.startCopy}>
|
|
196
|
+
<Text style={styles.startTitle}>{startConversationLabel}</Text>
|
|
197
|
+
<Text style={styles.startSubtitle}>{replyTimeLabel}</Text>
|
|
198
|
+
</View>
|
|
199
|
+
<ArrowRightIcon size={18} color={color} style={flipForRTL()} />
|
|
200
|
+
</Pressable>
|
|
201
|
+
</FadeSlideIn>
|
|
202
|
+
</View>
|
|
203
|
+
) : null}
|
|
204
|
+
|
|
205
|
+
<View style={styles.bodyContent}>
|
|
206
|
+
{offlineMessage ? (
|
|
207
|
+
<FadeSlideIn delay={70}>
|
|
208
|
+
<View style={styles.offlineNotice}>
|
|
209
|
+
<AlertIcon size={18} />
|
|
210
|
+
<Text style={styles.offlineText}>{offlineMessage}</Text>
|
|
211
|
+
</View>
|
|
212
|
+
</FadeSlideIn>
|
|
213
|
+
) : null}
|
|
214
|
+
|
|
215
|
+
{showRecent ? (
|
|
216
|
+
<FadeSlideIn delay={140}>
|
|
217
|
+
<View style={styles.recentHeader}>
|
|
218
|
+
<Text style={styles.recentTitle}>{labels.recentTitle}</Text>
|
|
219
|
+
{showViewAll ? (
|
|
220
|
+
<Pressable
|
|
221
|
+
onPress={onViewConversations}
|
|
222
|
+
accessibilityRole="button"
|
|
223
|
+
accessibilityLabel={labels.viewPrevious}
|
|
224
|
+
hitSlop={10}
|
|
225
|
+
style={({ pressed }) => [
|
|
226
|
+
styles.viewAllButton,
|
|
227
|
+
pressed && globalStyles.pressed,
|
|
228
|
+
]}>
|
|
229
|
+
<Text style={[styles.viewAllLabel, { color }]}>{labels.viewAll}</Text>
|
|
230
|
+
</Pressable>
|
|
231
|
+
) : null}
|
|
232
|
+
</View>
|
|
233
|
+
<View style={[globalStyles.card, styles.recentCard]}>
|
|
234
|
+
{recentConversations.map((conversation, index) => (
|
|
235
|
+
<Fragment key={conversation.id}>
|
|
236
|
+
{index > 0 ? (
|
|
237
|
+
<View style={[globalStyles.divider, styles.recentDivider]} />
|
|
238
|
+
) : null}
|
|
239
|
+
<ConversationRow
|
|
240
|
+
conversation={conversation}
|
|
241
|
+
color={color}
|
|
242
|
+
fallbackName={labels.team}
|
|
243
|
+
timeLabels={labels.time}
|
|
244
|
+
unreadCount={unreadByConversation[conversation.id] ?? 0}
|
|
245
|
+
unreadLabel={labels.unread}
|
|
246
|
+
horizontalPadding={spacing.lg}
|
|
247
|
+
onPress={() => onOpenConversation(conversation.id)}
|
|
248
|
+
/>
|
|
249
|
+
</Fragment>
|
|
250
|
+
))}
|
|
251
|
+
</View>
|
|
252
|
+
</FadeSlideIn>
|
|
253
|
+
) : null}
|
|
254
|
+
|
|
255
|
+
<View style={styles.spacer}>
|
|
256
|
+
{showEmptyHint ? (
|
|
257
|
+
<FadeSlideIn delay={140}>
|
|
258
|
+
<View style={styles.emptyHint}>
|
|
259
|
+
<ChatOutlineIcon size={30} color={palette.disabled} />
|
|
260
|
+
<Text style={styles.emptyHintText}>{labels.noConversations}</Text>
|
|
261
|
+
</View>
|
|
262
|
+
</FadeSlideIn>
|
|
263
|
+
) : null}
|
|
264
|
+
</View>
|
|
265
|
+
|
|
266
|
+
<FadeSlideIn delay={200}>
|
|
267
|
+
<View style={styles.statusStrip}>
|
|
268
|
+
{showAvatarStack ? (
|
|
269
|
+
<View style={styles.avatarStack}>
|
|
270
|
+
{teamAgents.map((agent, index) => (
|
|
271
|
+
<Avatar
|
|
272
|
+
key={`${agent.name ?? 'agent'}-${index}`}
|
|
273
|
+
avatar={agent.avatar}
|
|
274
|
+
name={agent.name}
|
|
275
|
+
size={26}
|
|
276
|
+
color={color}
|
|
277
|
+
style={[styles.avatarStackItem, index > 0 ? styles.avatarStackOverlap : null]}
|
|
278
|
+
/>
|
|
279
|
+
))}
|
|
280
|
+
</View>
|
|
281
|
+
) : null}
|
|
282
|
+
<View
|
|
283
|
+
style={[
|
|
284
|
+
styles.statusDot,
|
|
285
|
+
{ backgroundColor: isOnline ? palette.online : palette.textSubtle },
|
|
286
|
+
]}
|
|
287
|
+
/>
|
|
288
|
+
<Text style={styles.statusText} numberOfLines={1}>
|
|
289
|
+
{isOnline ? labels.statusOnline : labels.statusAway}
|
|
290
|
+
</Text>
|
|
291
|
+
</View>
|
|
292
|
+
</FadeSlideIn>
|
|
293
|
+
</View>
|
|
294
|
+
</View>
|
|
295
|
+
</ScrollView>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Staggered entrance for the body sections. Opacity and translate only, so the
|
|
301
|
+
* whole thing runs on the native driver and never touches layout.
|
|
302
|
+
*/
|
|
303
|
+
function FadeSlideIn({ delay = 0, children }: { delay?: number; children: ReactNode }) {
|
|
304
|
+
const reduceMotion = useReduceMotion();
|
|
305
|
+
const progress = useRef(new Animated.Value(0)).current;
|
|
306
|
+
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
// `null` means the reduce-motion answer has not landed yet; hold at 0
|
|
309
|
+
// rather than animating and snapping back.
|
|
310
|
+
if (reduceMotion === null) return undefined;
|
|
311
|
+
if (reduceMotion) {
|
|
312
|
+
progress.setValue(1);
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
Animated.timing(progress, {
|
|
317
|
+
toValue: 1,
|
|
318
|
+
duration: 260,
|
|
319
|
+
delay,
|
|
320
|
+
easing: Easing.out(Easing.quad),
|
|
321
|
+
useNativeDriver: true,
|
|
322
|
+
}).start();
|
|
323
|
+
|
|
324
|
+
return () => {
|
|
325
|
+
progress.stopAnimation();
|
|
326
|
+
};
|
|
327
|
+
}, [delay, progress, reduceMotion]);
|
|
328
|
+
|
|
329
|
+
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [12, 0] });
|
|
330
|
+
|
|
331
|
+
return (
|
|
332
|
+
<Animated.View style={{ opacity: progress, transform: [{ translateY }] }}>
|
|
333
|
+
{children}
|
|
334
|
+
</Animated.View>
|
|
335
|
+
);
|
|
336
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Props and label bundle for the Home space. */
|
|
2
|
+
|
|
3
|
+
import type { Conversation, WidgetConfig } from '../../../types';
|
|
4
|
+
import type { RelativeTimeLabels, TeamAgent } from '../../utils/conversations';
|
|
5
|
+
|
|
6
|
+
export interface HomeViewLabels {
|
|
7
|
+
close: string;
|
|
8
|
+
/** Accessibility label for the "view all" control. */
|
|
9
|
+
viewPrevious: string;
|
|
10
|
+
viewAll: string;
|
|
11
|
+
recentTitle: string;
|
|
12
|
+
noConversations: string;
|
|
13
|
+
statusOnline: string;
|
|
14
|
+
statusAway: string;
|
|
15
|
+
/** Stand-in name while a conversation has no agent assigned. */
|
|
16
|
+
team: string;
|
|
17
|
+
time: RelativeTimeLabels;
|
|
18
|
+
/** Template with a `{count}` token. */
|
|
19
|
+
unread: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface HomeViewProps {
|
|
23
|
+
config: WidgetConfig | null;
|
|
24
|
+
color: string;
|
|
25
|
+
visitorName?: string;
|
|
26
|
+
conversationCount: number;
|
|
27
|
+
/** Already sorted newest-first and capped by the provider. */
|
|
28
|
+
recentConversations: Conversation[];
|
|
29
|
+
unreadByConversation: Record<string, number>;
|
|
30
|
+
teamAgents: TeamAgent[];
|
|
31
|
+
isOnline: boolean;
|
|
32
|
+
offlineMessage?: string;
|
|
33
|
+
startConversationLabel: string;
|
|
34
|
+
replyTimeLabel: string;
|
|
35
|
+
allowNewConversations: boolean;
|
|
36
|
+
showPreviousConversations: boolean;
|
|
37
|
+
labels: HomeViewLabels;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
onStartConversation: () => void;
|
|
40
|
+
onViewConversations: () => void;
|
|
41
|
+
onOpenConversation: (conversationId: string) => void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Greeting helpers for the Home space. The admin's heading renders exactly as
|
|
3
|
+
* the dashboard sent it, with one exception: an explicit name token, which is
|
|
4
|
+
* the admin asking for the visitor's first name to be filled in.
|
|
5
|
+
* Deliberately free of React and React Native so they stay trivial to test.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** `{{name}}`, `{name}`, `{{first_name}}` all stand in for the visitor's first name. */
|
|
9
|
+
const NAME_TOKEN = /\{\{?\s*(?:name|first_?name)\s*\}?\}/gi;
|
|
10
|
+
|
|
11
|
+
const EMAIL_LIKE = /@/;
|
|
12
|
+
const PHONE_LIKE = /^[\d\s+()\-.]+$/;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* First name suitable for greeting someone by. Hosts sometimes put an email or
|
|
16
|
+
* a phone number in the name field, and greeting "Hi rep@acme.com" is worse
|
|
17
|
+
* than not personalizing at all.
|
|
18
|
+
*/
|
|
19
|
+
export function firstName(fullName?: string | null): string | null {
|
|
20
|
+
const trimmed = (fullName ?? '').trim();
|
|
21
|
+
if (!trimmed || EMAIL_LIKE.test(trimmed) || PHONE_LIKE.test(trimmed)) return null;
|
|
22
|
+
const candidate = (trimmed.split(/\s+/)[0] ?? '').replace(/[,;:.]+$/, '');
|
|
23
|
+
// Under 2 rejects a bare initial; over 24 means a sentence landed in the field.
|
|
24
|
+
if (candidate.length < 2 || candidate.length > 24) return null;
|
|
25
|
+
return candidate;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Repair the spacing and punctuation left behind when a token resolves to nothing. */
|
|
29
|
+
function tidy(value: string): string {
|
|
30
|
+
return value
|
|
31
|
+
.replace(/\s+/g, ' ')
|
|
32
|
+
.replace(/\s+([,!?.:;])/g, '$1')
|
|
33
|
+
.replace(/^[\s,]+/, '')
|
|
34
|
+
.trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the admin's heading against the visitor's name. Only an explicit
|
|
39
|
+
* token is substituted: a generic "Hi there" stays "Hi there", because that is
|
|
40
|
+
* what the dashboard preview shows the admin and the phone has to match it.
|
|
41
|
+
*/
|
|
42
|
+
export function personalizeGreeting(
|
|
43
|
+
template: string | null | undefined,
|
|
44
|
+
visitorName: string | null | undefined,
|
|
45
|
+
fallback: string
|
|
46
|
+
): string {
|
|
47
|
+
const base = (template ?? '').trim() || fallback;
|
|
48
|
+
const tokenized = base.replace(NAME_TOKEN, firstName(visitorName) ?? '');
|
|
49
|
+
return tokenized === base ? base : tidy(tokenized);
|
|
50
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** Styles for the pre-chat form: brand header, fields and the skip/submit row. */
|
|
2
|
+
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { fontSize, palette, radius, spacing } from '../../styles/theme';
|
|
6
|
+
import { START_ALIGN } from '../../utils/rtl';
|
|
7
|
+
|
|
8
|
+
export const styles = StyleSheet.create({
|
|
9
|
+
header: {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'flex-start',
|
|
12
|
+
gap: spacing.md,
|
|
13
|
+
paddingHorizontal: spacing.xl,
|
|
14
|
+
paddingVertical: spacing.lg,
|
|
15
|
+
minHeight: 96,
|
|
16
|
+
},
|
|
17
|
+
headerCopy: {
|
|
18
|
+
flex: 1,
|
|
19
|
+
minWidth: 0,
|
|
20
|
+
},
|
|
21
|
+
headerTitle: {
|
|
22
|
+
textAlign: START_ALIGN,
|
|
23
|
+
fontSize: fontSize.heading,
|
|
24
|
+
fontWeight: '700',
|
|
25
|
+
marginBottom: spacing.xs,
|
|
26
|
+
},
|
|
27
|
+
headerSubtitle: {
|
|
28
|
+
textAlign: START_ALIGN,
|
|
29
|
+
fontSize: fontSize.meta,
|
|
30
|
+
lineHeight: fontSize.meta * 1.4,
|
|
31
|
+
},
|
|
32
|
+
content: {
|
|
33
|
+
flexGrow: 1,
|
|
34
|
+
padding: spacing.xxl,
|
|
35
|
+
},
|
|
36
|
+
field: {
|
|
37
|
+
marginBottom: spacing.lg,
|
|
38
|
+
},
|
|
39
|
+
label: {
|
|
40
|
+
textAlign: START_ALIGN,
|
|
41
|
+
fontSize: fontSize.meta,
|
|
42
|
+
fontWeight: '600',
|
|
43
|
+
color: '#374151',
|
|
44
|
+
marginBottom: spacing.xs,
|
|
45
|
+
},
|
|
46
|
+
required: {
|
|
47
|
+
color: palette.danger,
|
|
48
|
+
},
|
|
49
|
+
input: {
|
|
50
|
+
textAlign: START_ALIGN,
|
|
51
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
52
|
+
borderColor: palette.disabled,
|
|
53
|
+
borderRadius: radius.sm,
|
|
54
|
+
paddingHorizontal: spacing.md,
|
|
55
|
+
paddingVertical: spacing.sm + 2,
|
|
56
|
+
fontSize: fontSize.input,
|
|
57
|
+
color: palette.ink,
|
|
58
|
+
minHeight: 46,
|
|
59
|
+
},
|
|
60
|
+
inputError: {
|
|
61
|
+
borderColor: palette.danger,
|
|
62
|
+
},
|
|
63
|
+
options: {
|
|
64
|
+
gap: spacing.sm,
|
|
65
|
+
},
|
|
66
|
+
option: {
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
justifyContent: 'space-between',
|
|
70
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
71
|
+
borderColor: palette.disabled,
|
|
72
|
+
borderRadius: radius.sm,
|
|
73
|
+
paddingHorizontal: spacing.md,
|
|
74
|
+
paddingVertical: spacing.md,
|
|
75
|
+
minHeight: 46,
|
|
76
|
+
},
|
|
77
|
+
optionLabel: {
|
|
78
|
+
fontSize: fontSize.body,
|
|
79
|
+
color: palette.ink,
|
|
80
|
+
},
|
|
81
|
+
errorText: {
|
|
82
|
+
textAlign: START_ALIGN,
|
|
83
|
+
fontSize: fontSize.caption,
|
|
84
|
+
color: palette.danger,
|
|
85
|
+
marginTop: spacing.xs,
|
|
86
|
+
},
|
|
87
|
+
actions: {
|
|
88
|
+
flexDirection: 'row',
|
|
89
|
+
gap: spacing.sm,
|
|
90
|
+
marginTop: spacing.lg,
|
|
91
|
+
},
|
|
92
|
+
skipButton: {
|
|
93
|
+
flex: 1,
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
justifyContent: 'center',
|
|
96
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
97
|
+
borderColor: palette.disabled,
|
|
98
|
+
borderRadius: radius.sm,
|
|
99
|
+
paddingVertical: spacing.md,
|
|
100
|
+
minHeight: 46,
|
|
101
|
+
},
|
|
102
|
+
skipLabel: {
|
|
103
|
+
fontSize: fontSize.body,
|
|
104
|
+
fontWeight: '600',
|
|
105
|
+
color: '#374151',
|
|
106
|
+
},
|
|
107
|
+
submitButton: {
|
|
108
|
+
flex: 1,
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
justifyContent: 'center',
|
|
111
|
+
borderRadius: radius.sm,
|
|
112
|
+
paddingVertical: spacing.md,
|
|
113
|
+
minHeight: 46,
|
|
114
|
+
},
|
|
115
|
+
submitLabel: {
|
|
116
|
+
fontSize: fontSize.body,
|
|
117
|
+
fontWeight: '600',
|
|
118
|
+
color: palette.white,
|
|
119
|
+
},
|
|
120
|
+
});
|