@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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useReduceMotion = useReduceMotion;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Shared reduce-motion check. The query is async, so the answer is cached for
|
|
11
|
+
* the process: the setting rarely changes mid-session, and re-asking on every
|
|
12
|
+
* mount would let the first frame animate before the answer arrives.
|
|
13
|
+
*
|
|
14
|
+
* Returns `null` until resolved, which callers should read as "hold still" —
|
|
15
|
+
* starting an animation and snapping it away a frame later is the flicker this
|
|
16
|
+
* is meant to avoid.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
let cached = null;
|
|
20
|
+
function useReduceMotion() {
|
|
21
|
+
const [value, setValue] = (0, _react.useState)(cached);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
if (cached !== null) return undefined;
|
|
24
|
+
let alive = true;
|
|
25
|
+
_reactNative.AccessibilityInfo.isReduceMotionEnabled().then(enabled => {
|
|
26
|
+
cached = enabled;
|
|
27
|
+
if (alive) setValue(enabled);
|
|
28
|
+
}).catch(() => {
|
|
29
|
+
cached = false;
|
|
30
|
+
if (alive) setValue(false);
|
|
31
|
+
});
|
|
32
|
+
return () => {
|
|
33
|
+
alive = false;
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=use-reduce-motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","cached","useReduceMotion","value","setValue","useState","useEffect","undefined","alive","AccessibilityInfo","isReduceMotionEnabled","then","enabled","catch"],"sourceRoot":"../../../../src","sources":["ui/hooks/use-reduce-motion.ts"],"mappings":";;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,IAAIE,MAAsB,GAAG,IAAI;AAE1B,SAASC,eAAeA,CAAA,EAAmB;EAChD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAiBJ,MAAM,CAAC;EAE1D,IAAAK,gBAAS,EAAC,MAAM;IACd,IAAIL,MAAM,KAAK,IAAI,EAAE,OAAOM,SAAS;IACrC,IAAIC,KAAK,GAAG,IAAI;IAEhBC,8BAAiB,CAACC,qBAAqB,CAAC,CAAC,CACtCC,IAAI,CAAEC,OAAO,IAAK;MACjBX,MAAM,GAAGW,OAAO;MAChB,IAAIJ,KAAK,EAAEJ,QAAQ,CAACQ,OAAO,CAAC;IAC9B,CAAC,CAAC,CACDC,KAAK,CAAC,MAAM;MACXZ,MAAM,GAAG,KAAK;MACd,IAAIO,KAAK,EAAEJ,QAAQ,CAAC,KAAK,CAAC;IAC5B,CAAC,CAAC;IAEJ,OAAO,MAAM;MACXI,KAAK,GAAG,KAAK;IACf,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWidgetInsets = useWidgetInsets;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* Safe-area insets without a hard dependency.
|
|
10
|
+
*
|
|
11
|
+
* RN's own `SafeAreaView` is deprecated (and iOS-only), so we use the host
|
|
12
|
+
* app's `react-native-safe-area-context` when it is installed and fall back to
|
|
13
|
+
* platform constants otherwise. Resolution happens once at module load, so the
|
|
14
|
+
* hook call order is stable across renders.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const FALLBACK_INSETS = {
|
|
18
|
+
top: _reactNative.Platform.OS === 'android' ? _reactNative.StatusBar.currentHeight ?? 0 : 0,
|
|
19
|
+
bottom: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 0
|
|
22
|
+
};
|
|
23
|
+
let insetsHook = null;
|
|
24
|
+
try {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
26
|
+
const mod = require('react-native-safe-area-context');
|
|
27
|
+
if (typeof mod?.useSafeAreaInsets === 'function') insetsHook = mod.useSafeAreaInsets;
|
|
28
|
+
} catch {
|
|
29
|
+
insetsHook = null;
|
|
30
|
+
}
|
|
31
|
+
function useWidgetInsets() {
|
|
32
|
+
if (!insetsHook) return FALLBACK_INSETS;
|
|
33
|
+
try {
|
|
34
|
+
return insetsHook();
|
|
35
|
+
} catch {
|
|
36
|
+
// The host mounted no <SafeAreaProvider>; the hook itself still ran, so
|
|
37
|
+
// React's hook order is unchanged.
|
|
38
|
+
return FALLBACK_INSETS;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=use-widget-insets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","FALLBACK_INSETS","top","Platform","OS","StatusBar","currentHeight","bottom","left","right","insetsHook","mod","useSafeAreaInsets","useWidgetInsets"],"sourceRoot":"../../../../src","sources":["ui/hooks/use-widget-insets.ts"],"mappings":";;;;;;AASA,IAAAA,YAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMC,eAA6B,GAAG;EACpCC,GAAG,EAAEC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAIC,sBAAS,CAACC,aAAa,IAAI,CAAC,GAAI,CAAC;EACnEC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE;AACT,CAAC;AAED,IAAIC,UAAuC,GAAG,IAAI;AAClD,IAAI;EACF;EACA,MAAMC,GAAG,GAAGX,OAAO,CAAC,gCAAgC,CAAC;EACrD,IAAI,OAAOW,GAAG,EAAEC,iBAAiB,KAAK,UAAU,EAAEF,UAAU,GAAGC,GAAG,CAACC,iBAAiB;AACtF,CAAC,CAAC,MAAM;EACNF,UAAU,GAAG,IAAI;AACnB;AAEO,SAASG,eAAeA,CAAA,EAAiB;EAC9C,IAAI,CAACH,UAAU,EAAE,OAAOT,eAAe;EACvC,IAAI;IACF,OAAOS,UAAU,CAAC,CAAC;EACrB,CAAC,CAAC,MAAM;IACN;IACA;IACA,OAAOT,eAAe;EACxB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChatView = ChatView;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _agentUiBlocks = require("../../../agent-ui-blocks.js");
|
|
10
|
+
var _AgentUiBlocks = require("../../components/AgentUiBlocks.js");
|
|
11
|
+
var _Avatar = require("../../components/Avatar.js");
|
|
12
|
+
var _ErrorBoundary = require("../../components/ErrorBoundary.js");
|
|
13
|
+
var _Gradient = require("../../components/Gradient.js");
|
|
14
|
+
var _icons = require("../../components/icons.js");
|
|
15
|
+
var _Markdown = require("../../components/Markdown.js");
|
|
16
|
+
var _useReduceMotion = require("../../hooks/use-reduce-motion.js");
|
|
17
|
+
var _global = require("../../styles/global.js");
|
|
18
|
+
var _theme = require("../../styles/theme.js");
|
|
19
|
+
var _conversations = require("../../utils/conversations.js");
|
|
20
|
+
var _html = require("../../utils/html.js");
|
|
21
|
+
var _safeUrl = require("../../utils/safe-url.js");
|
|
22
|
+
var _rtl = require("../../utils/rtl.js");
|
|
23
|
+
var _ChatViewStyles = require("./ChatView.styles.js");
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
/**
|
|
26
|
+
* Chat thread — message list, typing indicator and composer.
|
|
27
|
+
* Port of `client/src/widget/components/ChatView.tsx`.
|
|
28
|
+
*
|
|
29
|
+
* Mobile differences: older messages load through an explicit "Load earlier
|
|
30
|
+
* messages" control (a scroll-anchored infinite list fights the keyboard), and
|
|
31
|
+
* the composer hides the attach button because v1 has no picker.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function ChatView({
|
|
35
|
+
messages,
|
|
36
|
+
loading,
|
|
37
|
+
hasMoreMessages,
|
|
38
|
+
agentTyping,
|
|
39
|
+
color,
|
|
40
|
+
agentName,
|
|
41
|
+
agentAvatar,
|
|
42
|
+
isOnline,
|
|
43
|
+
locale,
|
|
44
|
+
prefillText,
|
|
45
|
+
offlineMessage,
|
|
46
|
+
labels,
|
|
47
|
+
onSendMessage,
|
|
48
|
+
onIdentifyVisitor,
|
|
49
|
+
onLoadMore,
|
|
50
|
+
onTyping,
|
|
51
|
+
onBack,
|
|
52
|
+
onClose
|
|
53
|
+
}) {
|
|
54
|
+
const [input, setInput] = (0, _react.useState)(prefillText || '');
|
|
55
|
+
const [composerFocused, setComposerFocused] = (0, _react.useState)(false);
|
|
56
|
+
const reduceMotion = (0, _useReduceMotion.useReduceMotion)();
|
|
57
|
+
const scrollRef = (0, _react.useRef)(null);
|
|
58
|
+
const typingStopTimer = (0, _react.useRef)(null);
|
|
59
|
+
(0, _react.useEffect)(() => {
|
|
60
|
+
if (prefillText) setInput(prefillText);
|
|
61
|
+
}, [prefillText]);
|
|
62
|
+
(0, _react.useEffect)(() => () => {
|
|
63
|
+
if (typingStopTimer.current) clearTimeout(typingStopTimer.current);
|
|
64
|
+
}, []);
|
|
65
|
+
const scrollToBottom = (0, _react.useCallback)((animated = true) => {
|
|
66
|
+
scrollRef.current?.scrollToEnd({
|
|
67
|
+
animated
|
|
68
|
+
});
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
// Land on the newest message the moment the thread opens — notification
|
|
72
|
+
// taps and conversation-list taps both mount this screen. The content-size
|
|
73
|
+
// handler below covers later growth (loads, images, incoming messages).
|
|
74
|
+
(0, _react.useEffect)(() => {
|
|
75
|
+
const frame = requestAnimationFrame(() => scrollToBottom(false));
|
|
76
|
+
return () => cancelAnimationFrame(frame);
|
|
77
|
+
}, [scrollToBottom]);
|
|
78
|
+
|
|
79
|
+
// "Load earlier" PREPENDS history; skipping one auto-scroll keeps the reader
|
|
80
|
+
// anchored where they were instead of yanking them back to the bottom.
|
|
81
|
+
const skipNextAutoScroll = (0, _react.useRef)(false);
|
|
82
|
+
const handleLoadEarlier = (0, _react.useCallback)(() => {
|
|
83
|
+
skipNextAutoScroll.current = true;
|
|
84
|
+
onLoadMore();
|
|
85
|
+
}, [onLoadMore]);
|
|
86
|
+
const handleContentSizeChange = (0, _react.useCallback)(() => {
|
|
87
|
+
if (skipNextAutoScroll.current) {
|
|
88
|
+
skipNextAutoScroll.current = false;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
scrollToBottom(false);
|
|
92
|
+
}, [scrollToBottom]);
|
|
93
|
+
|
|
94
|
+
// The keyboard shortens the thread instead of scrolling it, so whatever was
|
|
95
|
+
// at the bottom — the newest message, an agent form — would slide in behind
|
|
96
|
+
// the composer. Re-pin on every shrink, unanimated, so the list tracks the
|
|
97
|
+
// keyboard as it rises rather than jumping once it lands.
|
|
98
|
+
const viewportHeight = (0, _react.useRef)(0);
|
|
99
|
+
const handleViewportLayout = (0, _react.useCallback)(event => {
|
|
100
|
+
const {
|
|
101
|
+
height
|
|
102
|
+
} = event.nativeEvent.layout;
|
|
103
|
+
const shrank = viewportHeight.current - height > 1;
|
|
104
|
+
viewportHeight.current = height;
|
|
105
|
+
if (shrank) scrollToBottom(false);
|
|
106
|
+
}, [scrollToBottom]);
|
|
107
|
+
const canSend = input.trim().length > 0;
|
|
108
|
+
const handleSend = () => {
|
|
109
|
+
const trimmed = input.trim();
|
|
110
|
+
if (!trimmed) return;
|
|
111
|
+
setInput('');
|
|
112
|
+
if (typingStopTimer.current) clearTimeout(typingStopTimer.current);
|
|
113
|
+
onTyping(false);
|
|
114
|
+
onSendMessage(trimmed);
|
|
115
|
+
scrollToBottom();
|
|
116
|
+
};
|
|
117
|
+
const handleChangeText = text => {
|
|
118
|
+
setInput(text);
|
|
119
|
+
if (!text.trim()) return;
|
|
120
|
+
onTyping(true);
|
|
121
|
+
if (typingStopTimer.current) clearTimeout(typingStopTimer.current);
|
|
122
|
+
typingStopTimer.current = setTimeout(() => onTyping(false), 2500);
|
|
123
|
+
};
|
|
124
|
+
const handleAgentUiAction = (0, _react.useCallback)(async action => {
|
|
125
|
+
if (action.type === 'submit_contact' && onIdentifyVisitor) {
|
|
126
|
+
await onIdentifyVisitor({
|
|
127
|
+
email: stringPayload(action.payload.email),
|
|
128
|
+
name: stringPayload(action.payload.name) || [stringPayload(action.payload.firstName), stringPayload(action.payload.lastName)].filter(Boolean).join(' ') || undefined,
|
|
129
|
+
phone: stringPayload(action.payload.phone)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
onSendMessage((0, _agentUiBlocks.formatAgentUiActionMessage)(action), undefined, action);
|
|
133
|
+
scrollToBottom();
|
|
134
|
+
}, [onIdentifyVisitor, onSendMessage, scrollToBottom]);
|
|
135
|
+
const headerTextColor = (0, _theme.contrastingTextColor)(color);
|
|
136
|
+
const onDarkHeader = headerTextColor === _theme.palette.white;
|
|
137
|
+
const isEmptyThread = !loading && messages.length === 0;
|
|
138
|
+
// Two stops off the brand color: flat fill looked like an unstyled block.
|
|
139
|
+
// A non-hex brand color falls through mixHex unchanged and renders solid.
|
|
140
|
+
const headerGradient = [color, (0, _theme.mixHex)(color, '#000000', 0.16)];
|
|
141
|
+
const headerControl = {
|
|
142
|
+
backgroundColor: (0, _theme.withAlpha)(headerTextColor, 0.16)
|
|
143
|
+
};
|
|
144
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
145
|
+
style: _global.globalStyles.screen,
|
|
146
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Gradient.GradientBackground, {
|
|
147
|
+
colors: headerGradient,
|
|
148
|
+
style: [_ChatViewStyles.styles.header, {
|
|
149
|
+
borderBottomColor: (0, _theme.mixHex)(color, '#000000', 0.26)
|
|
150
|
+
}],
|
|
151
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
152
|
+
onPress: onBack,
|
|
153
|
+
accessibilityRole: "button",
|
|
154
|
+
accessibilityLabel: labels.back,
|
|
155
|
+
hitSlop: 12,
|
|
156
|
+
style: ({
|
|
157
|
+
pressed
|
|
158
|
+
}) => [_global.globalStyles.iconButton, headerControl, pressed && _global.globalStyles.pressed],
|
|
159
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ChevronIcon, {
|
|
160
|
+
size: 18,
|
|
161
|
+
direction: (0, _rtl.backDirection)(),
|
|
162
|
+
color: headerTextColor
|
|
163
|
+
})
|
|
164
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
165
|
+
style: _ChatViewStyles.styles.headerIdentity,
|
|
166
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
167
|
+
style: _ChatViewStyles.styles.avatarWrapper,
|
|
168
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.Avatar, {
|
|
169
|
+
avatar: agentAvatar,
|
|
170
|
+
name: agentName,
|
|
171
|
+
size: 36,
|
|
172
|
+
translucent: onDarkHeader,
|
|
173
|
+
color: _theme.palette.ink
|
|
174
|
+
}), isOnline ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
175
|
+
style: _ChatViewStyles.styles.onlineDot
|
|
176
|
+
}) : null]
|
|
177
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
178
|
+
style: _ChatViewStyles.styles.headerText,
|
|
179
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
180
|
+
style: [_ChatViewStyles.styles.headerName, {
|
|
181
|
+
color: headerTextColor
|
|
182
|
+
}],
|
|
183
|
+
numberOfLines: 1,
|
|
184
|
+
children: agentName || labels.team
|
|
185
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
186
|
+
style: [_ChatViewStyles.styles.headerStatus, {
|
|
187
|
+
color: (0, _theme.withAlpha)(headerTextColor, 0.75)
|
|
188
|
+
}],
|
|
189
|
+
numberOfLines: 1,
|
|
190
|
+
children: isOnline ? labels.statusOnline : labels.statusAway
|
|
191
|
+
})]
|
|
192
|
+
})]
|
|
193
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
194
|
+
onPress: onClose,
|
|
195
|
+
accessibilityRole: "button",
|
|
196
|
+
accessibilityLabel: labels.close,
|
|
197
|
+
hitSlop: 12,
|
|
198
|
+
style: ({
|
|
199
|
+
pressed
|
|
200
|
+
}) => [_global.globalStyles.iconButton, headerControl, pressed && _global.globalStyles.pressed],
|
|
201
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ChevronIcon, {
|
|
202
|
+
size: 20,
|
|
203
|
+
direction: "down",
|
|
204
|
+
color: headerTextColor
|
|
205
|
+
})
|
|
206
|
+
})]
|
|
207
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
|
|
208
|
+
ref: scrollRef,
|
|
209
|
+
style: _global.globalStyles.fill,
|
|
210
|
+
contentContainerStyle: [_ChatViewStyles.styles.messagesContent, isEmptyThread && _ChatViewStyles.styles.messagesContentEmpty],
|
|
211
|
+
keyboardShouldPersistTaps: "handled"
|
|
212
|
+
// Interactive dismissal drags the keyboard down under the finger while
|
|
213
|
+
// the composer stays where the last keyboard event left it, which opens
|
|
214
|
+
// a gap under the thread; on-drag hands us a normal hide event instead.
|
|
215
|
+
,
|
|
216
|
+
keyboardDismissMode: "on-drag",
|
|
217
|
+
onLayout: handleViewportLayout,
|
|
218
|
+
onContentSizeChange: handleContentSizeChange,
|
|
219
|
+
children: [hasMoreMessages ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
220
|
+
onPress: handleLoadEarlier,
|
|
221
|
+
accessibilityRole: "button",
|
|
222
|
+
style: _ChatViewStyles.styles.loadMore,
|
|
223
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
224
|
+
style: [_ChatViewStyles.styles.loadMoreLabel, {
|
|
225
|
+
color
|
|
226
|
+
}],
|
|
227
|
+
children: loading ? labels.loading : labels.loadEarlier
|
|
228
|
+
})
|
|
229
|
+
}) : null, loading && messages.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
230
|
+
style: _ChatViewStyles.styles.stateText,
|
|
231
|
+
children: labels.loading
|
|
232
|
+
}) : null, isEmptyThread ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
233
|
+
style: _ChatViewStyles.styles.emptyState,
|
|
234
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
235
|
+
style: [_ChatViewStyles.styles.emptyIcon, {
|
|
236
|
+
backgroundColor: (0, _theme.withAlpha)(color, 0.08)
|
|
237
|
+
}],
|
|
238
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ChatOutlineIcon, {
|
|
239
|
+
size: 28,
|
|
240
|
+
color: color
|
|
241
|
+
})
|
|
242
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
243
|
+
style: _ChatViewStyles.styles.emptyText,
|
|
244
|
+
children: labels.emptyConversation
|
|
245
|
+
})]
|
|
246
|
+
}) : null, messages.map((message, index) => {
|
|
247
|
+
const previous = index > 0 ? messages[index - 1] : undefined;
|
|
248
|
+
const startsDay = !previous || !(0, _conversations.isSameDay)(message.createdAt, previous.createdAt);
|
|
249
|
+
const isAgentMessage = message.direction !== 'inbound' && message.messageType !== 'system';
|
|
250
|
+
// Name only at the top of a run, the way every messenger does it.
|
|
251
|
+
const startsRun = !previous || previous.direction === 'inbound' || previous.messageType === 'system' || previous.senderName !== message.senderName;
|
|
252
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
253
|
+
children: [startsDay ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
254
|
+
style: _ChatViewStyles.styles.daySeparator,
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
256
|
+
style: _ChatViewStyles.styles.dayLine
|
|
257
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
258
|
+
style: _ChatViewStyles.styles.dayLabel,
|
|
259
|
+
children: (0, _conversations.formatDayLabel)(message.createdAt, locale, labels)
|
|
260
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
261
|
+
style: _ChatViewStyles.styles.dayLine
|
|
262
|
+
})]
|
|
263
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorBoundary.WidgetErrorBoundary, {
|
|
264
|
+
fallback: null,
|
|
265
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageBubble, {
|
|
266
|
+
message: message,
|
|
267
|
+
color: color,
|
|
268
|
+
labels: labels,
|
|
269
|
+
senderLabel: isAgentMessage && (startsRun || startsDay) ? message.senderName || agentName || labels.team : null,
|
|
270
|
+
timeLabel: (0, _conversations.formatClockTime)(message.createdAt, locale),
|
|
271
|
+
onSubmitProcedureForm: shouldShowProcedureForm(messages, message) ? body => onSendMessage(body) : undefined,
|
|
272
|
+
onAgentUiAction: shouldShowAgentUiBlocks(messages, message) ? handleAgentUiAction : undefined
|
|
273
|
+
})
|
|
274
|
+
})]
|
|
275
|
+
}, message.id);
|
|
276
|
+
}), agentTyping ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
277
|
+
style: _ChatViewStyles.styles.typingRow,
|
|
278
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
279
|
+
style: _ChatViewStyles.styles.typingBubble,
|
|
280
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(TypingDot, {
|
|
281
|
+
index: 0,
|
|
282
|
+
reduceMotion: reduceMotion
|
|
283
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(TypingDot, {
|
|
284
|
+
index: 1,
|
|
285
|
+
reduceMotion: reduceMotion
|
|
286
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(TypingDot, {
|
|
287
|
+
index: 2,
|
|
288
|
+
reduceMotion: reduceMotion
|
|
289
|
+
})]
|
|
290
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
291
|
+
style: _ChatViewStyles.styles.typingLabel,
|
|
292
|
+
children: labels.thinking
|
|
293
|
+
})]
|
|
294
|
+
}) : null]
|
|
295
|
+
}), offlineMessage ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
296
|
+
style: _ChatViewStyles.styles.offlineBanner,
|
|
297
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
298
|
+
style: _ChatViewStyles.styles.offlineText,
|
|
299
|
+
children: offlineMessage
|
|
300
|
+
})
|
|
301
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
302
|
+
style: _ChatViewStyles.styles.composerWrapper,
|
|
303
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
304
|
+
style: [_ChatViewStyles.styles.composer, composerFocused && _ChatViewStyles.styles.composerFocused, composerFocused && {
|
|
305
|
+
borderColor: (0, _theme.withAlpha)(color, 0.55)
|
|
306
|
+
}],
|
|
307
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
|
308
|
+
value: input,
|
|
309
|
+
onChangeText: handleChangeText,
|
|
310
|
+
onFocus: () => setComposerFocused(true),
|
|
311
|
+
onBlur: () => setComposerFocused(false),
|
|
312
|
+
placeholder: labels.messagePlaceholder,
|
|
313
|
+
placeholderTextColor: _theme.palette.textSubtle,
|
|
314
|
+
multiline: true,
|
|
315
|
+
style: _ChatViewStyles.styles.input,
|
|
316
|
+
accessibilityLabel: labels.messagePlaceholder
|
|
317
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
318
|
+
onPress: handleSend,
|
|
319
|
+
disabled: !canSend,
|
|
320
|
+
accessibilityRole: "button",
|
|
321
|
+
accessibilityState: {
|
|
322
|
+
disabled: !canSend
|
|
323
|
+
},
|
|
324
|
+
hitSlop: 8,
|
|
325
|
+
style: ({
|
|
326
|
+
pressed
|
|
327
|
+
}) => [_ChatViewStyles.styles.sendButton, canSend ? {
|
|
328
|
+
backgroundColor: color
|
|
329
|
+
} : _ChatViewStyles.styles.sendButtonDisabled, pressed && canSend && _ChatViewStyles.styles.sendButtonPressed],
|
|
330
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ArrowUpIcon, {
|
|
331
|
+
size: 18,
|
|
332
|
+
color: canSend ? (0, _theme.contrastingTextColor)(color) : _theme.palette.textSubtle
|
|
333
|
+
})
|
|
334
|
+
})]
|
|
335
|
+
})
|
|
336
|
+
})]
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function MessageBubble({
|
|
340
|
+
message,
|
|
341
|
+
color,
|
|
342
|
+
labels,
|
|
343
|
+
senderLabel,
|
|
344
|
+
timeLabel,
|
|
345
|
+
onSubmitProcedureForm,
|
|
346
|
+
onAgentUiAction
|
|
347
|
+
}) {
|
|
348
|
+
if (message.messageType === 'system') {
|
|
349
|
+
const text = message.bodyPlain || (0, _html.stripHtml)(message.body || '') || labels.conversationUpdated;
|
|
350
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
351
|
+
style: _ChatViewStyles.styles.systemRow,
|
|
352
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
353
|
+
style: _ChatViewStyles.styles.systemText,
|
|
354
|
+
children: text
|
|
355
|
+
})
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
const isVisitor = message.direction === 'inbound';
|
|
359
|
+
const rtl = (0, _rtl.isRTL)();
|
|
360
|
+
const messageText = message.bodyPlain || (0, _html.stripHtml)(message.body || '');
|
|
361
|
+
const hasBody = !!messageText;
|
|
362
|
+
const procedureForm = !isVisitor ? (0, _agentUiBlocks.getProcedureForm)(message.metadata) : null;
|
|
363
|
+
const agentUiBlocks = !isVisitor ? (0, _agentUiBlocks.getAgentUiBlocks)(message.metadata) : [];
|
|
364
|
+
const textColor = isVisitor ? _theme.palette.white : _theme.palette.ink;
|
|
365
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
366
|
+
style: [_ChatViewStyles.styles.messageRow, isVisitor ? _ChatViewStyles.styles.messageRowRight : _ChatViewStyles.styles.messageRowLeft],
|
|
367
|
+
children: [senderLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
368
|
+
style: _ChatViewStyles.styles.senderLabel,
|
|
369
|
+
children: senderLabel
|
|
370
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
371
|
+
style: [_ChatViewStyles.styles.bubble, isVisitor ? [_ChatViewStyles.styles.bubbleVisitor, {
|
|
372
|
+
backgroundColor: color
|
|
373
|
+
}] : _ChatViewStyles.styles.bubbleAgent, rtl && (isVisitor ? _ChatViewStyles.styles.bubbleVisitorRTL : _ChatViewStyles.styles.bubbleAgentRTL), message.status === 'pending' && _ChatViewStyles.styles.bubblePending],
|
|
374
|
+
children: [hasBody ? isVisitor ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
375
|
+
style: [_ChatViewStyles.styles.bubbleText, {
|
|
376
|
+
color: textColor
|
|
377
|
+
}],
|
|
378
|
+
children: messageText
|
|
379
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Markdown.Markdown, {
|
|
380
|
+
content: messageText,
|
|
381
|
+
color: textColor
|
|
382
|
+
}) : null, message.attachments && message.attachments.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
383
|
+
style: [_ChatViewStyles.styles.attachments, hasBody && _ChatViewStyles.styles.attachmentsSpaced],
|
|
384
|
+
children: message.attachments.map(attachment => /*#__PURE__*/(0, _jsxRuntime.jsx)(AttachmentPreview, {
|
|
385
|
+
attachment: attachment,
|
|
386
|
+
isVisitor: isVisitor
|
|
387
|
+
}, attachment.id))
|
|
388
|
+
}) : null, message.status === 'failed' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
389
|
+
style: [_ChatViewStyles.styles.failedText, {
|
|
390
|
+
color: isVisitor ? (0, _theme.withAlpha)(_theme.palette.white, 0.7) : _theme.palette.danger
|
|
391
|
+
}],
|
|
392
|
+
children: labels.failedToSend
|
|
393
|
+
}) : null, timeLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
394
|
+
style: [_ChatViewStyles.styles.messageTime, {
|
|
395
|
+
color: isVisitor ? (0, _theme.withAlpha)(_theme.palette.white, 0.7) : _theme.palette.textSubtle
|
|
396
|
+
}],
|
|
397
|
+
children: timeLabel
|
|
398
|
+
}) : null]
|
|
399
|
+
}), agentUiBlocks.length > 0 && onAgentUiAction ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_AgentUiBlocks.AgentUiBlocks, {
|
|
400
|
+
blocks: agentUiBlocks,
|
|
401
|
+
color: color,
|
|
402
|
+
labels: labels.blocks,
|
|
403
|
+
onAction: onAgentUiAction
|
|
404
|
+
}) : null, agentUiBlocks.length === 0 && procedureForm && onSubmitProcedureForm ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ProcedureFieldForm, {
|
|
405
|
+
form: procedureForm,
|
|
406
|
+
color: color,
|
|
407
|
+
labels: labels,
|
|
408
|
+
onSubmit: onSubmitProcedureForm
|
|
409
|
+
}) : null]
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function AttachmentPreview({
|
|
413
|
+
attachment,
|
|
414
|
+
isVisitor
|
|
415
|
+
}) {
|
|
416
|
+
// `url` is empty when the server sent a non-http(s) URL (see resolveUrl).
|
|
417
|
+
const isImage = attachment.contentType?.startsWith('image/') && !!attachment.url;
|
|
418
|
+
const open = () => void (0, _safeUrl.openExternalUrl)(attachment.url);
|
|
419
|
+
if (isImage) {
|
|
420
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
421
|
+
onPress: open,
|
|
422
|
+
accessibilityRole: "imagebutton",
|
|
423
|
+
accessibilityLabel: attachment.name,
|
|
424
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
425
|
+
source: {
|
|
426
|
+
uri: attachment.url
|
|
427
|
+
},
|
|
428
|
+
style: _ChatViewStyles.styles.attachmentImage,
|
|
429
|
+
resizeMode: "cover",
|
|
430
|
+
accessibilityIgnoresInvertColors: true
|
|
431
|
+
})
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
435
|
+
onPress: open,
|
|
436
|
+
accessibilityRole: "button",
|
|
437
|
+
style: [_ChatViewStyles.styles.attachmentFile, {
|
|
438
|
+
borderColor: isVisitor ? (0, _theme.withAlpha)(_theme.palette.white, 0.35) : _theme.palette.border
|
|
439
|
+
}],
|
|
440
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
441
|
+
style: [_ChatViewStyles.styles.attachmentName, {
|
|
442
|
+
color: isVisitor ? _theme.palette.white : _theme.palette.ink
|
|
443
|
+
}],
|
|
444
|
+
numberOfLines: 1,
|
|
445
|
+
children: attachment.name
|
|
446
|
+
})
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function ProcedureFieldForm({
|
|
450
|
+
form,
|
|
451
|
+
color,
|
|
452
|
+
labels,
|
|
453
|
+
onSubmit
|
|
454
|
+
}) {
|
|
455
|
+
const [values, setValues] = (0, _react.useState)({});
|
|
456
|
+
const [submitted, setSubmitted] = (0, _react.useState)(false);
|
|
457
|
+
const [expanded, setExpanded] = (0, _react.useState)(false);
|
|
458
|
+
const canSubmit = form.fields.every(field => !field.required || values[field.name]?.trim());
|
|
459
|
+
const handleSubmit = () => {
|
|
460
|
+
if (!canSubmit || submitted) return;
|
|
461
|
+
const body = form.fields.map(field => `${field.label}: ${(values[field.name] || '').trim()}`).filter(line => !line.endsWith(':')).join('\n');
|
|
462
|
+
if (!body.trim()) return;
|
|
463
|
+
setSubmitted(true);
|
|
464
|
+
onSubmit(body);
|
|
465
|
+
};
|
|
466
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
467
|
+
style: _ChatViewStyles.styles.procedureCard,
|
|
468
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
469
|
+
onPress: () => setExpanded(current => !current),
|
|
470
|
+
accessibilityRole: "button",
|
|
471
|
+
accessibilityState: {
|
|
472
|
+
expanded
|
|
473
|
+
},
|
|
474
|
+
style: [_ChatViewStyles.styles.procedureToggle, {
|
|
475
|
+
backgroundColor: expanded ? _theme.palette.surface : color
|
|
476
|
+
}],
|
|
477
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
478
|
+
style: [_ChatViewStyles.styles.procedureToggleLabel, {
|
|
479
|
+
color: expanded ? _theme.palette.text : _theme.palette.white
|
|
480
|
+
}],
|
|
481
|
+
children: submitted ? 'Details sent' : 'Share details'
|
|
482
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
483
|
+
style: [_ChatViewStyles.styles.procedureToggleHint, {
|
|
484
|
+
color: expanded ? _theme.palette.text : _theme.palette.white
|
|
485
|
+
}],
|
|
486
|
+
children: expanded ? 'Hide' : `${form.fields.length} field${form.fields.length === 1 ? '' : 's'}`
|
|
487
|
+
})]
|
|
488
|
+
}), expanded ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
489
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
490
|
+
style: _ChatViewStyles.styles.procedureTitle,
|
|
491
|
+
children: form.procedureName || 'Details'
|
|
492
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
493
|
+
style: _ChatViewStyles.styles.procedureFields,
|
|
494
|
+
children: form.fields.map(field => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
495
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
496
|
+
style: _ChatViewStyles.styles.procedureLabel,
|
|
497
|
+
children: [field.label, field.required ? ' *' : '']
|
|
498
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
|
499
|
+
value: values[field.name] || '',
|
|
500
|
+
onChangeText: text => setValues(current => ({
|
|
501
|
+
...current,
|
|
502
|
+
[field.name]: text
|
|
503
|
+
})),
|
|
504
|
+
placeholder: placeholderForField(field),
|
|
505
|
+
placeholderTextColor: _theme.palette.textSubtle,
|
|
506
|
+
editable: !submitted,
|
|
507
|
+
keyboardType: field.type === 'email' ? 'email-address' : field.type === 'phone' ? 'phone-pad' : 'default',
|
|
508
|
+
autoCapitalize: field.type === 'email' ? 'none' : 'sentences',
|
|
509
|
+
style: _ChatViewStyles.styles.procedureInput
|
|
510
|
+
})]
|
|
511
|
+
}, field.name))
|
|
512
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
513
|
+
onPress: handleSubmit,
|
|
514
|
+
disabled: !canSubmit || submitted,
|
|
515
|
+
accessibilityRole: "button",
|
|
516
|
+
style: [_ChatViewStyles.styles.procedureSubmit, {
|
|
517
|
+
backgroundColor: canSubmit && !submitted ? color : _theme.palette.disabled
|
|
518
|
+
}],
|
|
519
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
520
|
+
style: _ChatViewStyles.styles.procedureSubmitLabel,
|
|
521
|
+
children: submitted ? labels.procedureSent : labels.procedureSend
|
|
522
|
+
})
|
|
523
|
+
})]
|
|
524
|
+
}) : null]
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function TypingDot({
|
|
528
|
+
index,
|
|
529
|
+
reduceMotion
|
|
530
|
+
}) {
|
|
531
|
+
const value = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
532
|
+
const animating = reduceMotion === false;
|
|
533
|
+
(0, _react.useEffect)(() => {
|
|
534
|
+
if (!animating) return undefined;
|
|
535
|
+
// Every dot runs a constant 920ms cycle and only the leading delay
|
|
536
|
+
// differs, so the three hold their phase instead of drifting apart.
|
|
537
|
+
const loop = _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.delay(index * 140), _reactNative.Animated.timing(value, {
|
|
538
|
+
toValue: 1,
|
|
539
|
+
duration: 320,
|
|
540
|
+
easing: _reactNative.Easing.out(_reactNative.Easing.quad),
|
|
541
|
+
useNativeDriver: true
|
|
542
|
+
}), _reactNative.Animated.timing(value, {
|
|
543
|
+
toValue: 0,
|
|
544
|
+
duration: 320,
|
|
545
|
+
easing: _reactNative.Easing.in(_reactNative.Easing.quad),
|
|
546
|
+
useNativeDriver: true
|
|
547
|
+
}), _reactNative.Animated.delay(280 - index * 140)]));
|
|
548
|
+
loop.start();
|
|
549
|
+
return () => loop.stop();
|
|
550
|
+
}, [animating, index, value]);
|
|
551
|
+
const motionStyle = animating ? {
|
|
552
|
+
opacity: value.interpolate({
|
|
553
|
+
inputRange: [0, 1],
|
|
554
|
+
outputRange: [0.4, 1]
|
|
555
|
+
}),
|
|
556
|
+
transform: [{
|
|
557
|
+
translateY: value.interpolate({
|
|
558
|
+
inputRange: [0, 1],
|
|
559
|
+
outputRange: [0, -4]
|
|
560
|
+
})
|
|
561
|
+
}]
|
|
562
|
+
} : null;
|
|
563
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
564
|
+
style: [_ChatViewStyles.styles.typingDot, motionStyle]
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function placeholderForField(field) {
|
|
568
|
+
if (field.type === 'email') return 'name@example.com';
|
|
569
|
+
if (field.type === 'phone') return '+962 7...';
|
|
570
|
+
if (field.type === 'date' || field.type === 'time') return '';
|
|
571
|
+
return field.label;
|
|
572
|
+
}
|
|
573
|
+
function stringPayload(value) {
|
|
574
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
575
|
+
}
|
|
576
|
+
function shouldShowProcedureForm(messages, message) {
|
|
577
|
+
if (message.direction === 'inbound' || !(0, _agentUiBlocks.getProcedureForm)(message.metadata)) return false;
|
|
578
|
+
return messages.findIndex(candidate => candidate.id === message.id) === messages.length - 1;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** Hide superseded slot pickers so only the newest one stays actionable. */
|
|
582
|
+
function shouldShowAgentUiBlocks(messages, message) {
|
|
583
|
+
const blocks = (0, _agentUiBlocks.getAgentUiBlocks)(message.metadata);
|
|
584
|
+
if (blocks.length === 0) return false;
|
|
585
|
+
if (!blocks.every(block => block.type === 'appointment_slot_picker')) return true;
|
|
586
|
+
const messageIndex = messages.findIndex(candidate => candidate.id === message.id);
|
|
587
|
+
const laterBlockIds = new Set(messages.slice(messageIndex + 1).flatMap(candidate => (0, _agentUiBlocks.getAgentUiBlocks)(candidate.metadata)).filter(block => block.type === 'appointment_slot_picker').map(block => block.id));
|
|
588
|
+
return blocks.some(block => !laterBlockIds.has(block.id));
|
|
589
|
+
}
|
|
590
|
+
//# sourceMappingURL=ChatView.js.map
|