@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,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Markdown renderer for agent replies.
|
|
3
|
+
*
|
|
4
|
+
* The web widget uses react-markdown + remark-gfm; this SDK ships no runtime
|
|
5
|
+
* dependencies, so it supports the subset agents actually emit: paragraphs,
|
|
6
|
+
* bullet/numbered lists, bold, italic, inline code, fenced code and links
|
|
7
|
+
* (including bare URLs, linkified the same way the web widget does).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Fragment } from 'react';
|
|
11
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
12
|
+
|
|
13
|
+
import { fontSize, palette, radius, spacing } from '../styles/theme';
|
|
14
|
+
import { openExternalUrl } from '../utils/safe-url';
|
|
15
|
+
|
|
16
|
+
// File-like extensions we should NOT treat as clickable domains (e.g. "report.pdf").
|
|
17
|
+
const NON_LINK_EXTENSIONS = new Set([
|
|
18
|
+
'pdf',
|
|
19
|
+
'png',
|
|
20
|
+
'jpg',
|
|
21
|
+
'jpeg',
|
|
22
|
+
'gif',
|
|
23
|
+
'svg',
|
|
24
|
+
'webp',
|
|
25
|
+
'doc',
|
|
26
|
+
'docx',
|
|
27
|
+
'xls',
|
|
28
|
+
'xlsx',
|
|
29
|
+
'csv',
|
|
30
|
+
'txt',
|
|
31
|
+
'zip',
|
|
32
|
+
'rar',
|
|
33
|
+
'js',
|
|
34
|
+
'ts',
|
|
35
|
+
'tsx',
|
|
36
|
+
'jsx',
|
|
37
|
+
'json',
|
|
38
|
+
'md',
|
|
39
|
+
'html',
|
|
40
|
+
'css',
|
|
41
|
+
'exe',
|
|
42
|
+
'dmg',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
function linkifyPlainText(text: string): string {
|
|
46
|
+
const urlRe = /((?:https?:\/\/|www\.)[^\s<>()]+|(?:[a-z0-9-]+\.)+[a-z]{2,24}(?:\/[^\s<>()]*)?)/gi;
|
|
47
|
+
return text.replace(urlRe, (match) => {
|
|
48
|
+
const trailingMatch = match.match(/[.,!?;:)\]]+$/);
|
|
49
|
+
const tail = trailingMatch ? trailingMatch[0] : '';
|
|
50
|
+
const core = tail ? match.slice(0, -tail.length) : match;
|
|
51
|
+
const hasScheme = /^https?:\/\//i.test(core);
|
|
52
|
+
if (!hasScheme && !/\//.test(core)) {
|
|
53
|
+
const ext = core.split('.').pop()?.toLowerCase() ?? '';
|
|
54
|
+
if (NON_LINK_EXTENSIONS.has(ext)) return match;
|
|
55
|
+
}
|
|
56
|
+
const href = hasScheme ? core : `https://${core.replace(/^www\./i, '')}`;
|
|
57
|
+
return `[${core}](${href})${tail}`;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Turn bare URLs into markdown links while leaving code and existing links alone. */
|
|
62
|
+
export function linkifyMarkdown(text: string): string {
|
|
63
|
+
if (!text) return text;
|
|
64
|
+
const protectedPattern = /(```[\s\S]*?```|`[^`]*`|!?\[[^\]]*\]\([^)]*\))/g;
|
|
65
|
+
return text
|
|
66
|
+
.split(protectedPattern)
|
|
67
|
+
.map((segment, index) => (index % 2 === 1 ? segment : linkifyPlainText(segment)))
|
|
68
|
+
.join('');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const INLINE_PATTERN =
|
|
72
|
+
/(\*\*[^*]+\*\*|__[^_]+__|\*[^*\n]+\*|_[^_\n]+_|`[^`]+`|!?\[[^\]]*\]\([^)]*\))/g;
|
|
73
|
+
|
|
74
|
+
function openLink(href: string) {
|
|
75
|
+
void openExternalUrl(href);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Renders one line of markdown into nested <Text> runs. */
|
|
79
|
+
function InlineMarkdown({ content, color }: { content: string; color: string }) {
|
|
80
|
+
const parts = content.split(INLINE_PATTERN).filter((part) => part !== undefined && part !== '');
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<>
|
|
84
|
+
{parts.map((part, index) => {
|
|
85
|
+
const key = `${index}-${part.slice(0, 8)}`;
|
|
86
|
+
|
|
87
|
+
if (/^(\*\*|__)[\s\S]+(\*\*|__)$/.test(part)) {
|
|
88
|
+
return (
|
|
89
|
+
<Text key={key} style={styles.bold}>
|
|
90
|
+
{part.slice(2, -2)}
|
|
91
|
+
</Text>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (/^[*_][^*_][\s\S]*[*_]$/.test(part) && part.length > 2) {
|
|
95
|
+
return (
|
|
96
|
+
<Text key={key} style={styles.italic}>
|
|
97
|
+
{part.slice(1, -1)}
|
|
98
|
+
</Text>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (/^`[^`]+`$/.test(part)) {
|
|
102
|
+
return (
|
|
103
|
+
<Text key={key} style={styles.inlineCode}>
|
|
104
|
+
{part.slice(1, -1)}
|
|
105
|
+
</Text>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const link = /^!?\[([^\]]*)\]\(([^)]*)\)$/.exec(part);
|
|
110
|
+
if (link) {
|
|
111
|
+
const label = link[1] || link[2] || '';
|
|
112
|
+
const href = link[2] || '';
|
|
113
|
+
return (
|
|
114
|
+
<Text
|
|
115
|
+
key={key}
|
|
116
|
+
style={[styles.link, { color }]}
|
|
117
|
+
onPress={href ? () => openLink(href) : undefined}>
|
|
118
|
+
{label}
|
|
119
|
+
</Text>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return <Fragment key={key}>{part}</Fragment>;
|
|
124
|
+
})}
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface MarkdownProps {
|
|
130
|
+
content: string;
|
|
131
|
+
color: string;
|
|
132
|
+
/** Link color — defaults to the text color with an underline. */
|
|
133
|
+
linkColor?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function Markdown({ content, color, linkColor }: MarkdownProps) {
|
|
137
|
+
const blocks = parseBlocks(linkifyMarkdown(content));
|
|
138
|
+
const effectiveLinkColor = linkColor ?? color;
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<View>
|
|
142
|
+
{blocks.map((block, index) => {
|
|
143
|
+
const key = `block-${index}`;
|
|
144
|
+
|
|
145
|
+
if (block.type === 'code') {
|
|
146
|
+
return (
|
|
147
|
+
<View key={key} style={styles.codeBlock}>
|
|
148
|
+
<Text style={styles.codeBlockText}>{block.lines.join('\n')}</Text>
|
|
149
|
+
</View>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (block.type === 'list') {
|
|
154
|
+
return (
|
|
155
|
+
<View key={key} style={styles.list}>
|
|
156
|
+
{block.items.map((item, itemIndex) => (
|
|
157
|
+
<View key={`${key}-${itemIndex}`} style={styles.listItem}>
|
|
158
|
+
<Text style={[styles.listMarker, { color }]}>
|
|
159
|
+
{block.ordered ? `${itemIndex + 1}.` : '•'}
|
|
160
|
+
</Text>
|
|
161
|
+
<Text style={[styles.text, styles.listItemText, { color }]}>
|
|
162
|
+
<InlineMarkdown content={item} color={effectiveLinkColor} />
|
|
163
|
+
</Text>
|
|
164
|
+
</View>
|
|
165
|
+
))}
|
|
166
|
+
</View>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<Text key={key} style={[styles.text, index > 0 && styles.paragraphSpacing, { color }]}>
|
|
172
|
+
<InlineMarkdown content={block.lines.join('\n')} color={effectiveLinkColor} />
|
|
173
|
+
</Text>
|
|
174
|
+
);
|
|
175
|
+
})}
|
|
176
|
+
</View>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
type Block =
|
|
181
|
+
| { type: 'paragraph'; lines: string[] }
|
|
182
|
+
| { type: 'code'; lines: string[] }
|
|
183
|
+
| { type: 'list'; ordered: boolean; items: string[] };
|
|
184
|
+
|
|
185
|
+
function parseBlocks(content: string): Block[] {
|
|
186
|
+
const lines = content.split('\n');
|
|
187
|
+
const blocks: Block[] = [];
|
|
188
|
+
let paragraph: string[] = [];
|
|
189
|
+
|
|
190
|
+
const flushParagraph = () => {
|
|
191
|
+
if (paragraph.length > 0) {
|
|
192
|
+
blocks.push({ type: 'paragraph', lines: paragraph });
|
|
193
|
+
paragraph = [];
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
198
|
+
const line = lines[index] as string;
|
|
199
|
+
|
|
200
|
+
if (line.trim().startsWith('```')) {
|
|
201
|
+
flushParagraph();
|
|
202
|
+
const code: string[] = [];
|
|
203
|
+
index += 1;
|
|
204
|
+
while (index < lines.length && !(lines[index] as string).trim().startsWith('```')) {
|
|
205
|
+
code.push(lines[index] as string);
|
|
206
|
+
index += 1;
|
|
207
|
+
}
|
|
208
|
+
blocks.push({ type: 'code', lines: code });
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const bullet = /^\s*[-*+]\s+(.*)$/.exec(line);
|
|
213
|
+
const ordered = /^\s*\d+[.)]\s+(.*)$/.exec(line);
|
|
214
|
+
if (bullet || ordered) {
|
|
215
|
+
flushParagraph();
|
|
216
|
+
const isOrdered = !!ordered;
|
|
217
|
+
const items: string[] = [(bullet?.[1] ?? ordered?.[1] ?? '').trim()];
|
|
218
|
+
while (index + 1 < lines.length) {
|
|
219
|
+
const nextLine = lines[index + 1] as string;
|
|
220
|
+
const nextMatch = isOrdered
|
|
221
|
+
? /^\s*\d+[.)]\s+(.*)$/.exec(nextLine)
|
|
222
|
+
: /^\s*[-*+]\s+(.*)$/.exec(nextLine);
|
|
223
|
+
if (!nextMatch) break;
|
|
224
|
+
items.push((nextMatch[1] ?? '').trim());
|
|
225
|
+
index += 1;
|
|
226
|
+
}
|
|
227
|
+
blocks.push({ type: 'list', ordered: isOrdered, items });
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (line.trim() === '') {
|
|
232
|
+
flushParagraph();
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Headings render as emphasised paragraphs — the bubble is already small.
|
|
237
|
+
paragraph.push(line.replace(/^#{1,6}\s+/, ''));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
flushParagraph();
|
|
241
|
+
return blocks;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const styles = StyleSheet.create({
|
|
245
|
+
text: {
|
|
246
|
+
fontSize: fontSize.body,
|
|
247
|
+
lineHeight: fontSize.body * 1.45,
|
|
248
|
+
},
|
|
249
|
+
paragraphSpacing: {
|
|
250
|
+
marginTop: spacing.sm,
|
|
251
|
+
},
|
|
252
|
+
bold: {
|
|
253
|
+
fontWeight: '700',
|
|
254
|
+
},
|
|
255
|
+
italic: {
|
|
256
|
+
fontStyle: 'italic',
|
|
257
|
+
},
|
|
258
|
+
link: {
|
|
259
|
+
textDecorationLine: 'underline',
|
|
260
|
+
},
|
|
261
|
+
inlineCode: {
|
|
262
|
+
fontFamily: 'Courier',
|
|
263
|
+
fontSize: fontSize.meta,
|
|
264
|
+
},
|
|
265
|
+
codeBlock: {
|
|
266
|
+
marginTop: spacing.sm,
|
|
267
|
+
padding: spacing.sm,
|
|
268
|
+
borderRadius: radius.sm,
|
|
269
|
+
backgroundColor: 'rgba(0,0,0,0.06)',
|
|
270
|
+
},
|
|
271
|
+
codeBlockText: {
|
|
272
|
+
fontFamily: 'Courier',
|
|
273
|
+
fontSize: fontSize.meta,
|
|
274
|
+
color: palette.text,
|
|
275
|
+
},
|
|
276
|
+
list: {
|
|
277
|
+
marginTop: spacing.xs,
|
|
278
|
+
},
|
|
279
|
+
listItem: {
|
|
280
|
+
flexDirection: 'row',
|
|
281
|
+
marginBottom: spacing.xs,
|
|
282
|
+
},
|
|
283
|
+
listItemText: {
|
|
284
|
+
flex: 1,
|
|
285
|
+
},
|
|
286
|
+
listMarker: {
|
|
287
|
+
fontSize: fontSize.body,
|
|
288
|
+
lineHeight: fontSize.body * 1.45,
|
|
289
|
+
width: 20,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proactive / campaign card shown above the home + messages spaces.
|
|
3
|
+
* Port of `client/src/widget/components/OutboundMessageCard.tsx`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Image, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
7
|
+
|
|
8
|
+
import type { OutboundMessage } from '../../types';
|
|
9
|
+
import { htmlToText } from '../utils/html';
|
|
10
|
+
import { openExternalUrl } from '../utils/safe-url';
|
|
11
|
+
import { CloseIcon } from './icons';
|
|
12
|
+
import { START_ALIGN } from '../utils/rtl';
|
|
13
|
+
import { fontSize, palette, radius, shadows, spacing } from '../styles/theme';
|
|
14
|
+
|
|
15
|
+
interface OutboundMessageCardProps {
|
|
16
|
+
message: OutboundMessage;
|
|
17
|
+
color: string;
|
|
18
|
+
labels: { title: string; cta: string; dismiss: string };
|
|
19
|
+
onDismiss: () => void;
|
|
20
|
+
onStartChat: (prefill?: string) => void;
|
|
21
|
+
onTrack?: (event: string, metadata?: Record<string, unknown>) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function OutboundMessageCard({
|
|
25
|
+
message,
|
|
26
|
+
color,
|
|
27
|
+
labels,
|
|
28
|
+
onDismiss,
|
|
29
|
+
onStartChat,
|
|
30
|
+
onTrack,
|
|
31
|
+
}: OutboundMessageCardProps) {
|
|
32
|
+
const ctaLabel = message.ctaLabel || labels.cta;
|
|
33
|
+
const body = message.body || htmlToText(message.bodyHtml || '');
|
|
34
|
+
|
|
35
|
+
const handlePress = () => {
|
|
36
|
+
onTrack?.('widget_outbound_clicked', {
|
|
37
|
+
outboundId: message.id,
|
|
38
|
+
type: message.type,
|
|
39
|
+
hasCtaUrl: !!message.ctaUrl,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (message.ctaUrl) {
|
|
43
|
+
void openExternalUrl(message.ctaUrl);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
onStartChat(htmlToText(message.prefill || '') || body);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View style={styles.wrapper}>
|
|
51
|
+
<View style={styles.card}>
|
|
52
|
+
{message.imageUrl ? (
|
|
53
|
+
<Image
|
|
54
|
+
source={{ uri: message.imageUrl }}
|
|
55
|
+
style={styles.image}
|
|
56
|
+
resizeMode="cover"
|
|
57
|
+
accessibilityIgnoresInvertColors
|
|
58
|
+
/>
|
|
59
|
+
) : null}
|
|
60
|
+
<View style={styles.body}>
|
|
61
|
+
<View style={styles.header}>
|
|
62
|
+
<View style={styles.headerCopy}>
|
|
63
|
+
<Text style={styles.title}>{message.title || labels.title}</Text>
|
|
64
|
+
{body ? <Text style={styles.description}>{body}</Text> : null}
|
|
65
|
+
</View>
|
|
66
|
+
<Pressable
|
|
67
|
+
onPress={onDismiss}
|
|
68
|
+
accessibilityRole="button"
|
|
69
|
+
accessibilityLabel={labels.dismiss}
|
|
70
|
+
hitSlop={12}
|
|
71
|
+
style={styles.dismiss}>
|
|
72
|
+
<CloseIcon size={16} color={palette.textSubtle} />
|
|
73
|
+
</Pressable>
|
|
74
|
+
</View>
|
|
75
|
+
<Pressable
|
|
76
|
+
onPress={handlePress}
|
|
77
|
+
accessibilityRole="button"
|
|
78
|
+
style={({ pressed }) => [
|
|
79
|
+
styles.cta,
|
|
80
|
+
{ backgroundColor: color },
|
|
81
|
+
pressed && styles.ctaPressed,
|
|
82
|
+
]}>
|
|
83
|
+
<Text style={styles.ctaLabel}>{ctaLabel}</Text>
|
|
84
|
+
</Pressable>
|
|
85
|
+
</View>
|
|
86
|
+
</View>
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const styles = StyleSheet.create({
|
|
92
|
+
wrapper: {
|
|
93
|
+
padding: spacing.md + 2,
|
|
94
|
+
backgroundColor: palette.white,
|
|
95
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
96
|
+
borderBottomColor: palette.borderSoft,
|
|
97
|
+
},
|
|
98
|
+
card: {
|
|
99
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
100
|
+
borderColor: palette.border,
|
|
101
|
+
borderRadius: radius.xl,
|
|
102
|
+
overflow: 'hidden',
|
|
103
|
+
backgroundColor: palette.white,
|
|
104
|
+
...shadows.card,
|
|
105
|
+
},
|
|
106
|
+
image: {
|
|
107
|
+
width: '100%',
|
|
108
|
+
height: 150,
|
|
109
|
+
},
|
|
110
|
+
body: {
|
|
111
|
+
padding: spacing.lg,
|
|
112
|
+
},
|
|
113
|
+
header: {
|
|
114
|
+
flexDirection: 'row',
|
|
115
|
+
alignItems: 'flex-start',
|
|
116
|
+
gap: spacing.sm + 2,
|
|
117
|
+
},
|
|
118
|
+
headerCopy: {
|
|
119
|
+
flex: 1,
|
|
120
|
+
minWidth: 0,
|
|
121
|
+
},
|
|
122
|
+
title: {
|
|
123
|
+
textAlign: START_ALIGN,
|
|
124
|
+
fontSize: fontSize.title,
|
|
125
|
+
fontWeight: '600',
|
|
126
|
+
color: palette.ink,
|
|
127
|
+
},
|
|
128
|
+
description: {
|
|
129
|
+
textAlign: START_ALIGN,
|
|
130
|
+
marginTop: 5,
|
|
131
|
+
fontSize: fontSize.meta,
|
|
132
|
+
lineHeight: fontSize.meta * 1.45,
|
|
133
|
+
color: palette.textMuted,
|
|
134
|
+
},
|
|
135
|
+
dismiss: {
|
|
136
|
+
padding: spacing.xs,
|
|
137
|
+
},
|
|
138
|
+
cta: {
|
|
139
|
+
marginTop: spacing.md,
|
|
140
|
+
borderRadius: radius.pill,
|
|
141
|
+
alignItems: 'center',
|
|
142
|
+
justifyContent: 'center',
|
|
143
|
+
paddingVertical: spacing.md,
|
|
144
|
+
minHeight: 44,
|
|
145
|
+
},
|
|
146
|
+
ctaPressed: {
|
|
147
|
+
opacity: 0.85,
|
|
148
|
+
},
|
|
149
|
+
ctaLabel: {
|
|
150
|
+
color: palette.white,
|
|
151
|
+
fontSize: fontSize.meta,
|
|
152
|
+
fontWeight: '600',
|
|
153
|
+
},
|
|
154
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel chrome: the colored header (with the assigned agent) and the bottom
|
|
3
|
+
* space switcher. Port of `client/src/widget/components/WidgetPanel.tsx`; the
|
|
4
|
+
* fixed-size floating card becomes a full-height sheet because the RN host is
|
|
5
|
+
* a modal, not an iframe pinned to a corner.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ReactNode } from 'react';
|
|
9
|
+
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
10
|
+
|
|
11
|
+
import type { WidgetSpace, WidgetSpaceType } from '../../types';
|
|
12
|
+
import { globalStyles } from '../styles/global';
|
|
13
|
+
import { fontSize, palette, spacing } from '../styles/theme';
|
|
14
|
+
import { ChatOutlineIcon, HomeIcon } from './icons';
|
|
15
|
+
|
|
16
|
+
const SPACE_META: Record<
|
|
17
|
+
WidgetSpaceType,
|
|
18
|
+
{ labelKey: 'home' | 'messages'; icon: (props: { size: number; color: string }) => ReactNode }
|
|
19
|
+
> = {
|
|
20
|
+
home: { labelKey: 'home', icon: (props) => <HomeIcon {...props} /> },
|
|
21
|
+
messages: { labelKey: 'messages', icon: (props) => <ChatOutlineIcon {...props} /> },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface WidgetPanelProps {
|
|
25
|
+
color: string;
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
activeTab: WidgetSpaceType;
|
|
28
|
+
onTabChange: (tab: WidgetSpaceType) => void;
|
|
29
|
+
showTabs: boolean;
|
|
30
|
+
spaces: WidgetSpace[];
|
|
31
|
+
/** Messages received while the panel sat on another surface. */
|
|
32
|
+
unreadCount?: number;
|
|
33
|
+
labels: { home: string; messages: string; unread: string };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function WidgetPanel({
|
|
37
|
+
color,
|
|
38
|
+
children,
|
|
39
|
+
activeTab,
|
|
40
|
+
onTabChange,
|
|
41
|
+
showTabs,
|
|
42
|
+
spaces,
|
|
43
|
+
unreadCount = 0,
|
|
44
|
+
labels,
|
|
45
|
+
}: WidgetPanelProps) {
|
|
46
|
+
const enabledSpaces = spaces.filter((space) => space.enabled);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View style={globalStyles.screen}>
|
|
50
|
+
<View style={globalStyles.fill}>{children}</View>
|
|
51
|
+
|
|
52
|
+
{showTabs && enabledSpaces.length > 1 && (
|
|
53
|
+
<View style={styles.tabBar}>
|
|
54
|
+
{enabledSpaces.map((space) => {
|
|
55
|
+
const meta = SPACE_META[space.type];
|
|
56
|
+
if (!meta) return null;
|
|
57
|
+
const active = activeTab === space.type;
|
|
58
|
+
const showBadge = space.type === 'messages' && unreadCount > 0;
|
|
59
|
+
return (
|
|
60
|
+
<Pressable
|
|
61
|
+
key={space.type}
|
|
62
|
+
onPress={() => onTabChange(space.type)}
|
|
63
|
+
accessibilityRole="tab"
|
|
64
|
+
accessibilityState={{ selected: active }}
|
|
65
|
+
accessibilityLabel={
|
|
66
|
+
showBadge ? `${labels[meta.labelKey]}, ${labels.unread}` : undefined
|
|
67
|
+
}
|
|
68
|
+
style={styles.tab}>
|
|
69
|
+
<View style={styles.tabIconWrap}>
|
|
70
|
+
{meta.icon({ size: 22, color: active ? color : palette.textSubtle })}
|
|
71
|
+
{showBadge ? (
|
|
72
|
+
<View style={styles.tabBadge} pointerEvents="none">
|
|
73
|
+
<Text style={styles.tabBadgeLabel}>
|
|
74
|
+
{unreadCount > 9 ? '9+' : unreadCount}
|
|
75
|
+
</Text>
|
|
76
|
+
</View>
|
|
77
|
+
) : null}
|
|
78
|
+
</View>
|
|
79
|
+
<Text style={[styles.tabLabel, { color: active ? color : palette.textSubtle }]}>
|
|
80
|
+
{labels[meta.labelKey]}
|
|
81
|
+
</Text>
|
|
82
|
+
</Pressable>
|
|
83
|
+
);
|
|
84
|
+
})}
|
|
85
|
+
</View>
|
|
86
|
+
)}
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const styles = StyleSheet.create({
|
|
92
|
+
tabIconWrap: {
|
|
93
|
+
position: 'relative',
|
|
94
|
+
},
|
|
95
|
+
tabBadge: {
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
top: -5,
|
|
98
|
+
end: -12,
|
|
99
|
+
minWidth: 18,
|
|
100
|
+
height: 18,
|
|
101
|
+
borderRadius: 9,
|
|
102
|
+
paddingHorizontal: spacing.xs,
|
|
103
|
+
backgroundColor: palette.danger,
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center',
|
|
106
|
+
borderWidth: 2,
|
|
107
|
+
borderColor: palette.white,
|
|
108
|
+
},
|
|
109
|
+
tabBadgeLabel: {
|
|
110
|
+
fontSize: fontSize.micro,
|
|
111
|
+
fontWeight: '700',
|
|
112
|
+
color: palette.white,
|
|
113
|
+
},
|
|
114
|
+
tabBar: {
|
|
115
|
+
flexDirection: 'row',
|
|
116
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
117
|
+
borderTopColor: palette.border,
|
|
118
|
+
backgroundColor: palette.white,
|
|
119
|
+
},
|
|
120
|
+
tab: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
gap: 2,
|
|
125
|
+
paddingVertical: spacing.sm,
|
|
126
|
+
minHeight: 52,
|
|
127
|
+
},
|
|
128
|
+
tabLabel: {
|
|
129
|
+
fontSize: fontSize.caption,
|
|
130
|
+
// Weight stays constant across states — only color signals the active tab.
|
|
131
|
+
fontWeight: '600',
|
|
132
|
+
},
|
|
133
|
+
});
|