@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,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometric icons drawn with plain Views.
|
|
3
|
+
*
|
|
4
|
+
* The library ships zero native dependencies, so `react-native-svg` is off the
|
|
5
|
+
* table; every glyph here is a rotated border or triangle, which renders
|
|
6
|
+
* identically on both platforms and scales with the `size` prop.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { StyleSheet, View, type ViewStyle } from 'react-native';
|
|
10
|
+
|
|
11
|
+
import { palette } from '../styles/theme';
|
|
12
|
+
|
|
13
|
+
interface IconProps {
|
|
14
|
+
size?: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
style?: ViewStyle;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Two crossed bars. */
|
|
20
|
+
export function CloseIcon({ size = 18, color = palette.textMuted, style }: IconProps) {
|
|
21
|
+
const bar: ViewStyle = {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
width: size,
|
|
24
|
+
height: Math.max(2, size * 0.11),
|
|
25
|
+
borderRadius: 2,
|
|
26
|
+
backgroundColor: color,
|
|
27
|
+
};
|
|
28
|
+
return (
|
|
29
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
30
|
+
<View style={[bar, { transform: [{ rotate: '45deg' }] }]} />
|
|
31
|
+
<View style={[bar, { transform: [{ rotate: '-45deg' }] }]} />
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type ChevronDirection = 'left' | 'right' | 'up' | 'down';
|
|
37
|
+
|
|
38
|
+
const CHEVRON_ROTATION: Record<ChevronDirection, string> = {
|
|
39
|
+
left: '45deg',
|
|
40
|
+
right: '-135deg',
|
|
41
|
+
up: '135deg',
|
|
42
|
+
down: '-45deg',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** A square with two adjacent borders, rotated into an arrow head. */
|
|
46
|
+
export function ChevronIcon({
|
|
47
|
+
size = 16,
|
|
48
|
+
color = palette.textMuted,
|
|
49
|
+
direction = 'left',
|
|
50
|
+
style,
|
|
51
|
+
}: IconProps & { direction?: ChevronDirection }) {
|
|
52
|
+
const box = size * 0.62;
|
|
53
|
+
return (
|
|
54
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
55
|
+
<View
|
|
56
|
+
style={{
|
|
57
|
+
width: box,
|
|
58
|
+
height: box,
|
|
59
|
+
borderLeftWidth: Math.max(2, size * 0.13),
|
|
60
|
+
borderBottomWidth: Math.max(2, size * 0.13),
|
|
61
|
+
borderColor: color,
|
|
62
|
+
transform: [{ rotate: CHEVRON_ROTATION[direction] }],
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Arrow with a shaft — used for the "start a conversation" affordance. */
|
|
70
|
+
export function ArrowRightIcon({ size = 16, color = palette.textMuted, style }: IconProps) {
|
|
71
|
+
const thickness = Math.max(2, size * 0.12);
|
|
72
|
+
return (
|
|
73
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
74
|
+
<View
|
|
75
|
+
style={{
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
width: size * 0.8,
|
|
78
|
+
height: thickness,
|
|
79
|
+
borderRadius: thickness,
|
|
80
|
+
backgroundColor: color,
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
<View
|
|
84
|
+
style={{
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
right: size * 0.12,
|
|
87
|
+
width: size * 0.42,
|
|
88
|
+
height: size * 0.42,
|
|
89
|
+
borderTopWidth: thickness,
|
|
90
|
+
borderRightWidth: thickness,
|
|
91
|
+
borderColor: color,
|
|
92
|
+
transform: [{ rotate: '45deg' }],
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
</View>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Right-pointing triangle for the send button. */
|
|
100
|
+
/** Upward arrow — the send affordance inside the composer's round button. */
|
|
101
|
+
export function ArrowUpIcon({ size = 16, color = palette.white, style }: IconProps) {
|
|
102
|
+
const thickness = Math.max(2, size * 0.12);
|
|
103
|
+
return (
|
|
104
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
105
|
+
<View
|
|
106
|
+
style={{
|
|
107
|
+
position: 'absolute',
|
|
108
|
+
width: thickness,
|
|
109
|
+
height: size * 0.78,
|
|
110
|
+
borderRadius: thickness,
|
|
111
|
+
backgroundColor: color,
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
<View
|
|
115
|
+
style={{
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
top: size * 0.14,
|
|
118
|
+
width: size * 0.42,
|
|
119
|
+
height: size * 0.42,
|
|
120
|
+
borderTopWidth: thickness,
|
|
121
|
+
borderRightWidth: thickness,
|
|
122
|
+
borderColor: color,
|
|
123
|
+
transform: [{ rotate: '-45deg' }],
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
</View>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Rounded speech bubble with a tail. */
|
|
131
|
+
export function ChatIcon({ size = 24, color = palette.white, style }: IconProps) {
|
|
132
|
+
return (
|
|
133
|
+
<View style={[{ width: size, height: size }, style]}>
|
|
134
|
+
<View
|
|
135
|
+
style={{
|
|
136
|
+
width: size,
|
|
137
|
+
height: size * 0.78,
|
|
138
|
+
borderRadius: size * 0.26,
|
|
139
|
+
backgroundColor: color,
|
|
140
|
+
}}
|
|
141
|
+
/>
|
|
142
|
+
<View
|
|
143
|
+
style={{
|
|
144
|
+
position: 'absolute',
|
|
145
|
+
left: size * 0.18,
|
|
146
|
+
bottom: 0,
|
|
147
|
+
width: 0,
|
|
148
|
+
height: 0,
|
|
149
|
+
borderLeftWidth: size * 0.14,
|
|
150
|
+
borderRightWidth: size * 0.14,
|
|
151
|
+
borderTopWidth: size * 0.26,
|
|
152
|
+
borderLeftColor: 'transparent',
|
|
153
|
+
borderRightColor: 'transparent',
|
|
154
|
+
borderTopColor: color,
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Outlined speech bubble — the Messages tab + empty state. */
|
|
162
|
+
export function ChatOutlineIcon({ size = 22, color = palette.textSubtle, style }: IconProps) {
|
|
163
|
+
const thickness = Math.max(1.5, size * 0.09);
|
|
164
|
+
return (
|
|
165
|
+
<View style={[{ width: size, height: size }, style]}>
|
|
166
|
+
<View
|
|
167
|
+
style={{
|
|
168
|
+
width: size,
|
|
169
|
+
height: size * 0.76,
|
|
170
|
+
borderRadius: size * 0.24,
|
|
171
|
+
borderWidth: thickness,
|
|
172
|
+
borderColor: color,
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
<View
|
|
176
|
+
style={{
|
|
177
|
+
position: 'absolute',
|
|
178
|
+
left: size * 0.2,
|
|
179
|
+
bottom: size * 0.02,
|
|
180
|
+
width: size * 0.22,
|
|
181
|
+
height: size * 0.22,
|
|
182
|
+
borderLeftWidth: thickness,
|
|
183
|
+
borderBottomWidth: thickness,
|
|
184
|
+
borderColor: color,
|
|
185
|
+
backgroundColor: palette.white,
|
|
186
|
+
transform: [{ rotate: '-45deg' }],
|
|
187
|
+
}}
|
|
188
|
+
/>
|
|
189
|
+
</View>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** House outline — the Home tab. */
|
|
194
|
+
export function HomeIcon({ size = 22, color = palette.textSubtle, style }: IconProps) {
|
|
195
|
+
const thickness = Math.max(1.5, size * 0.09);
|
|
196
|
+
return (
|
|
197
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
198
|
+
<View
|
|
199
|
+
style={{
|
|
200
|
+
position: 'absolute',
|
|
201
|
+
top: size * 0.04,
|
|
202
|
+
width: size * 0.56,
|
|
203
|
+
height: size * 0.56,
|
|
204
|
+
borderTopWidth: thickness,
|
|
205
|
+
borderLeftWidth: thickness,
|
|
206
|
+
borderColor: color,
|
|
207
|
+
transform: [{ rotate: '45deg' }],
|
|
208
|
+
}}
|
|
209
|
+
/>
|
|
210
|
+
<View
|
|
211
|
+
style={{
|
|
212
|
+
position: 'absolute',
|
|
213
|
+
bottom: size * 0.08,
|
|
214
|
+
width: size * 0.7,
|
|
215
|
+
height: size * 0.44,
|
|
216
|
+
borderWidth: thickness,
|
|
217
|
+
borderTopWidth: 0,
|
|
218
|
+
borderColor: color,
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
</View>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Person glyph for conversations with no assigned agent. */
|
|
226
|
+
export function PersonIcon({ size = 18, color = palette.white, style }: IconProps) {
|
|
227
|
+
const thickness = Math.max(1.5, size * 0.11);
|
|
228
|
+
return (
|
|
229
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
230
|
+
<View
|
|
231
|
+
style={{
|
|
232
|
+
position: 'absolute',
|
|
233
|
+
top: size * 0.06,
|
|
234
|
+
width: size * 0.42,
|
|
235
|
+
height: size * 0.42,
|
|
236
|
+
borderRadius: size * 0.21,
|
|
237
|
+
borderWidth: thickness,
|
|
238
|
+
borderColor: color,
|
|
239
|
+
}}
|
|
240
|
+
/>
|
|
241
|
+
<View
|
|
242
|
+
style={{
|
|
243
|
+
position: 'absolute',
|
|
244
|
+
bottom: size * 0.06,
|
|
245
|
+
width: size * 0.74,
|
|
246
|
+
height: size * 0.3,
|
|
247
|
+
borderTopLeftRadius: size * 0.37,
|
|
248
|
+
borderTopRightRadius: size * 0.37,
|
|
249
|
+
borderWidth: thickness,
|
|
250
|
+
borderBottomWidth: 0,
|
|
251
|
+
borderColor: color,
|
|
252
|
+
}}
|
|
253
|
+
/>
|
|
254
|
+
</View>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Circle-with-bang used on the offline notice. */
|
|
259
|
+
export function AlertIcon({ size = 16, color = palette.warningIcon, style }: IconProps) {
|
|
260
|
+
return (
|
|
261
|
+
<View
|
|
262
|
+
style={[
|
|
263
|
+
{
|
|
264
|
+
width: size,
|
|
265
|
+
height: size,
|
|
266
|
+
borderRadius: size / 2,
|
|
267
|
+
borderWidth: Math.max(1.5, size * 0.12),
|
|
268
|
+
borderColor: color,
|
|
269
|
+
},
|
|
270
|
+
styles.center,
|
|
271
|
+
style,
|
|
272
|
+
]}>
|
|
273
|
+
<View
|
|
274
|
+
style={{
|
|
275
|
+
width: Math.max(1.5, size * 0.12),
|
|
276
|
+
height: size * 0.34,
|
|
277
|
+
backgroundColor: color,
|
|
278
|
+
marginBottom: 1,
|
|
279
|
+
}}
|
|
280
|
+
/>
|
|
281
|
+
<View
|
|
282
|
+
style={{
|
|
283
|
+
width: Math.max(1.5, size * 0.12),
|
|
284
|
+
height: Math.max(1.5, size * 0.12),
|
|
285
|
+
backgroundColor: color,
|
|
286
|
+
}}
|
|
287
|
+
/>
|
|
288
|
+
</View>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function PaperclipIcon({ size = 18, color = palette.textMuted, style }: IconProps) {
|
|
293
|
+
const thickness = Math.max(1.5, size * 0.1);
|
|
294
|
+
return (
|
|
295
|
+
<View style={[{ width: size, height: size }, styles.center, style]}>
|
|
296
|
+
<View
|
|
297
|
+
style={{
|
|
298
|
+
width: size * 0.42,
|
|
299
|
+
height: size * 0.82,
|
|
300
|
+
borderRadius: size * 0.21,
|
|
301
|
+
borderWidth: thickness,
|
|
302
|
+
borderColor: color,
|
|
303
|
+
transform: [{ rotate: '35deg' }],
|
|
304
|
+
}}
|
|
305
|
+
/>
|
|
306
|
+
</View>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const styles = StyleSheet.create({
|
|
311
|
+
center: {
|
|
312
|
+
alignItems: 'center',
|
|
313
|
+
justifyContent: 'center',
|
|
314
|
+
},
|
|
315
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How far the keyboard covers the widget panel, in dp.
|
|
3
|
+
*
|
|
4
|
+
* The panel is a `<Modal>` that reaches the bottom of the screen, so the
|
|
5
|
+
* keyboard's own height is the whole story: what it reports is what has to be
|
|
6
|
+
* given back, less whatever the layout has already conceded down there.
|
|
7
|
+
*
|
|
8
|
+
* Measuring the panel does not work, and neither does RN's
|
|
9
|
+
* `<KeyboardAvoidingView>`, which is built on the same measurement. Both read a
|
|
10
|
+
* view's position out of the shadow tree, which places it relative to the
|
|
11
|
+
* surface root, while the keyboard frame arrives in screen coordinates. An iOS
|
|
12
|
+
* page sheet starts some 60dp down the screen, so the two disagree by exactly
|
|
13
|
+
* that much and the composer ends up under the keyboard with only its top
|
|
14
|
+
* border showing.
|
|
15
|
+
*
|
|
16
|
+
* What counts as already conceded differs by platform. iOS never resizes its
|
|
17
|
+
* window for the keyboard, so it is the safe-area padding the panel already
|
|
18
|
+
* keeps below itself. Android modals ask for `adjustResize`, so the window
|
|
19
|
+
* usually gives up the height itself and nothing more is owed; when it does not
|
|
20
|
+
* — an edge-to-edge window stays put — the whole keyboard still is. Either way
|
|
21
|
+
* the difference shows up in the panel's own height, so that is where the
|
|
22
|
+
* shrink is read from. RN already nets the navigation bar out of the height it
|
|
23
|
+
* reports on Android, so the safe-area inset must not come off twice there.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
27
|
+
import { Keyboard, LayoutAnimation, Platform } from 'react-native';
|
|
28
|
+
import type { KeyboardEvent, KeyboardEventName, LayoutChangeEvent } from 'react-native';
|
|
29
|
+
|
|
30
|
+
// iOS announces the keyboard before it moves, so the layout can travel with
|
|
31
|
+
// it; Android only reports the keyboard once it has settled.
|
|
32
|
+
const SHOW_EVENT: KeyboardEventName =
|
|
33
|
+
Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
|
|
34
|
+
const HIDE_EVENT: KeyboardEventName =
|
|
35
|
+
Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
|
36
|
+
|
|
37
|
+
/** Android is the only platform whose window gives up height to the keyboard. */
|
|
38
|
+
const WINDOW_RESIZES = Platform.OS === 'android';
|
|
39
|
+
|
|
40
|
+
export interface KeyboardOverlap {
|
|
41
|
+
/** Bottom padding, in dp, that keeps the panel clear of the keyboard. */
|
|
42
|
+
overlap: number;
|
|
43
|
+
/** Goes on the padded view; its height is how the Android resize is spotted. */
|
|
44
|
+
onLayout: (event: LayoutChangeEvent) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function useKeyboardOverlap(enabled: boolean, bottomInset: number): KeyboardOverlap {
|
|
48
|
+
const [overlap, setOverlap] = useState(0);
|
|
49
|
+
// Mirrors `overlap` for the handlers, which must not re-subscribe on it.
|
|
50
|
+
const applied = useRef(0);
|
|
51
|
+
const keyboardHeight = useRef(0);
|
|
52
|
+
// The panel's height with no keyboard, and its height now. Taking the tallest
|
|
53
|
+
// seen keeps an Android resize that lands before the keyboard event from
|
|
54
|
+
// being mistaken for the resting height.
|
|
55
|
+
const restingHeight = useRef(0);
|
|
56
|
+
const currentHeight = useRef(0);
|
|
57
|
+
|
|
58
|
+
const apply = useCallback((next: number, event?: KeyboardEvent) => {
|
|
59
|
+
if (Math.abs(next - applied.current) < 1) return;
|
|
60
|
+
applied.current = next;
|
|
61
|
+
|
|
62
|
+
// Riding the keyboard's own duration and curve keeps the composer glued to
|
|
63
|
+
// it, and leaves the work in the native layout pass instead of re-laying
|
|
64
|
+
// out the message list from JS on every frame. Android reports a duration
|
|
65
|
+
// of 0 and animates nothing, which is what the guard falls through to.
|
|
66
|
+
const duration = event?.duration ?? 0;
|
|
67
|
+
const easing = event?.easing;
|
|
68
|
+
if (duration > 10 && easing) {
|
|
69
|
+
LayoutAnimation.configureNext({
|
|
70
|
+
duration,
|
|
71
|
+
update: {
|
|
72
|
+
duration,
|
|
73
|
+
type: LayoutAnimation.Types[easing] ?? LayoutAnimation.Types.keyboard,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setOverlap(next);
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const recompute = useCallback(
|
|
82
|
+
(event?: KeyboardEvent) => {
|
|
83
|
+
const alreadyClear = WINDOW_RESIZES
|
|
84
|
+
? Math.max(restingHeight.current - currentHeight.current, 0)
|
|
85
|
+
: bottomInset;
|
|
86
|
+
const height = keyboardHeight.current;
|
|
87
|
+
apply(Math.min(Math.max(height - alreadyClear, 0), height), event);
|
|
88
|
+
},
|
|
89
|
+
[apply, bottomInset]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const onLayout = useCallback(
|
|
93
|
+
(event: LayoutChangeEvent) => {
|
|
94
|
+
// Only Android has a shrink to read, and only there can it land after the
|
|
95
|
+
// keyboard event and leave the first answer stale.
|
|
96
|
+
if (!WINDOW_RESIZES) return;
|
|
97
|
+
const { height } = event.nativeEvent.layout;
|
|
98
|
+
currentHeight.current = height;
|
|
99
|
+
restingHeight.current = Math.max(restingHeight.current, height);
|
|
100
|
+
if (keyboardHeight.current > 0) recompute();
|
|
101
|
+
},
|
|
102
|
+
[recompute]
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!enabled) {
|
|
107
|
+
keyboardHeight.current = 0;
|
|
108
|
+
restingHeight.current = 0;
|
|
109
|
+
apply(0);
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const handleShow = (event: KeyboardEvent) => {
|
|
114
|
+
keyboardHeight.current = event.endCoordinates?.height ?? 0;
|
|
115
|
+
recompute(event);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleHide = (event: KeyboardEvent) => {
|
|
119
|
+
keyboardHeight.current = 0;
|
|
120
|
+
recompute(event);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const subscriptions = [
|
|
124
|
+
Keyboard.addListener(SHOW_EVENT, handleShow),
|
|
125
|
+
Keyboard.addListener(HIDE_EVENT, handleHide),
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
subscriptions.forEach((subscription) => subscription.remove());
|
|
130
|
+
};
|
|
131
|
+
}, [apply, enabled, recompute]);
|
|
132
|
+
|
|
133
|
+
return { overlap, onLayout };
|
|
134
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared reduce-motion check. The query is async, so the answer is cached for
|
|
3
|
+
* the process: the setting rarely changes mid-session, and re-asking on every
|
|
4
|
+
* mount would let the first frame animate before the answer arrives.
|
|
5
|
+
*
|
|
6
|
+
* Returns `null` until resolved, which callers should read as "hold still" —
|
|
7
|
+
* starting an animation and snapping it away a frame later is the flicker this
|
|
8
|
+
* is meant to avoid.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useEffect, useState } from 'react';
|
|
12
|
+
import { AccessibilityInfo } from 'react-native';
|
|
13
|
+
|
|
14
|
+
let cached: boolean | null = null;
|
|
15
|
+
|
|
16
|
+
export function useReduceMotion(): boolean | null {
|
|
17
|
+
const [value, setValue] = useState<boolean | null>(cached);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (cached !== null) return undefined;
|
|
21
|
+
let alive = true;
|
|
22
|
+
|
|
23
|
+
AccessibilityInfo.isReduceMotionEnabled()
|
|
24
|
+
.then((enabled) => {
|
|
25
|
+
cached = enabled;
|
|
26
|
+
if (alive) setValue(enabled);
|
|
27
|
+
})
|
|
28
|
+
.catch(() => {
|
|
29
|
+
cached = false;
|
|
30
|
+
if (alive) setValue(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
alive = false;
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-area insets without a hard dependency.
|
|
3
|
+
*
|
|
4
|
+
* RN's own `SafeAreaView` is deprecated (and iOS-only), so we use the host
|
|
5
|
+
* app's `react-native-safe-area-context` when it is installed and fall back to
|
|
6
|
+
* platform constants otherwise. Resolution happens once at module load, so the
|
|
7
|
+
* hook call order is stable across renders.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Platform, StatusBar } from 'react-native';
|
|
11
|
+
|
|
12
|
+
export interface WidgetInsets {
|
|
13
|
+
top: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
left: number;
|
|
16
|
+
right: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const FALLBACK_INSETS: WidgetInsets = {
|
|
20
|
+
top: Platform.OS === 'android' ? (StatusBar.currentHeight ?? 0) : 0,
|
|
21
|
+
bottom: 0,
|
|
22
|
+
left: 0,
|
|
23
|
+
right: 0,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let insetsHook: (() => WidgetInsets) | null = null;
|
|
27
|
+
try {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
29
|
+
const mod = require('react-native-safe-area-context');
|
|
30
|
+
if (typeof mod?.useSafeAreaInsets === 'function') insetsHook = mod.useSafeAreaInsets;
|
|
31
|
+
} catch {
|
|
32
|
+
insetsHook = null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useWidgetInsets(): WidgetInsets {
|
|
36
|
+
if (!insetsHook) return FALLBACK_INSETS;
|
|
37
|
+
try {
|
|
38
|
+
return insetsHook();
|
|
39
|
+
} catch {
|
|
40
|
+
// The host mounted no <SafeAreaProvider>; the hook itself still ran, so
|
|
41
|
+
// React's hook order is unchanged.
|
|
42
|
+
return FALLBACK_INSETS;
|
|
43
|
+
}
|
|
44
|
+
}
|