@crafter/rn-ai-elements 0.0.1
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/lib/commonjs/chatbot/AIImage.js +126 -0
- package/lib/commonjs/chatbot/AIImage.js.map +1 -0
- package/lib/commonjs/chatbot/Attachments.js +317 -0
- package/lib/commonjs/chatbot/Attachments.js.map +1 -0
- package/lib/commonjs/chatbot/ChatErrorBoundary.js +201 -0
- package/lib/commonjs/chatbot/ChatErrorBoundary.js.map +1 -0
- package/lib/commonjs/chatbot/ChatMessageItem.js +169 -0
- package/lib/commonjs/chatbot/ChatMessageItem.js.map +1 -0
- package/lib/commonjs/chatbot/Conversation.js +415 -0
- package/lib/commonjs/chatbot/Conversation.js.map +1 -0
- package/lib/commonjs/chatbot/ConversationScrollButton.js +131 -0
- package/lib/commonjs/chatbot/ConversationScrollButton.js.map +1 -0
- package/lib/commonjs/chatbot/Message.js +203 -0
- package/lib/commonjs/chatbot/Message.js.map +1 -0
- package/lib/commonjs/chatbot/PromptInput.js +352 -0
- package/lib/commonjs/chatbot/PromptInput.js.map +1 -0
- package/lib/commonjs/chatbot/Reasoning.js +184 -0
- package/lib/commonjs/chatbot/Reasoning.js.map +1 -0
- package/lib/commonjs/chatbot/Shimmer.js +116 -0
- package/lib/commonjs/chatbot/Shimmer.js.map +1 -0
- package/lib/commonjs/chatbot/Sources.js +212 -0
- package/lib/commonjs/chatbot/Sources.js.map +1 -0
- package/lib/commonjs/chatbot/Suggestion.js +99 -0
- package/lib/commonjs/chatbot/Suggestion.js.map +1 -0
- package/lib/commonjs/chatbot/Tool.js +307 -0
- package/lib/commonjs/chatbot/Tool.js.map +1 -0
- package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js +141 -0
- package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js.map +1 -0
- package/lib/commonjs/chatbot/index.js +140 -0
- package/lib/commonjs/chatbot/index.js.map +1 -0
- package/lib/commonjs/chatbot/types.js +6 -0
- package/lib/commonjs/chatbot/types.js.map +1 -0
- package/lib/commonjs/hooks/index.js +34 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useAutoScroll.js +39 -0
- package/lib/commonjs/hooks/useAutoScroll.js.map +1 -0
- package/lib/commonjs/hooks/useClipboard.js +44 -0
- package/lib/commonjs/hooks/useClipboard.js.map +1 -0
- package/lib/commonjs/hooks/useCollapsible.js +35 -0
- package/lib/commonjs/hooks/useCollapsible.js.map +1 -0
- package/lib/commonjs/hooks/useStickToBottom.js +68 -0
- package/lib/commonjs/hooks/useStickToBottom.js.map +1 -0
- package/lib/commonjs/index.js +257 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/primitives/Badge.js +119 -0
- package/lib/commonjs/primitives/Badge.js.map +1 -0
- package/lib/commonjs/primitives/Button.js +185 -0
- package/lib/commonjs/primitives/Button.js.map +1 -0
- package/lib/commonjs/primitives/Card.js +166 -0
- package/lib/commonjs/primitives/Card.js.map +1 -0
- package/lib/commonjs/primitives/Collapsible.js +137 -0
- package/lib/commonjs/primitives/Collapsible.js.map +1 -0
- package/lib/commonjs/primitives/ScrollArea.js +40 -0
- package/lib/commonjs/primitives/ScrollArea.js.map +1 -0
- package/lib/commonjs/primitives/index.js +83 -0
- package/lib/commonjs/primitives/index.js.map +1 -0
- package/lib/commonjs/streaming/StreamingMarkdown.js +252 -0
- package/lib/commonjs/streaming/StreamingMarkdown.js.map +1 -0
- package/lib/commonjs/streaming/index.js +13 -0
- package/lib/commonjs/streaming/index.js.map +1 -0
- package/lib/commonjs/streaming/parser.js +482 -0
- package/lib/commonjs/streaming/parser.js.map +1 -0
- package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js +35 -0
- package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/CodeRenderer.js +128 -0
- package/lib/commonjs/streaming/renderers/CodeRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/HeadingRenderer.js +61 -0
- package/lib/commonjs/streaming/renderers/HeadingRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/ImageRenderer.js +53 -0
- package/lib/commonjs/streaming/renderers/ImageRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/LinkRenderer.js +49 -0
- package/lib/commonjs/streaming/renderers/LinkRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/ListRenderer.js +63 -0
- package/lib/commonjs/streaming/renderers/ListRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/TableRenderer.js +77 -0
- package/lib/commonjs/streaming/renderers/TableRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/TextRenderer.js +41 -0
- package/lib/commonjs/streaming/renderers/TextRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/index.js +76 -0
- package/lib/commonjs/streaming/renderers/index.js.map +1 -0
- package/lib/commonjs/streaming/renderers/renderInlineChildren.js +112 -0
- package/lib/commonjs/streaming/renderers/renderInlineChildren.js.map +1 -0
- package/lib/commonjs/streaming/renderers/renderNode.js +81 -0
- package/lib/commonjs/streaming/renderers/renderNode.js.map +1 -0
- package/lib/commonjs/theme/ThemeProvider.js +68 -0
- package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theme/defaultTheme.js +96 -0
- package/lib/commonjs/theme/defaultTheme.js.map +1 -0
- package/lib/commonjs/theme/index.js +32 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/tokens.js +2 -0
- package/lib/commonjs/theme/tokens.js.map +1 -0
- package/lib/commonjs/types.d.js +2 -0
- package/lib/commonjs/types.d.js.map +1 -0
- package/lib/commonjs/voice/index.js +13 -0
- package/lib/commonjs/voice/index.js.map +1 -0
- package/lib/commonjs/voice/useSpeechRecognition.js +172 -0
- package/lib/commonjs/voice/useSpeechRecognition.js.map +1 -0
- package/lib/module/chatbot/AIImage.js +121 -0
- package/lib/module/chatbot/AIImage.js.map +1 -0
- package/lib/module/chatbot/Attachments.js +312 -0
- package/lib/module/chatbot/Attachments.js.map +1 -0
- package/lib/module/chatbot/ChatErrorBoundary.js +196 -0
- package/lib/module/chatbot/ChatErrorBoundary.js.map +1 -0
- package/lib/module/chatbot/ChatMessageItem.js +164 -0
- package/lib/module/chatbot/ChatMessageItem.js.map +1 -0
- package/lib/module/chatbot/Conversation.js +412 -0
- package/lib/module/chatbot/Conversation.js.map +1 -0
- package/lib/module/chatbot/ConversationScrollButton.js +126 -0
- package/lib/module/chatbot/ConversationScrollButton.js.map +1 -0
- package/lib/module/chatbot/Message.js +198 -0
- package/lib/module/chatbot/Message.js.map +1 -0
- package/lib/module/chatbot/PromptInput.js +347 -0
- package/lib/module/chatbot/PromptInput.js.map +1 -0
- package/lib/module/chatbot/Reasoning.js +179 -0
- package/lib/module/chatbot/Reasoning.js.map +1 -0
- package/lib/module/chatbot/Shimmer.js +111 -0
- package/lib/module/chatbot/Shimmer.js.map +1 -0
- package/lib/module/chatbot/Sources.js +207 -0
- package/lib/module/chatbot/Sources.js.map +1 -0
- package/lib/module/chatbot/Suggestion.js +94 -0
- package/lib/module/chatbot/Suggestion.js.map +1 -0
- package/lib/module/chatbot/Tool.js +303 -0
- package/lib/module/chatbot/Tool.js.map +1 -0
- package/lib/module/chatbot/adapters/uiMessageAdapter.js +137 -0
- package/lib/module/chatbot/adapters/uiMessageAdapter.js.map +1 -0
- package/lib/module/chatbot/index.js +39 -0
- package/lib/module/chatbot/index.js.map +1 -0
- package/lib/module/chatbot/types.js +4 -0
- package/lib/module/chatbot/types.js.map +1 -0
- package/lib/module/hooks/index.js +7 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useAutoScroll.js +35 -0
- package/lib/module/hooks/useAutoScroll.js.map +1 -0
- package/lib/module/hooks/useClipboard.js +40 -0
- package/lib/module/hooks/useClipboard.js.map +1 -0
- package/lib/module/hooks/useCollapsible.js +31 -0
- package/lib/module/hooks/useCollapsible.js.map +1 -0
- package/lib/module/hooks/useStickToBottom.js +64 -0
- package/lib/module/hooks/useStickToBottom.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/primitives/Badge.js +114 -0
- package/lib/module/primitives/Badge.js.map +1 -0
- package/lib/module/primitives/Button.js +180 -0
- package/lib/module/primitives/Button.js.map +1 -0
- package/lib/module/primitives/Card.js +156 -0
- package/lib/module/primitives/Card.js.map +1 -0
- package/lib/module/primitives/Collapsible.js +130 -0
- package/lib/module/primitives/Collapsible.js.map +1 -0
- package/lib/module/primitives/ScrollArea.js +35 -0
- package/lib/module/primitives/ScrollArea.js.map +1 -0
- package/lib/module/primitives/index.js +8 -0
- package/lib/module/primitives/index.js.map +1 -0
- package/lib/module/streaming/StreamingMarkdown.js +246 -0
- package/lib/module/streaming/StreamingMarkdown.js.map +1 -0
- package/lib/module/streaming/index.js +4 -0
- package/lib/module/streaming/index.js.map +1 -0
- package/lib/module/streaming/parser.js +477 -0
- package/lib/module/streaming/parser.js.map +1 -0
- package/lib/module/streaming/renderers/BlockquoteRenderer.js +30 -0
- package/lib/module/streaming/renderers/BlockquoteRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/CodeRenderer.js +123 -0
- package/lib/module/streaming/renderers/CodeRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/HeadingRenderer.js +56 -0
- package/lib/module/streaming/renderers/HeadingRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/ImageRenderer.js +48 -0
- package/lib/module/streaming/renderers/ImageRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/LinkRenderer.js +44 -0
- package/lib/module/streaming/renderers/LinkRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/ListRenderer.js +58 -0
- package/lib/module/streaming/renderers/ListRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/TableRenderer.js +72 -0
- package/lib/module/streaming/renderers/TableRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/TextRenderer.js +36 -0
- package/lib/module/streaming/renderers/TextRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/index.js +13 -0
- package/lib/module/streaming/renderers/index.js.map +1 -0
- package/lib/module/streaming/renderers/renderInlineChildren.js +107 -0
- package/lib/module/streaming/renderers/renderInlineChildren.js.map +1 -0
- package/lib/module/streaming/renderers/renderNode.js +78 -0
- package/lib/module/streaming/renderers/renderNode.js.map +1 -0
- package/lib/module/theme/ThemeProvider.js +62 -0
- package/lib/module/theme/ThemeProvider.js.map +1 -0
- package/lib/module/theme/defaultTheme.js +92 -0
- package/lib/module/theme/defaultTheme.js.map +1 -0
- package/lib/module/theme/index.js +5 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/tokens.js +2 -0
- package/lib/module/theme/tokens.js.map +1 -0
- package/lib/module/types.d.js +2 -0
- package/lib/module/types.d.js.map +1 -0
- package/lib/module/voice/index.js +14 -0
- package/lib/module/voice/index.js.map +1 -0
- package/lib/module/voice/useSpeechRecognition.js +169 -0
- package/lib/module/voice/useSpeechRecognition.js.map +1 -0
- package/lib/typescript/src/chatbot/AIImage.d.ts +24 -0
- package/lib/typescript/src/chatbot/AIImage.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Attachments.d.ts +20 -0
- package/lib/typescript/src/chatbot/Attachments.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts +57 -0
- package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/ChatMessageItem.d.ts +45 -0
- package/lib/typescript/src/chatbot/ChatMessageItem.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Conversation.d.ts +94 -0
- package/lib/typescript/src/chatbot/Conversation.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts +62 -0
- package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Message.d.ts +39 -0
- package/lib/typescript/src/chatbot/Message.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/PromptInput.d.ts +93 -0
- package/lib/typescript/src/chatbot/PromptInput.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Reasoning.d.ts +14 -0
- package/lib/typescript/src/chatbot/Reasoning.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Shimmer.d.ts +13 -0
- package/lib/typescript/src/chatbot/Shimmer.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Sources.d.ts +17 -0
- package/lib/typescript/src/chatbot/Sources.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Suggestion.d.ts +15 -0
- package/lib/typescript/src/chatbot/Suggestion.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Tool.d.ts +30 -0
- package/lib/typescript/src/chatbot/Tool.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts +24 -0
- package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/index.d.ts +29 -0
- package/lib/typescript/src/chatbot/index.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/types.d.ts +49 -0
- package/lib/typescript/src/chatbot/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +9 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAutoScroll.d.ts +23 -0
- package/lib/typescript/src/hooks/useAutoScroll.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useClipboard.d.ts +22 -0
- package/lib/typescript/src/hooks/useClipboard.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCollapsible.d.ts +28 -0
- package/lib/typescript/src/hooks/useCollapsible.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStickToBottom.d.ts +39 -0
- package/lib/typescript/src/hooks/useStickToBottom.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Badge.d.ts +10 -0
- package/lib/typescript/src/primitives/Badge.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Button.d.ts +16 -0
- package/lib/typescript/src/primitives/Button.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Card.d.ts +33 -0
- package/lib/typescript/src/primitives/Card.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Collapsible.d.ts +20 -0
- package/lib/typescript/src/primitives/Collapsible.d.ts.map +1 -0
- package/lib/typescript/src/primitives/ScrollArea.d.ts +10 -0
- package/lib/typescript/src/primitives/ScrollArea.d.ts.map +1 -0
- package/lib/typescript/src/primitives/index.d.ts +11 -0
- package/lib/typescript/src/primitives/index.d.ts.map +1 -0
- package/lib/typescript/src/streaming/StreamingMarkdown.d.ts +47 -0
- package/lib/typescript/src/streaming/StreamingMarkdown.d.ts.map +1 -0
- package/lib/typescript/src/streaming/index.d.ts +3 -0
- package/lib/typescript/src/streaming/index.d.ts.map +1 -0
- package/lib/typescript/src/streaming/parser.d.ts +41 -0
- package/lib/typescript/src/streaming/parser.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/index.d.ts +19 -0
- package/lib/typescript/src/streaming/renderers/index.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts +12 -0
- package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/renderNode.d.ts +8 -0
- package/lib/typescript/src/streaming/renderers/renderNode.d.ts.map +1 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts +14 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts +4 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +5 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens.d.ts +66 -0
- package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
- package/lib/typescript/src/voice/index.d.ts +3 -0
- package/lib/typescript/src/voice/index.d.ts.map +1 -0
- package/lib/typescript/src/voice/useSpeechRecognition.d.ts +77 -0
- package/lib/typescript/src/voice/useSpeechRecognition.d.ts.map +1 -0
- package/package.json +132 -0
- package/src/chatbot/AIImage.tsx +166 -0
- package/src/chatbot/Attachments.tsx +382 -0
- package/src/chatbot/ChatErrorBoundary.tsx +230 -0
- package/src/chatbot/ChatMessageItem.tsx +195 -0
- package/src/chatbot/Conversation.tsx +537 -0
- package/src/chatbot/ConversationScrollButton.tsx +149 -0
- package/src/chatbot/Message.tsx +266 -0
- package/src/chatbot/PromptInput.tsx +532 -0
- package/src/chatbot/Reasoning.tsx +198 -0
- package/src/chatbot/Shimmer.tsx +146 -0
- package/src/chatbot/Sources.tsx +263 -0
- package/src/chatbot/Suggestion.tsx +123 -0
- package/src/chatbot/Tool.tsx +340 -0
- package/src/chatbot/adapters/uiMessageAdapter.ts +177 -0
- package/src/chatbot/index.ts +97 -0
- package/src/chatbot/types.ts +66 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/useAutoScroll.ts +43 -0
- package/src/hooks/useClipboard.ts +46 -0
- package/src/hooks/useCollapsible.ts +42 -0
- package/src/hooks/useStickToBottom.ts +82 -0
- package/src/index.ts +139 -0
- package/src/primitives/Badge.tsx +119 -0
- package/src/primitives/Button.tsx +213 -0
- package/src/primitives/Card.tsx +221 -0
- package/src/primitives/Collapsible.tsx +168 -0
- package/src/primitives/ScrollArea.tsx +53 -0
- package/src/primitives/index.ts +36 -0
- package/src/streaming/StreamingMarkdown.tsx +282 -0
- package/src/streaming/index.ts +2 -0
- package/src/streaming/parser.ts +506 -0
- package/src/streaming/renderers/BlockquoteRenderer.tsx +42 -0
- package/src/streaming/renderers/CodeRenderer.tsx +158 -0
- package/src/streaming/renderers/HeadingRenderer.tsx +64 -0
- package/src/streaming/renderers/ImageRenderer.tsx +62 -0
- package/src/streaming/renderers/LinkRenderer.tsx +53 -0
- package/src/streaming/renderers/ListRenderer.tsx +65 -0
- package/src/streaming/renderers/TableRenderer.tsx +103 -0
- package/src/streaming/renderers/TextRenderer.tsx +39 -0
- package/src/streaming/renderers/index.ts +26 -0
- package/src/streaming/renderers/renderInlineChildren.tsx +115 -0
- package/src/streaming/renderers/renderNode.tsx +72 -0
- package/src/theme/ThemeProvider.tsx +77 -0
- package/src/theme/defaultTheme.ts +93 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/tokens.ts +69 -0
- package/src/types.d.ts +71 -0
- package/src/voice/index.ts +15 -0
- package/src/voice/useSpeechRecognition.ts +230 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const sharedTokens = {
|
|
4
|
+
spacing: {
|
|
5
|
+
xs: 4,
|
|
6
|
+
sm: 8,
|
|
7
|
+
md: 12,
|
|
8
|
+
lg: 16,
|
|
9
|
+
xl: 24,
|
|
10
|
+
'2xl': 32
|
|
11
|
+
},
|
|
12
|
+
radius: {
|
|
13
|
+
sm: 6,
|
|
14
|
+
md: 10,
|
|
15
|
+
lg: 16,
|
|
16
|
+
full: 9999
|
|
17
|
+
},
|
|
18
|
+
typography: {
|
|
19
|
+
fontFamily: 'System',
|
|
20
|
+
monoFontFamily: 'monospace',
|
|
21
|
+
fontSize: {
|
|
22
|
+
xs: 11,
|
|
23
|
+
sm: 13,
|
|
24
|
+
md: 15,
|
|
25
|
+
lg: 17,
|
|
26
|
+
xl: 20,
|
|
27
|
+
'2xl': 24
|
|
28
|
+
},
|
|
29
|
+
lineHeight: {
|
|
30
|
+
tight: 1.25,
|
|
31
|
+
normal: 1.5,
|
|
32
|
+
relaxed: 1.75
|
|
33
|
+
},
|
|
34
|
+
fontWeight: {
|
|
35
|
+
normal: '400',
|
|
36
|
+
medium: '500',
|
|
37
|
+
semibold: '600',
|
|
38
|
+
bold: '700'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const lightTheme = {
|
|
43
|
+
...sharedTokens,
|
|
44
|
+
dark: false,
|
|
45
|
+
colors: {
|
|
46
|
+
primary: '#18181B',
|
|
47
|
+
primaryForeground: '#FAFAFA',
|
|
48
|
+
secondary: '#F4F4F5',
|
|
49
|
+
secondaryForeground: '#18181B',
|
|
50
|
+
background: '#FFFFFF',
|
|
51
|
+
foreground: '#09090B',
|
|
52
|
+
muted: '#F4F4F5',
|
|
53
|
+
mutedForeground: '#71717A',
|
|
54
|
+
card: '#FFFFFF',
|
|
55
|
+
cardForeground: '#09090B',
|
|
56
|
+
border: '#E4E4E7',
|
|
57
|
+
destructive: '#EF4444',
|
|
58
|
+
destructiveForeground: '#FAFAFA',
|
|
59
|
+
success: '#22C55E',
|
|
60
|
+
successForeground: '#FAFAFA',
|
|
61
|
+
warning: '#F59E0B',
|
|
62
|
+
warningForeground: '#18181B',
|
|
63
|
+
accent: '#F4F4F5',
|
|
64
|
+
accentForeground: '#18181B'
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
export const darkTheme = {
|
|
68
|
+
...sharedTokens,
|
|
69
|
+
dark: true,
|
|
70
|
+
colors: {
|
|
71
|
+
primary: '#FAFAFA',
|
|
72
|
+
primaryForeground: '#18181B',
|
|
73
|
+
secondary: '#27272A',
|
|
74
|
+
secondaryForeground: '#FAFAFA',
|
|
75
|
+
background: '#09090B',
|
|
76
|
+
foreground: '#FAFAFA',
|
|
77
|
+
muted: '#27272A',
|
|
78
|
+
mutedForeground: '#A1A1AA',
|
|
79
|
+
card: '#09090B',
|
|
80
|
+
cardForeground: '#FAFAFA',
|
|
81
|
+
border: '#27272A',
|
|
82
|
+
destructive: '#DC2626',
|
|
83
|
+
destructiveForeground: '#FAFAFA',
|
|
84
|
+
success: '#16A34A',
|
|
85
|
+
successForeground: '#FAFAFA',
|
|
86
|
+
warning: '#D97706',
|
|
87
|
+
warningForeground: '#FAFAFA',
|
|
88
|
+
accent: '#27272A',
|
|
89
|
+
accentForeground: '#FAFAFA'
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=defaultTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sharedTokens","spacing","xs","sm","md","lg","xl","radius","full","typography","fontFamily","monoFontFamily","fontSize","lineHeight","tight","normal","relaxed","fontWeight","medium","semibold","bold","lightTheme","dark","colors","primary","primaryForeground","secondary","secondaryForeground","background","foreground","muted","mutedForeground","card","cardForeground","border","destructive","destructiveForeground","success","successForeground","warning","warningForeground","accent","accentForeground","darkTheme"],"sourceRoot":"../../../src","sources":["theme/defaultTheme.ts"],"mappings":";;AAEA,MAAMA,YAAwE,GAAG;EAC/EC,OAAO,EAAE;IACPC,EAAE,EAAE,CAAC;IACLC,EAAE,EAAE,CAAC;IACLC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACN,KAAK,EAAE;EACT,CAAC;EACDC,MAAM,EAAE;IACNJ,EAAE,EAAE,CAAC;IACLC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNG,IAAI,EAAE;EACR,CAAC;EACDC,UAAU,EAAE;IACVC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,WAAW;IAC3BC,QAAQ,EAAE;MACRV,EAAE,EAAE,EAAE;MACNC,EAAE,EAAE,EAAE;MACNC,EAAE,EAAE,EAAE;MACNC,EAAE,EAAE,EAAE;MACNC,EAAE,EAAE,EAAE;MACN,KAAK,EAAE;IACT,CAAC;IACDO,UAAU,EAAE;MACVC,KAAK,EAAE,IAAI;MACXC,MAAM,EAAE,GAAG;MACXC,OAAO,EAAE;IACX,CAAC;IACDC,UAAU,EAAE;MACVF,MAAM,EAAE,KAAK;MACbG,MAAM,EAAE,KAAK;MACbC,QAAQ,EAAE,KAAK;MACfC,IAAI,EAAE;IACR;EACF;AACF,CAAC;AAED,OAAO,MAAMC,UAA2B,GAAG;EACzC,GAAGrB,YAAY;EACfsB,IAAI,EAAE,KAAK;EACXC,MAAM,EAAE;IACNC,OAAO,EAAE,SAAS;IAClBC,iBAAiB,EAAE,SAAS;IAC5BC,SAAS,EAAE,SAAS;IACpBC,mBAAmB,EAAE,SAAS;IAC9BC,UAAU,EAAE,SAAS;IACrBC,UAAU,EAAE,SAAS;IACrBC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAE,SAAS;IAC1BC,IAAI,EAAE,SAAS;IACfC,cAAc,EAAE,SAAS;IACzBC,MAAM,EAAE,SAAS;IACjBC,WAAW,EAAE,SAAS;IACtBC,qBAAqB,EAAE,SAAS;IAChCC,OAAO,EAAE,SAAS;IAClBC,iBAAiB,EAAE,SAAS;IAC5BC,OAAO,EAAE,SAAS;IAClBC,iBAAiB,EAAE,SAAS;IAC5BC,MAAM,EAAE,SAAS;IACjBC,gBAAgB,EAAE;EACpB;AACF,CAAC;AAED,OAAO,MAAMC,SAA0B,GAAG;EACxC,GAAG3C,YAAY;EACfsB,IAAI,EAAE,IAAI;EACVC,MAAM,EAAE;IACNC,OAAO,EAAE,SAAS;IAClBC,iBAAiB,EAAE,SAAS;IAC5BC,SAAS,EAAE,SAAS;IACpBC,mBAAmB,EAAE,SAAS;IAC9BC,UAAU,EAAE,SAAS;IACrBC,UAAU,EAAE,SAAS;IACrBC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAE,SAAS;IAC1BC,IAAI,EAAE,SAAS;IACfC,cAAc,EAAE,SAAS;IACzBC,MAAM,EAAE,SAAS;IACjBC,WAAW,EAAE,SAAS;IACtBC,qBAAqB,EAAE,SAAS;IAChCC,OAAO,EAAE,SAAS;IAClBC,iBAAiB,EAAE,SAAS;IAC5BC,OAAO,EAAE,SAAS;IAClBC,iBAAiB,EAAE,SAAS;IAC5BC,MAAM,EAAE,SAAS;IACjBC,gBAAgB,EAAE;EACpB;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AIElementsProvider","useAIElementsTheme","lightTheme","darkTheme"],"sourceRoot":"../../../src","sources":["theme/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,kBAAkB,QAAQ,iBAAiB;AAGxE,SAASC,UAAU,EAAEC,SAAS,QAAQ,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["theme/tokens.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// @crafter/rn-ai-elements/voice — speech-recognition hook
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
//
|
|
7
|
+
// This subpath export exists so consumers who want voice input install
|
|
8
|
+
// `expo-speech-recognition` themselves (it's an optional peer dep) and
|
|
9
|
+
// import from `@crafter/rn-ai-elements/voice`. Consumers who don't want
|
|
10
|
+
// voice input never trigger the import and don't need the peer dep.
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
export { useSpeechRecognition } from './useSpeechRecognition';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSpeechRecognition"],"sourceRoot":"../../../src","sources":["voice/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,wBAAwB","ignoreList":[]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef, useState } from 'react';
|
|
4
|
+
import { ExpoSpeechRecognitionModule, useSpeechRecognitionEvent } from 'expo-speech-recognition';
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// useSpeechRecognition — React wrapper around ExpoSpeechRecognitionModule
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
//
|
|
10
|
+
// Wraps the imperative `ExpoSpeechRecognitionModule.start / stop / abort`
|
|
11
|
+
// API with React state so a component can just read `isListening` +
|
|
12
|
+
// `transcript` and call `start()` / `stop()` / `toggle()`. Handles:
|
|
13
|
+
//
|
|
14
|
+
// - Permission request + gating (asks once, then uses the cached result)
|
|
15
|
+
// - Transcript accumulation across interim and final results
|
|
16
|
+
// - Automatic cleanup if the component unmounts mid-recognition
|
|
17
|
+
// - Error surfacing as a discriminated `error` state
|
|
18
|
+
//
|
|
19
|
+
// **Peer dependency:** this hook imports from `expo-speech-recognition`,
|
|
20
|
+
// which is declared as an **optional** peer dependency of
|
|
21
|
+
// `@crafter/rn-ai-elements`. Consumers who don't want voice input don't
|
|
22
|
+
// have to install it — they just don't import from
|
|
23
|
+
// `@crafter/rn-ai-elements/voice`. Consumers who do want voice input
|
|
24
|
+
// install `expo-speech-recognition` themselves, add its config plugin to
|
|
25
|
+
// `app.json`, and rebuild the native app.
|
|
26
|
+
//
|
|
27
|
+
// Intentionally minimal: no language picker, no contextual biasing, no
|
|
28
|
+
// audio persistence. Covers the common case of "tap mic, speak, text
|
|
29
|
+
// appears in the input field" and nothing more — add config props later
|
|
30
|
+
// if a consumer needs them.
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
const DEFAULT_LANG = 'en-US';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* React hook wrapping `expo-speech-recognition` for chat-style voice input.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { useSpeechRecognition } from '@crafter/rn-ai-elements/voice';
|
|
41
|
+
*
|
|
42
|
+
* const { isListening, transcript, toggle } = useSpeechRecognition({
|
|
43
|
+
* onFinalResult: (text) => console.log('final:', text),
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Pipe transcript into your input state
|
|
47
|
+
* useEffect(() => {
|
|
48
|
+
* if (transcript) setInput(transcript);
|
|
49
|
+
* }, [transcript]);
|
|
50
|
+
*
|
|
51
|
+
* // Wire the mic button
|
|
52
|
+
* <PromptInput
|
|
53
|
+
* value={input}
|
|
54
|
+
* onChangeText={setInput}
|
|
55
|
+
* isListening={isListening}
|
|
56
|
+
* onMicPress={toggle}
|
|
57
|
+
* ...
|
|
58
|
+
* />
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function useSpeechRecognition(options = {}) {
|
|
62
|
+
const {
|
|
63
|
+
lang = DEFAULT_LANG,
|
|
64
|
+
interimResults = true,
|
|
65
|
+
continuous = false,
|
|
66
|
+
addsPunctuation = true,
|
|
67
|
+
onFinalResult
|
|
68
|
+
} = options;
|
|
69
|
+
const [isListening, setIsListening] = useState(false);
|
|
70
|
+
const [transcript, setTranscript] = useState('');
|
|
71
|
+
const [error, setError] = useState(null);
|
|
72
|
+
|
|
73
|
+
// Keep the latest onFinalResult in a ref so consumers don't have to
|
|
74
|
+
// memoize it to avoid re-registering listeners.
|
|
75
|
+
const onFinalResultRef = useRef(onFinalResult);
|
|
76
|
+
onFinalResultRef.current = onFinalResult;
|
|
77
|
+
|
|
78
|
+
// --- Native event listeners (auto-cleanup on unmount) -------------------
|
|
79
|
+
|
|
80
|
+
useSpeechRecognitionEvent('start', () => {
|
|
81
|
+
setIsListening(true);
|
|
82
|
+
setError(null);
|
|
83
|
+
});
|
|
84
|
+
useSpeechRecognitionEvent('end', () => {
|
|
85
|
+
setIsListening(false);
|
|
86
|
+
});
|
|
87
|
+
useSpeechRecognitionEvent('result', event => {
|
|
88
|
+
// `event.results` is an array of alternatives; the first entry is the
|
|
89
|
+
// best transcript per the platform's ranking. We only render that one.
|
|
90
|
+
const best = event.results[0]?.transcript ?? '';
|
|
91
|
+
setTranscript(best);
|
|
92
|
+
if (event.isFinal) {
|
|
93
|
+
onFinalResultRef.current?.(best);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
useSpeechRecognitionEvent('error', event => {
|
|
97
|
+
// `no-speech` is a soft "nothing was said" signal, not a hard error —
|
|
98
|
+
// it still fires `end` afterwards, so just surface it quietly.
|
|
99
|
+
setError({
|
|
100
|
+
code: event.error,
|
|
101
|
+
message: event.message
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// --- Control methods -----------------------------------------------------
|
|
106
|
+
|
|
107
|
+
const start = useCallback(async () => {
|
|
108
|
+
// Check current permissions first, only prompt if they're missing —
|
|
109
|
+
// requesting every time is jarring and will hit the dialog dismissal
|
|
110
|
+
// cap on iOS.
|
|
111
|
+
const current = await ExpoSpeechRecognitionModule.getPermissionsAsync();
|
|
112
|
+
if (!current.granted) {
|
|
113
|
+
const requested = await ExpoSpeechRecognitionModule.requestPermissionsAsync();
|
|
114
|
+
if (!requested.granted) {
|
|
115
|
+
setError({
|
|
116
|
+
code: 'not-allowed',
|
|
117
|
+
message: 'Speech recognition permission was denied. Enable it in Settings to use voice input.'
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Fresh run → clear any stale transcript/error from the previous turn.
|
|
124
|
+
setTranscript('');
|
|
125
|
+
setError(null);
|
|
126
|
+
const recognitionOptions = {
|
|
127
|
+
lang,
|
|
128
|
+
interimResults,
|
|
129
|
+
continuous,
|
|
130
|
+
addsPunctuation
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
ExpoSpeechRecognitionModule.start(recognitionOptions);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
setError({
|
|
136
|
+
code: 'client',
|
|
137
|
+
message: err instanceof Error ? err.message : String(err)
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, [lang, interimResults, continuous, addsPunctuation]);
|
|
141
|
+
const stop = useCallback(() => {
|
|
142
|
+
try {
|
|
143
|
+
ExpoSpeechRecognitionModule.stop();
|
|
144
|
+
} catch {
|
|
145
|
+
// If stop is called while not listening it's a no-op — swallow.
|
|
146
|
+
}
|
|
147
|
+
}, []);
|
|
148
|
+
const toggle = useCallback(async () => {
|
|
149
|
+
if (isListening) {
|
|
150
|
+
stop();
|
|
151
|
+
} else {
|
|
152
|
+
await start();
|
|
153
|
+
}
|
|
154
|
+
}, [isListening, start, stop]);
|
|
155
|
+
const reset = useCallback(() => {
|
|
156
|
+
setTranscript('');
|
|
157
|
+
setError(null);
|
|
158
|
+
}, []);
|
|
159
|
+
return {
|
|
160
|
+
isListening,
|
|
161
|
+
transcript,
|
|
162
|
+
error,
|
|
163
|
+
start,
|
|
164
|
+
stop,
|
|
165
|
+
toggle,
|
|
166
|
+
reset
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=useSpeechRecognition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useState","ExpoSpeechRecognitionModule","useSpeechRecognitionEvent","DEFAULT_LANG","useSpeechRecognition","options","lang","interimResults","continuous","addsPunctuation","onFinalResult","isListening","setIsListening","transcript","setTranscript","error","setError","onFinalResultRef","current","event","best","results","isFinal","code","message","start","getPermissionsAsync","granted","requested","requestPermissionsAsync","recognitionOptions","err","Error","String","stop","toggle","reset"],"sourceRoot":"../../../src","sources":["voice/useSpeechRecognition.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
export type AIImageSource = {
|
|
4
|
+
uri: string;
|
|
5
|
+
base64?: never;
|
|
6
|
+
mimeType?: never;
|
|
7
|
+
} | {
|
|
8
|
+
base64: string;
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
uri?: never;
|
|
11
|
+
};
|
|
12
|
+
export interface AIImageProps {
|
|
13
|
+
source: AIImageSource;
|
|
14
|
+
alt?: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
resizeMode?: 'cover' | 'contain' | 'stretch';
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
onPress?: () => void;
|
|
20
|
+
}
|
|
21
|
+
declare function AIImageComponent({ source, alt, width: explicitWidth, height: explicitHeight, resizeMode, style, onPress, }: AIImageProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const AIImage: React.MemoExoticComponent<typeof AIImageComponent>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=AIImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIImage.d.ts","sourceRoot":"","sources":["../../../../src/chatbot/AIImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAQtB,MAAM,MAAM,aAAa,GACrB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7C,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAkBD,iBAAS,gBAAgB,CAAC,EACxB,MAAM,EACN,GAAG,EACH,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,EACtB,UAAoB,EACpB,KAAK,EACL,OAAO,GACR,EAAE,YAAY,2CAyFd;AAoBD,eAAO,MAAM,OAAO,oDAAyB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
export interface Attachment {
|
|
4
|
+
type: 'image' | 'file';
|
|
5
|
+
name: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
uri?: string;
|
|
8
|
+
mimeType?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
}
|
|
11
|
+
export type AttachmentVariant = 'grid' | 'inline' | 'list';
|
|
12
|
+
export interface AttachmentsProps {
|
|
13
|
+
attachments: Attachment[];
|
|
14
|
+
variant?: AttachmentVariant;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
}
|
|
17
|
+
declare function AttachmentsComponent({ attachments, variant, style, }: AttachmentsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
export declare const Attachments: React.MemoExoticComponent<typeof AttachmentsComponent>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=Attachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Attachments.d.ts","sourceRoot":"","sources":["../../../../src/chatbot/Attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AACpC,OAAO,EAQL,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAQtB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AA0RD,iBAAS,oBAAoB,CAAC,EAC5B,WAAW,EACX,OAAkB,EAClB,KAAK,GACN,EAAE,gBAAgB,kDAalB;AA+CD,eAAO,MAAM,WAAW,wDAA6B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { Component, type ReactNode } from 'react';
|
|
2
|
+
export interface ChatErrorBoundaryProps {
|
|
3
|
+
/** The protected subtree. Errors thrown during render are caught here. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Optional custom fallback. Receives the caught error and a reset
|
|
7
|
+
* callback that clears the boundary back to the children.
|
|
8
|
+
*/
|
|
9
|
+
fallback?: (error: Error, reset: () => void) => ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Called once when the boundary catches an error. Useful for forwarding
|
|
12
|
+
* to crash reporting (Sentry, Bugsnag, etc).
|
|
13
|
+
*/
|
|
14
|
+
onError?: (error: Error, errorInfo: {
|
|
15
|
+
componentStack: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
/**
|
|
18
|
+
* When any value in this array changes between renders, the boundary
|
|
19
|
+
* automatically resets. Use this for cases like "the user navigated to a
|
|
20
|
+
* new message id" — re-rendering with a different id should clear a
|
|
21
|
+
* previously caught error.
|
|
22
|
+
*/
|
|
23
|
+
resetKeys?: ReadonlyArray<unknown>;
|
|
24
|
+
}
|
|
25
|
+
interface ChatErrorBoundaryState {
|
|
26
|
+
error: Error | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Class-component boundary that wraps individual chat messages. If a single
|
|
30
|
+
* message's render throws (e.g. malformed markdown, a tool call with bad
|
|
31
|
+
* JSON), only that bubble shows a fallback — the rest of the conversation
|
|
32
|
+
* keeps working.
|
|
33
|
+
*
|
|
34
|
+
* React doesn't expose hooks for error boundaries, so this **must** stay a
|
|
35
|
+
* class component. The themed fallback is delegated to a sibling functional
|
|
36
|
+
* component so it can read the theme via hooks.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <ChatErrorBoundary resetKeys={[message.id]}>
|
|
41
|
+
* <MessageRenderer message={message} />
|
|
42
|
+
* </ChatErrorBoundary>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class ChatErrorBoundary extends Component<ChatErrorBoundaryProps, ChatErrorBoundaryState> {
|
|
46
|
+
static displayName: string;
|
|
47
|
+
state: ChatErrorBoundaryState;
|
|
48
|
+
static getDerivedStateFromError(error: Error): ChatErrorBoundaryState;
|
|
49
|
+
componentDidCatch(error: Error, errorInfo: {
|
|
50
|
+
componentStack: string;
|
|
51
|
+
}): void;
|
|
52
|
+
componentDidUpdate(prev: ChatErrorBoundaryProps): void;
|
|
53
|
+
reset: () => void;
|
|
54
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=ChatErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/chatbot/ChatErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AASzD,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IAC1D;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACpC;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAuBD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,iBAAkB,SAAQ,SAAS,CAC9C,sBAAsB,EACtB,sBAAsB,CACvB;IACC,MAAM,CAAC,WAAW,SAAuB;IAEzC,KAAK,EAAE,sBAAsB,CAAmB;IAEhD,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,sBAAsB;IAIrE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;IAgBrE,kBAAkB,CAAC,IAAI,EAAE,sBAAsB;IAY/C,KAAK,aAEH;IAEF,MAAM;CAUP"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChatMessageData } from './types';
|
|
3
|
+
export interface ChatMessageItemProps {
|
|
4
|
+
/**
|
|
5
|
+
* The message to render, in the canonical {@link ChatMessageData} shape.
|
|
6
|
+
* Map your own message type to this shape inside `renderMessage`.
|
|
7
|
+
*/
|
|
8
|
+
item: ChatMessageData;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated No longer applied — `StreamingMarkdown` matches Vercel
|
|
11
|
+
* ai-elements' `memo(Streamdown)` pattern and performs no custom fade
|
|
12
|
+
* animation. Kept in the props for backwards compatibility so existing
|
|
13
|
+
* call sites don't break; safe to remove.
|
|
14
|
+
*/
|
|
15
|
+
fadeDuration?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Renders a single chat message — either a user bubble (delegated to the
|
|
19
|
+
* library's `Message` compound) or an assistant block composed of optional
|
|
20
|
+
* reasoning, tool call, streaming markdown, and sources.
|
|
21
|
+
*
|
|
22
|
+
* Wrapped in `React.memo` with a custom equality function below: rows only
|
|
23
|
+
* re-render when their own `item` content actually changes, **not** when an
|
|
24
|
+
* unrelated message updates elsewhere in the list. The equality function
|
|
25
|
+
* compares fields directly so callers can safely build a fresh
|
|
26
|
+
* `ChatMessageData` object on every render — identity churn is fine.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const renderMessage = useCallback(
|
|
31
|
+
* (raw: MyMessage) => {
|
|
32
|
+
* const data: ChatMessageData = toChatMessageData(raw);
|
|
33
|
+
* return <ChatMessageItem item={data} />;
|
|
34
|
+
* },
|
|
35
|
+
* [],
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function ChatMessageItemImpl({ item }: ChatMessageItemProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
declare namespace ChatMessageItemImpl {
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
43
|
+
export declare const ChatMessageItem: React.MemoExoticComponent<typeof ChatMessageItemImpl>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=ChatMessageItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatMessageItem.d.ts","sourceRoot":"","sources":["../../../../src/chatbot/ChatMessageItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAM/C,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,IAAI,EAAE,eAAe,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,mBAAmB,CAAC,EAAE,IAAI,EAAE,EAAE,oBAAoB,2CAgE1D;kBAhEQ,mBAAmB;;;AA2H5B,eAAO,MAAM,eAAe,uDAA4C,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type ViewProps } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* Minimum shape Conversation requires from a message. Most chat libraries
|
|
5
|
+
* (the Vercel `ai` SDK, OpenAI's `ChatMessage`, Anthropic's `Message`) all
|
|
6
|
+
* satisfy this contract via `id` + `role`.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConversationMessage {
|
|
9
|
+
id: string;
|
|
10
|
+
/** Optional — used by the default `isUserMessage` predicate. */
|
|
11
|
+
role?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Order in which `messages` is provided. */
|
|
14
|
+
export type ConversationMessageOrder = 'oldest-first' | 'newest-first';
|
|
15
|
+
/**
|
|
16
|
+
* How `Conversation` reacts to new messages and content growth.
|
|
17
|
+
*
|
|
18
|
+
* - `'anchor-user-message'` *(default)* — When a new user message arrives,
|
|
19
|
+
* scroll it to the top of the viewport and use dynamic bottom padding so
|
|
20
|
+
* the assistant response streams downward beneath it. Auto-scroll on
|
|
21
|
+
* collapsible expansion (e.g. opening a Sources block) when the user is
|
|
22
|
+
* already near the bottom and not currently streaming. This mimics how
|
|
23
|
+
* ChatGPT, Claude, and Vercel ai-elements anchor each new turn.
|
|
24
|
+
* - `'stick-to-bottom'` — Classic chat behavior: always follow the bottom
|
|
25
|
+
* on any content size change, even mid-stream. The list "sticks" to the
|
|
26
|
+
* newest content. Matches what `use-stick-to-bottom` does on the web.
|
|
27
|
+
* - `'none'` — Disable all automatic scrolling and dynamic padding. The
|
|
28
|
+
* consumer is fully responsible for managing scroll position via the
|
|
29
|
+
* imperative `ConversationRef`.
|
|
30
|
+
*/
|
|
31
|
+
export type ConversationScrollBehavior = 'anchor-user-message' | 'stick-to-bottom' | 'none';
|
|
32
|
+
/** Imperative handle exposed via ref. */
|
|
33
|
+
export interface ConversationRef {
|
|
34
|
+
/** Scroll to a given display index, optionally animated. */
|
|
35
|
+
scrollToIndex: (index: number, opts?: {
|
|
36
|
+
animated?: boolean;
|
|
37
|
+
viewPosition?: number;
|
|
38
|
+
}) => void;
|
|
39
|
+
/** Scroll to the top of the list (oldest message). */
|
|
40
|
+
scrollToTop: (opts?: {
|
|
41
|
+
animated?: boolean;
|
|
42
|
+
}) => void;
|
|
43
|
+
/** Scroll to the bottom of the list (newest message). */
|
|
44
|
+
scrollToBottom: (opts?: {
|
|
45
|
+
animated?: boolean;
|
|
46
|
+
}) => void;
|
|
47
|
+
/** Whether the user is currently scrolled near the bottom of content. */
|
|
48
|
+
isAtBottom: () => boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface ConversationProps<T extends ConversationMessage> extends Omit<ViewProps, 'children'> {
|
|
51
|
+
/** Imperative handle. Use `useRef<ConversationRef>(null)` and pass it here. */
|
|
52
|
+
ref?: Ref<ConversationRef>;
|
|
53
|
+
/** The conversation messages. Order is controlled by the `order` prop. */
|
|
54
|
+
messages: T[];
|
|
55
|
+
/** Render a single message. Called for each item in display order. */
|
|
56
|
+
renderMessage: (item: T) => ReactNode;
|
|
57
|
+
/** Rendered when `messages` is empty. Filled to the chat area (`flex: 1`). */
|
|
58
|
+
emptyState?: ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the assistant is currently generating. While true, content
|
|
61
|
+
* growth from streaming is **not** auto-scrolled — the user-message
|
|
62
|
+
* anchor takes precedence. Once it flips back to false, content growth
|
|
63
|
+
* (e.g. expanding a Sources / Reasoning collapsible) auto-scrolls if
|
|
64
|
+
* the user was already near the bottom.
|
|
65
|
+
*/
|
|
66
|
+
isStreaming?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Order of items in the `messages` array. Defaults to `'oldest-first'`,
|
|
69
|
+
* matching what `@ai-sdk/react`'s `useChat()` and most LLM SDKs return.
|
|
70
|
+
* Use `'newest-first'` if your state is built with `[newMsg, ...prev]`.
|
|
71
|
+
*/
|
|
72
|
+
order?: ConversationMessageOrder;
|
|
73
|
+
/**
|
|
74
|
+
* Predicate for identifying user messages — used to anchor the most
|
|
75
|
+
* recent user message to the top of the viewport when it appears.
|
|
76
|
+
* Defaults to `(m) => m.role === 'user'`.
|
|
77
|
+
*/
|
|
78
|
+
isUserMessage?: (item: T) => boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Push-based notification when the "near the bottom" state changes.
|
|
81
|
+
* Fires once on each transition (true → false or false → true), driven
|
|
82
|
+
* by either user scroll events or content-size growth from streaming.
|
|
83
|
+
* Use this to drive a floating scroll-to-bottom button — see
|
|
84
|
+
* `ConversationScrollButton`.
|
|
85
|
+
*/
|
|
86
|
+
onIsAtBottomChange?: (isAtBottom: boolean) => void;
|
|
87
|
+
/**
|
|
88
|
+
* How to react to new messages and content growth. Defaults to
|
|
89
|
+
* `'anchor-user-message'`. See {@link ConversationScrollBehavior}.
|
|
90
|
+
*/
|
|
91
|
+
scrollBehavior?: ConversationScrollBehavior;
|
|
92
|
+
}
|
|
93
|
+
export declare const Conversation: <T extends ConversationMessage>(props: ConversationProps<T>) => ReactElement;
|
|
94
|
+
//# sourceMappingURL=Conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conversation.d.ts","sourceRoot":"","sources":["../../../../src/chatbot/Conversation.tsx"],"names":[],"mappings":"AAAA,OAAc,EAQZ,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAqBtB;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,6CAA6C;AAC7C,MAAM,MAAM,wBAAwB,GAAG,cAAc,GAAG,cAAc,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,0BAA0B,GAClC,qBAAqB,GACrB,iBAAiB,GACjB,MAAM,CAAC;AAEX,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,aAAa,EAAE,CACb,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,KACjD,IAAI,CAAC;IACV,sDAAsD;IACtD,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACrD,yDAAyD;IACzD,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACxD,yEAAyE;IACzE,UAAU,EAAE,MAAM,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,mBAAmB,CAC9D,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IACnC,+EAA+E;IAC/E,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,sEAAsE;IACtE,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC;IACtC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,wBAAwB,CAAC;IACjC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IACrC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACnD;;;OAGG;IACH,cAAc,CAAC,EAAE,0BAA0B,CAAC;CAC7C;AAgYD,eAAO,MAAM,YAAY,EAA8B,CACrD,CAAC,SAAS,mBAAmB,EAE7B,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KACxB,YAAY,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
export interface ConversationScrollButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the button is currently visible. When false, the component
|
|
5
|
+
* returns `null` (mount/unmount instead of fade) so the underlying
|
|
6
|
+
* `GlassView` native view is never wrapped in something Reanimated
|
|
7
|
+
* touches — see the comment block below for why that matters.
|
|
8
|
+
*/
|
|
9
|
+
visible: boolean;
|
|
10
|
+
/** Press handler — typically calls `conversationRef.current.scrollToBottom()`. */
|
|
11
|
+
onPress: () => void;
|
|
12
|
+
/** Outer style for the floating wrapper (use for absolute positioning). */
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
/** Optional accessibility label override. */
|
|
15
|
+
accessibilityLabel?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A floating circle button that appears when the user has scrolled away
|
|
19
|
+
* from the bottom of a conversation, and disappears when they return.
|
|
20
|
+
*
|
|
21
|
+
* Designed to sit in the chat area's bottom-left corner so it visually
|
|
22
|
+
* stacks above the PromptInput's Plus button — same size, same glass
|
|
23
|
+
* treatment, same press feedback. Pairs with
|
|
24
|
+
* `<Conversation onIsAtBottomChange={...} />`: the parent screen tracks
|
|
25
|
+
* the boolean and passes it as `visible`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const [isAtBottom, setIsAtBottom] = useState(true);
|
|
30
|
+
* const ref = useRef<ConversationRef>(null);
|
|
31
|
+
*
|
|
32
|
+
* <View style={{ flex: 1 }}>
|
|
33
|
+
* <Conversation
|
|
34
|
+
* ref={ref}
|
|
35
|
+
* onIsAtBottomChange={setIsAtBottom}
|
|
36
|
+
* ...
|
|
37
|
+
* />
|
|
38
|
+
* <ConversationScrollButton
|
|
39
|
+
* visible={!isAtBottom}
|
|
40
|
+
* onPress={() => ref.current?.scrollToBottom()}
|
|
41
|
+
* style={{ position: 'absolute', left: 12, bottom: 12 }}
|
|
42
|
+
* />
|
|
43
|
+
* </View>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* **Why no fade animation?**
|
|
47
|
+
* Earlier iterations wrapped this in a Reanimated `Animated.View` for a
|
|
48
|
+
* smooth fade-in/out. On the iOS simulator (and likely device) the
|
|
49
|
+
* `expo-glass-effect` `GlassView` would render correctly on first mount
|
|
50
|
+
* but lose its glass material after a Fast Refresh or reload. Reanimated
|
|
51
|
+
* drives styles on the UI thread via a code path that conflicts with
|
|
52
|
+
* `expo-glass-effect`'s custom native view manager — the prop diff that
|
|
53
|
+
* re-applies the glass layer never reaches the native view. Dropping the
|
|
54
|
+
* animation wrapper and using a plain conditional render keeps the
|
|
55
|
+
* GlassView in exactly the same context as the working `Plus` button
|
|
56
|
+
* inside `PromptInput.CircleButton`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function ConversationScrollButton({ visible, onPress, style, accessibilityLabel, }: ConversationScrollButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
59
|
+
export declare namespace ConversationScrollButton {
|
|
60
|
+
var displayName: string;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ConversationScrollButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationScrollButton.d.ts","sourceRoot":"","sources":["../../../../src/chatbot/ConversationScrollButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAStB,MAAM,WAAW,6BAA6B;IAC5C;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,OAAO,EACP,KAAK,EACL,kBAA+C,GAChD,EAAE,6BAA6B,kDA+B/B;yBApCe,wBAAwB"}
|