@datalayer/agent-runtimes 0.0.2
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/LICENSE +32 -0
- package/README.md +56 -0
- package/lib/App.css +47 -0
- package/lib/App.d.ts +3 -0
- package/lib/App.js +18 -0
- package/lib/components/chat/components/AgentDetails.d.ts +19 -0
- package/lib/components/chat/components/AgentDetails.js +170 -0
- package/lib/components/chat/components/Chat.d.ts +105 -0
- package/lib/components/chat/components/Chat.js +275 -0
- package/lib/components/chat/components/ChatFloating.d.ts +146 -0
- package/lib/components/chat/components/ChatFloating.js +381 -0
- package/lib/components/chat/components/ChatInline.d.ts +42 -0
- package/lib/components/chat/components/ChatInline.js +327 -0
- package/lib/components/chat/components/ChatPopupStandalone.d.ts +110 -0
- package/lib/components/chat/components/ChatPopupStandalone.js +422 -0
- package/lib/components/chat/components/ChatSidebar.d.ts +78 -0
- package/lib/components/chat/components/ChatSidebar.js +224 -0
- package/lib/components/chat/components/ChatStandalone.d.ts +105 -0
- package/lib/components/chat/components/ChatStandalone.js +320 -0
- package/lib/components/chat/components/base/ChatBase.d.ts +285 -0
- package/lib/components/chat/components/base/ChatBase.js +1192 -0
- package/lib/components/chat/components/display/ToolCallDisplay.d.ts +26 -0
- package/lib/components/chat/components/display/ToolCallDisplay.js +225 -0
- package/lib/components/chat/components/display/index.d.ts +6 -0
- package/lib/components/chat/components/display/index.js +10 -0
- package/lib/components/chat/components/elements/ChatHeader.d.ts +43 -0
- package/lib/components/chat/components/elements/ChatHeader.js +67 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.d.ts +26 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.js +145 -0
- package/lib/components/chat/components/elements/ChatMessages.d.ts +36 -0
- package/lib/components/chat/components/elements/ChatMessages.js +195 -0
- package/lib/components/chat/components/elements/FloatingBrandButton.d.ts +34 -0
- package/lib/components/chat/components/elements/FloatingBrandButton.js +88 -0
- package/lib/components/chat/components/elements/MessagePart.d.ts +50 -0
- package/lib/components/chat/components/elements/MessagePart.js +48 -0
- package/lib/components/chat/components/elements/PoweredByTag.d.ts +26 -0
- package/lib/components/chat/components/elements/PoweredByTag.js +33 -0
- package/lib/components/chat/components/elements/ToolApprovalDialog.d.ts +42 -0
- package/lib/components/chat/components/elements/ToolApprovalDialog.js +96 -0
- package/lib/components/chat/components/index.d.ts +21 -0
- package/lib/components/chat/components/index.js +34 -0
- package/lib/components/chat/components/parts/DynamicToolPart.d.ts +20 -0
- package/lib/components/chat/components/parts/DynamicToolPart.js +13 -0
- package/lib/components/chat/components/parts/ReasoningPart.d.ts +17 -0
- package/lib/components/chat/components/parts/ReasoningPart.js +69 -0
- package/lib/components/chat/components/parts/TextPart.d.ts +28 -0
- package/lib/components/chat/components/parts/TextPart.js +103 -0
- package/lib/components/chat/components/parts/ToolPart.d.ts +17 -0
- package/lib/components/chat/components/parts/ToolPart.js +163 -0
- package/lib/components/chat/components/parts/index.d.ts +9 -0
- package/lib/components/chat/components/parts/index.js +13 -0
- package/lib/components/chat/extensions/A2UIExtension.d.ts +87 -0
- package/lib/components/chat/extensions/A2UIExtension.js +312 -0
- package/lib/components/chat/extensions/ExtensionRegistry.d.ts +66 -0
- package/lib/components/chat/extensions/ExtensionRegistry.js +128 -0
- package/lib/components/chat/extensions/MCPUIExtension.d.ts +77 -0
- package/lib/components/chat/extensions/MCPUIExtension.js +212 -0
- package/lib/components/chat/extensions/index.d.ts +9 -0
- package/lib/components/chat/extensions/index.js +12 -0
- package/lib/components/chat/handler.d.ts +20 -0
- package/lib/components/chat/handler.js +56 -0
- package/lib/components/chat/index.d.ts +61 -0
- package/lib/components/chat/index.js +76 -0
- package/lib/components/chat/inference/BaseInferenceProvider.d.ts +57 -0
- package/lib/components/chat/inference/BaseInferenceProvider.js +69 -0
- package/lib/components/chat/inference/DatalayerInferenceProvider.d.ts +83 -0
- package/lib/components/chat/inference/DatalayerInferenceProvider.js +305 -0
- package/lib/components/chat/inference/SelfHostedInferenceProvider.d.ts +54 -0
- package/lib/components/chat/inference/SelfHostedInferenceProvider.js +246 -0
- package/lib/components/chat/inference/index.d.ts +9 -0
- package/lib/components/chat/inference/index.js +12 -0
- package/lib/components/chat/middleware/MiddlewarePipeline.d.ts +118 -0
- package/lib/components/chat/middleware/MiddlewarePipeline.js +255 -0
- package/lib/components/chat/middleware/index.d.ts +7 -0
- package/lib/components/chat/middleware/index.js +10 -0
- package/lib/components/chat/protocols/A2AAdapter.d.ts +79 -0
- package/lib/components/chat/protocols/A2AAdapter.js +388 -0
- package/lib/components/chat/protocols/ACPAdapter.d.ts +161 -0
- package/lib/components/chat/protocols/ACPAdapter.js +504 -0
- package/lib/components/chat/protocols/AGUIAdapter.d.ts +82 -0
- package/lib/components/chat/protocols/AGUIAdapter.js +518 -0
- package/lib/components/chat/protocols/BaseProtocolAdapter.d.ts +75 -0
- package/lib/components/chat/protocols/BaseProtocolAdapter.js +119 -0
- package/lib/components/chat/protocols/VercelAIAdapter.d.ts +77 -0
- package/lib/components/chat/protocols/VercelAIAdapter.js +252 -0
- package/lib/components/chat/protocols/index.d.ts +11 -0
- package/lib/components/chat/protocols/index.js +14 -0
- package/lib/components/chat/store/chatStore.d.ts +158 -0
- package/lib/components/chat/store/chatStore.js +313 -0
- package/lib/components/chat/store/index.d.ts +6 -0
- package/lib/components/chat/store/index.js +10 -0
- package/lib/components/chat/tools/ToolExecutor.d.ts +49 -0
- package/lib/components/chat/tools/ToolExecutor.js +151 -0
- package/lib/components/chat/tools/index.d.ts +8 -0
- package/lib/components/chat/tools/index.js +11 -0
- package/lib/components/chat/types/extension.d.ts +181 -0
- package/lib/components/chat/types/extension.js +46 -0
- package/lib/components/chat/types/index.d.ts +11 -0
- package/lib/components/chat/types/index.js +16 -0
- package/lib/components/chat/types/inference.d.ts +117 -0
- package/lib/components/chat/types/inference.js +5 -0
- package/lib/components/chat/types/message.d.ts +117 -0
- package/lib/components/chat/types/message.js +50 -0
- package/lib/components/chat/types/middleware.d.ts +153 -0
- package/lib/components/chat/types/middleware.js +32 -0
- package/lib/components/chat/types/protocol.d.ts +209 -0
- package/lib/components/chat/types/protocol.js +5 -0
- package/lib/components/chat/types/tool.d.ts +140 -0
- package/lib/components/chat/types/tool.js +23 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +6 -0
- package/lib/components/sparklines/Sparklines.d.ts +16 -0
- package/lib/components/sparklines/Sparklines.js +65 -0
- package/lib/components/sparklines/SparklinesLine.d.ts +8 -0
- package/lib/components/sparklines/SparklinesLine.js +37 -0
- package/lib/components/sparklines/dataProcessing.d.ts +25 -0
- package/lib/components/sparklines/dataProcessing.js +35 -0
- package/lib/components/sparklines/index.d.ts +4 -0
- package/lib/components/sparklines/index.js +7 -0
- package/lib/components/sparklines/types.d.ts +36 -0
- package/lib/components/sparklines/types.js +5 -0
- package/lib/components/ui/accordion.d.ts +7 -0
- package/lib/components/ui/accordion.js +22 -0
- package/lib/components/ui/alert-dialog.d.ts +14 -0
- package/lib/components/ui/alert-dialog.js +43 -0
- package/lib/components/ui/alert.d.ts +9 -0
- package/lib/components/ui/alert.js +24 -0
- package/lib/components/ui/aspect-ratio.d.ts +3 -0
- package/lib/components/ui/aspect-ratio.js +11 -0
- package/lib/components/ui/avatar.d.ts +6 -0
- package/lib/components/ui/avatar.js +18 -0
- package/lib/components/ui/badge.d.ts +9 -0
- package/lib/components/ui/badge.js +22 -0
- package/lib/components/ui/breadcrumb.d.ts +11 -0
- package/lib/components/ui/breadcrumb.js +27 -0
- package/lib/components/ui/button-group.d.ts +11 -0
- package/lib/components/ui/button-group.js +31 -0
- package/lib/components/ui/button.d.ts +13 -0
- package/lib/components/ui/button.js +39 -0
- package/lib/components/ui/calendar.d.ts +8 -0
- package/lib/components/ui/calendar.js +80 -0
- package/lib/components/ui/card.d.ts +9 -0
- package/lib/components/ui/card.js +24 -0
- package/lib/components/ui/carousel.d.ts +19 -0
- package/lib/components/ui/carousel.js +95 -0
- package/lib/components/ui/chart.d.ts +53 -0
- package/lib/components/ui/chart.js +136 -0
- package/lib/components/ui/checkbox.d.ts +4 -0
- package/lib/components/ui/checkbox.js +13 -0
- package/lib/components/ui/collapsible.d.ts +5 -0
- package/lib/components/ui/collapsible.js +17 -0
- package/lib/components/ui/command.d.ts +18 -0
- package/lib/components/ui/command.js +38 -0
- package/lib/components/ui/context-menu.d.ts +25 -0
- package/lib/components/ui/context-menu.js +55 -0
- package/lib/components/ui/dialog.d.ts +15 -0
- package/lib/components/ui/dialog.js +40 -0
- package/lib/components/ui/drawer.d.ts +13 -0
- package/lib/components/ui/drawer.js +39 -0
- package/lib/components/ui/dropdown-menu.d.ts +25 -0
- package/lib/components/ui/dropdown-menu.js +55 -0
- package/lib/components/ui/empty.d.ts +11 -0
- package/lib/components/ui/empty.js +37 -0
- package/lib/components/ui/field.d.ts +24 -0
- package/lib/components/ui/field.js +80 -0
- package/lib/components/ui/form.d.ts +24 -0
- package/lib/components/ui/form.js +63 -0
- package/lib/components/ui/hover-card.d.ts +6 -0
- package/lib/components/ui/hover-card.js +18 -0
- package/lib/components/ui/input-group.d.ts +19 -0
- package/lib/components/ui/input-group.js +69 -0
- package/lib/components/ui/input-otp.d.ts +11 -0
- package/lib/components/ui/input-otp.js +25 -0
- package/lib/components/ui/input.d.ts +3 -0
- package/lib/components/ui/input.js +6 -0
- package/lib/components/ui/item.d.ts +23 -0
- package/lib/components/ui/item.js +66 -0
- package/lib/components/ui/kbd.d.ts +3 -0
- package/lib/components/ui/kbd.js +13 -0
- package/lib/components/ui/label.d.ts +4 -0
- package/lib/components/ui/label.js +12 -0
- package/lib/components/ui/menubar.d.ts +26 -0
- package/lib/components/ui/menubar.js +58 -0
- package/lib/components/ui/navigation-menu.d.ts +14 -0
- package/lib/components/ui/navigation-menu.js +31 -0
- package/lib/components/ui/pagination.d.ts +13 -0
- package/lib/components/ui/pagination.js +29 -0
- package/lib/components/ui/popover.d.ts +7 -0
- package/lib/components/ui/popover.js +21 -0
- package/lib/components/ui/progress.d.ts +4 -0
- package/lib/components/ui/progress.js +12 -0
- package/lib/components/ui/radio-group.d.ts +5 -0
- package/lib/components/ui/radio-group.js +16 -0
- package/lib/components/ui/resizable.d.ts +8 -0
- package/lib/components/ui/resizable.js +19 -0
- package/lib/components/ui/scroll-area.d.ts +5 -0
- package/lib/components/ui/scroll-area.js +17 -0
- package/lib/components/ui/select.d.ts +15 -0
- package/lib/components/ui/select.js +42 -0
- package/lib/components/ui/separator.d.ts +4 -0
- package/lib/components/ui/separator.js +12 -0
- package/lib/components/ui/sheet.d.ts +13 -0
- package/lib/components/ui/sheet.js +44 -0
- package/lib/components/ui/sidebar.d.ts +69 -0
- package/lib/components/ui/sidebar.js +216 -0
- package/lib/components/ui/skeleton.d.ts +2 -0
- package/lib/components/ui/skeleton.js +10 -0
- package/lib/components/ui/slider.d.ts +4 -0
- package/lib/components/ui/slider.js +18 -0
- package/lib/components/ui/sonner.d.ts +3 -0
- package/lib/components/ui/sonner.js +25 -0
- package/lib/components/ui/spinner.d.ts +2 -0
- package/lib/components/ui/spinner.js +11 -0
- package/lib/components/ui/switch.d.ts +4 -0
- package/lib/components/ui/switch.js +12 -0
- package/lib/components/ui/table.d.ts +10 -0
- package/lib/components/ui/table.js +32 -0
- package/lib/components/ui/tabs.d.ts +7 -0
- package/lib/components/ui/tabs.js +21 -0
- package/lib/components/ui/textarea.d.ts +3 -0
- package/lib/components/ui/textarea.js +6 -0
- package/lib/components/ui/toast.d.ts +15 -0
- package/lib/components/ui/toast.js +38 -0
- package/lib/components/ui/toaster.d.ts +1 -0
- package/lib/components/ui/toaster.js +14 -0
- package/lib/components/ui/toggle-group.d.ts +9 -0
- package/lib/components/ui/toggle-group.js +26 -0
- package/lib/components/ui/toggle.d.ts +9 -0
- package/lib/components/ui/toggle.js +30 -0
- package/lib/components/ui/tooltip.d.ts +7 -0
- package/lib/components/ui/tooltip.js +21 -0
- package/lib/components/vercel-ai-elements/artifact.d.ts +23 -0
- package/lib/components/vercel-ai-elements/artifact.js +24 -0
- package/lib/components/vercel-ai-elements/code-block.d.ts +17 -0
- package/lib/components/vercel-ai-elements/code-block.js +94 -0
- package/lib/components/vercel-ai-elements/conversation.d.ts +15 -0
- package/lib/components/vercel-ai-elements/conversation.js +21 -0
- package/lib/components/vercel-ai-elements/loader.d.ts +5 -0
- package/lib/components/vercel-ai-elements/loader.js +8 -0
- package/lib/components/vercel-ai-elements/message.d.ts +46 -0
- package/lib/components/vercel-ai-elements/message.js +109 -0
- package/lib/components/vercel-ai-elements/model-selector.d.ts +35 -0
- package/lib/components/vercel-ai-elements/model-selector.js +22 -0
- package/lib/components/vercel-ai-elements/prompt-input.d.ts +195 -0
- package/lib/components/vercel-ai-elements/prompt-input.js +589 -0
- package/lib/components/vercel-ai-elements/reasoning.d.ts +26 -0
- package/lib/components/vercel-ai-elements/reasoning.js +80 -0
- package/lib/components/vercel-ai-elements/shimmer.d.ts +9 -0
- package/lib/components/vercel-ai-elements/shimmer.js +22 -0
- package/lib/components/vercel-ai-elements/sources.d.ts +12 -0
- package/lib/components/vercel-ai-elements/sources.js +13 -0
- package/lib/components/vercel-ai-elements/suggestion.d.ts +10 -0
- package/lib/components/vercel-ai-elements/suggestion.js +16 -0
- package/lib/components/vercel-ai-elements/tool.d.ts +23 -0
- package/lib/components/vercel-ai-elements/tool.js +52 -0
- package/lib/examples/A2UiRestaurantExample.d.ts +25 -0
- package/lib/examples/A2UiRestaurantExample.js +305 -0
- package/lib/examples/AgUiAgenticExample.d.ts +25 -0
- package/lib/examples/AgUiAgenticExample.js +63 -0
- package/lib/examples/AgUiBackendToolRenderingExample.d.ts +30 -0
- package/lib/examples/AgUiBackendToolRenderingExample.js +103 -0
- package/lib/examples/AgUiHaikuGenUIExample.d.ts +44 -0
- package/lib/examples/AgUiHaikuGenUIExample.js +151 -0
- package/lib/examples/AgUiHumanInTheLoopExample.d.ts +26 -0
- package/lib/examples/AgUiHumanInTheLoopExample.js +220 -0
- package/lib/examples/AgUiSharedStateExample.d.ts +25 -0
- package/lib/examples/AgUiSharedStateExample.js +181 -0
- package/lib/examples/AgUiToolsBasedGenUIExample.d.ts +25 -0
- package/lib/examples/AgUiToolsBasedGenUIExample.js +257 -0
- package/lib/examples/AgentRuntimeCustomExample.d.ts +9 -0
- package/lib/examples/AgentRuntimeCustomExample.js +68 -0
- package/lib/examples/AgentRuntimeLexical2Example.d.ts +42 -0
- package/lib/examples/AgentRuntimeLexical2Example.js +236 -0
- package/lib/examples/AgentRuntimeLexicalExample.d.ts +36 -0
- package/lib/examples/AgentRuntimeLexicalExample.js +260 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +41 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +166 -0
- package/lib/examples/AgentRuntimeNotebookExample.d.ts +9 -0
- package/lib/examples/AgentRuntimeNotebookExample.js +148 -0
- package/lib/examples/AgentRuntimeNotebookSidebarExample.d.ts +13 -0
- package/lib/examples/AgentRuntimeNotebookSidebarExample.js +121 -0
- package/lib/examples/AgentRuntimeStandaloneExample.d.ts +21 -0
- package/lib/examples/AgentRuntimeStandaloneExample.js +158 -0
- package/lib/examples/AgentSpaceFormExample.d.ts +22 -0
- package/lib/examples/AgentSpaceFormExample.js +296 -0
- package/lib/examples/AgentSpaceHomeExample.d.ts +8 -0
- package/lib/examples/AgentSpaceHomeExample.js +171 -0
- package/lib/examples/CopilotKitLexicalExample.d.ts +38 -0
- package/lib/examples/CopilotKitLexicalExample.js +161 -0
- package/lib/examples/CopilotKitNotebookExample.d.ts +11 -0
- package/lib/examples/CopilotKitNotebookExample.js +70 -0
- package/lib/examples/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples/DatalayerNotebookExample.js +99 -0
- package/lib/examples/JupyterCellExample.d.ts +6 -0
- package/lib/examples/JupyterCellExample.js +19 -0
- package/lib/examples/JupyterNotebookExample.d.ts +6 -0
- package/lib/examples/JupyterNotebookExample.js +21 -0
- package/lib/examples/ag-ui/haiku/HaikuDisplay.d.ts +18 -0
- package/lib/examples/ag-ui/haiku/HaikuDisplay.js +110 -0
- package/lib/examples/ag-ui/haiku/InlineHaikuCard.d.ts +39 -0
- package/lib/examples/ag-ui/haiku/InlineHaikuCard.js +117 -0
- package/lib/examples/ag-ui/haiku/index.d.ts +11 -0
- package/lib/examples/ag-ui/haiku/index.js +15 -0
- package/lib/examples/ag-ui/index.d.ts +10 -0
- package/lib/examples/ag-ui/index.js +16 -0
- package/lib/examples/ag-ui/weather/InlineWeatherCard.d.ts +43 -0
- package/lib/examples/ag-ui/weather/InlineWeatherCard.js +180 -0
- package/lib/examples/ag-ui/weather/index.d.ts +9 -0
- package/lib/examples/ag-ui/weather/index.js +13 -0
- package/lib/examples/components/AgentConfiguration.d.ts +50 -0
- package/lib/examples/components/AgentConfiguration.js +115 -0
- package/lib/examples/components/AgentsDataTable.d.ts +13 -0
- package/lib/examples/components/AgentsDataTable.js +74 -0
- package/lib/examples/components/FooterMetrics.d.ts +12 -0
- package/lib/examples/components/FooterMetrics.js +17 -0
- package/lib/examples/components/Header.d.ts +27 -0
- package/lib/examples/components/Header.js +294 -0
- package/lib/examples/components/HeaderControls.d.ts +11 -0
- package/lib/examples/components/HeaderControls.js +24 -0
- package/lib/examples/components/LexicalEditor.d.ts +27 -0
- package/lib/examples/components/LexicalEditor.js +118 -0
- package/lib/examples/components/MainContent.d.ts +19 -0
- package/lib/examples/components/MainContent.js +68 -0
- package/lib/examples/components/MockFileBrowser.d.ts +12 -0
- package/lib/examples/components/MockFileBrowser.js +131 -0
- package/lib/examples/components/Rating.d.ts +14 -0
- package/lib/examples/components/Rating.js +12 -0
- package/lib/examples/components/SessionTabs.d.ts +21 -0
- package/lib/examples/components/SessionTabs.js +11 -0
- package/lib/examples/components/TimeTravel.d.ts +15 -0
- package/lib/examples/components/TimeTravel.js +23 -0
- package/lib/examples/components/index.d.ts +11 -0
- package/lib/examples/components/index.js +14 -0
- package/lib/examples/example-selector.d.ts +22 -0
- package/lib/examples/example-selector.js +62 -0
- package/lib/examples/index.d.ts +21 -0
- package/lib/examples/index.js +25 -0
- package/lib/examples/lexical/editorConfig.d.ts +76 -0
- package/lib/examples/lexical/editorConfig.js +55 -0
- package/lib/examples/lexical/lexical-theme.css +436 -0
- package/lib/examples/lexical/theme.d.ts +61 -0
- package/lib/examples/lexical/theme.js +72 -0
- package/lib/examples/main.d.ts +2 -0
- package/lib/examples/main.js +334 -0
- package/lib/examples/stores/agents/earthquake-detector.ipynb.json +111 -0
- package/lib/examples/stores/agents/earthquake-detector.json +13 -0
- package/lib/examples/stores/agents/earthquake-detector.lexical.json +2988 -0
- package/lib/examples/stores/agents/sales-forecaster.ipynb.json +111 -0
- package/lib/examples/stores/agents/sales-forecaster.json +13 -0
- package/lib/examples/stores/agents/sales-forecaster.lexical.json +2988 -0
- package/lib/examples/stores/agents/social-post-generator.ipynb.json +111 -0
- package/lib/examples/stores/agents/social-post-generator.json +13 -0
- package/lib/examples/stores/agents/social-post-generator.lexical.json +2988 -0
- package/lib/examples/stores/agents/stock-market.ipynb.json +56 -0
- package/lib/examples/stores/agents/stock-market.json +13 -0
- package/lib/examples/stores/agents/stock-market.lexical.json +1026 -0
- package/lib/examples/stores/examplesStore.d.ts +26 -0
- package/lib/examples/stores/examplesStore.js +60 -0
- package/lib/examples/stores/notebooks/Empty.ipynb.json +33 -0
- package/lib/examples/stores/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples/stores/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples/stores/notebooks/Lite.ipynb.json +128 -0
- package/lib/examples/stores/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples/stores/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/stores/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples/stores/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples/stores/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples/stores/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples/stores/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +12 -0
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +69 -0
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +85 -0
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +62 -0
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +51 -0
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +9 -0
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +56 -0
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +50 -0
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +16 -0
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +72 -0
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +9 -0
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +43 -0
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +31 -0
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +54 -0
- package/lib/examples/vercel-ai-elements/index.d.ts +13 -0
- package/lib/examples/vercel-ai-elements/index.js +17 -0
- package/lib/examples/vercel-ai-elements/main.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/main.js +9 -0
- package/lib/examples/vercel-ai-elements/showcase.css +128 -0
- package/lib/hooks/index.d.ts +68 -0
- package/lib/hooks/index.js +81 -0
- package/lib/hooks/useA2A.d.ts +75 -0
- package/lib/hooks/useA2A.js +368 -0
- package/lib/hooks/useAGUI.d.ts +63 -0
- package/lib/hooks/useAGUI.js +162 -0
- package/lib/hooks/useAcp.d.ts +121 -0
- package/lib/hooks/useAcp.js +459 -0
- package/lib/hooks/useAgents.d.ts +13 -0
- package/lib/hooks/useAgents.js +71 -0
- package/lib/hooks/useChat.d.ts +62 -0
- package/lib/hooks/useChat.js +363 -0
- package/lib/hooks/useKeyboardShortcuts.d.ts +47 -0
- package/lib/hooks/useKeyboardShortcuts.js +153 -0
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +19 -0
- package/lib/hooks/useNotebookAIAgent.d.ts +8 -0
- package/lib/hooks/useNotebookAIAgent.js +56 -0
- package/lib/hooks/useToast.d.ts +44 -0
- package/lib/hooks/useToast.js +128 -0
- package/lib/hooks/useTools.d.ts +107 -0
- package/lib/hooks/useTools.js +130 -0
- package/lib/hooks/useVercelChat.d.ts +45 -0
- package/lib/hooks/useVercelChat.js +62 -0
- package/lib/index.css +73 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/lib/lexical/ChatInlinePlugin.d.ts +21 -0
- package/lib/lexical/ChatInlinePlugin.js +379 -0
- package/lib/lexical/index.d.ts +6 -0
- package/lib/lexical/index.js +10 -0
- package/lib/lib/utils.d.ts +2 -0
- package/lib/lib/utils.js +9 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +12 -0
- package/lib/models/AIAgent.d.ts +17 -0
- package/lib/models/AIAgent.js +5 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/models/index.js +5 -0
- package/lib/renderers/a2ui/components/A2UIRenderer.d.ts +7 -0
- package/lib/renderers/a2ui/components/A2UIRenderer.js +102 -0
- package/lib/renderers/a2ui/components/SurfaceRenderer.d.ts +7 -0
- package/lib/renderers/a2ui/components/SurfaceRenderer.js +101 -0
- package/lib/renderers/a2ui/components/content/AudioPlayer.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/AudioPlayer.js +38 -0
- package/lib/renderers/a2ui/components/content/Divider.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Divider.js +35 -0
- package/lib/renderers/a2ui/components/content/Icon.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Icon.js +110 -0
- package/lib/renderers/a2ui/components/content/Image.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Image.js +61 -0
- package/lib/renderers/a2ui/components/content/Text.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Text.js +64 -0
- package/lib/renderers/a2ui/components/content/Video.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Video.js +37 -0
- package/lib/renderers/a2ui/components/content/index.d.ts +6 -0
- package/lib/renderers/a2ui/components/content/index.js +25 -0
- package/lib/renderers/a2ui/components/index.d.ts +5 -0
- package/lib/renderers/a2ui/components/index.js +24 -0
- package/lib/renderers/a2ui/components/interactive/Button.d.ts +11 -0
- package/lib/renderers/a2ui/components/interactive/Button.js +71 -0
- package/lib/renderers/a2ui/components/interactive/CheckBox.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/CheckBox.js +48 -0
- package/lib/renderers/a2ui/components/interactive/DateTimeInput.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/DateTimeInput.js +62 -0
- package/lib/renderers/a2ui/components/interactive/MultipleChoice.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/MultipleChoice.js +73 -0
- package/lib/renderers/a2ui/components/interactive/Slider.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/Slider.js +53 -0
- package/lib/renderers/a2ui/components/interactive/TextField.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/TextField.js +72 -0
- package/lib/renderers/a2ui/components/interactive/index.d.ts +6 -0
- package/lib/renderers/a2ui/components/interactive/index.js +25 -0
- package/lib/renderers/a2ui/components/layout/Card.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Card.js +30 -0
- package/lib/renderers/a2ui/components/layout/Column.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Column.js +65 -0
- package/lib/renderers/a2ui/components/layout/List.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/List.js +55 -0
- package/lib/renderers/a2ui/components/layout/Modal.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Modal.js +58 -0
- package/lib/renderers/a2ui/components/layout/Row.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Row.js +65 -0
- package/lib/renderers/a2ui/components/layout/Tabs.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Tabs.js +48 -0
- package/lib/renderers/a2ui/components/layout/index.d.ts +6 -0
- package/lib/renderers/a2ui/components/layout/index.js +25 -0
- package/lib/renderers/a2ui/context/A2UIContext.d.ts +17 -0
- package/lib/renderers/a2ui/context/A2UIContext.js +54 -0
- package/lib/renderers/a2ui/context/ThemeContext.d.ts +20 -0
- package/lib/renderers/a2ui/context/ThemeContext.js +333 -0
- package/lib/renderers/a2ui/hooks/useA2UI.d.ts +36 -0
- package/lib/renderers/a2ui/hooks/useA2UI.js +62 -0
- package/lib/renderers/a2ui/hooks/useDataBinding.d.ts +8 -0
- package/lib/renderers/a2ui/hooks/useDataBinding.js +83 -0
- package/lib/renderers/a2ui/index.d.ts +9 -0
- package/lib/renderers/a2ui/index.js +28 -0
- package/lib/renderers/a2ui/lib/utils.d.ts +11 -0
- package/lib/renderers/a2ui/lib/utils.js +38 -0
- package/lib/renderers/a2ui/types/index.d.ts +17 -0
- package/lib/renderers/a2ui/types/index.js +5 -0
- package/lib/renderers/index.d.ts +1 -0
- package/lib/renderers/index.js +5 -0
- package/lib/state/index.d.ts +1 -0
- package/lib/state/index.js +5 -0
- package/lib/state/substates/AIAgentState.d.ts +11 -0
- package/lib/state/substates/AIAgentState.js +42 -0
- package/lib/state/substates/index.d.ts +1 -0
- package/lib/state/substates/index.js +5 -0
- package/lib/stories/Button.d.ts +15 -0
- package/lib/stories/Button.js +13 -0
- package/lib/stories/Button.stories.d.ts +23 -0
- package/lib/stories/Button.stories.js +48 -0
- package/lib/stories/Cell.stories.d.ts +12 -0
- package/lib/stories/Cell.stories.js +123 -0
- package/lib/stories/Header.d.ts +12 -0
- package/lib/stories/Header.js +8 -0
- package/lib/stories/Header.stories.d.ts +18 -0
- package/lib/stories/Header.stories.js +30 -0
- package/lib/stories/Page.d.ts +3 -0
- package/lib/stories/Page.js +12 -0
- package/lib/stories/Page.stories.d.ts +12 -0
- package/lib/stories/Page.stories.js +28 -0
- package/lib/stories/assets/accessibility.png +0 -0
- package/lib/stories/assets/accessibility.svg +1 -0
- package/lib/stories/assets/addon-library.png +0 -0
- package/lib/stories/assets/assets.png +0 -0
- package/lib/stories/assets/context.png +0 -0
- package/lib/stories/assets/discord.svg +1 -0
- package/lib/stories/assets/docs.png +0 -0
- package/lib/stories/assets/figma-plugin.png +0 -0
- package/lib/stories/assets/github.svg +1 -0
- package/lib/stories/assets/share.png +0 -0
- package/lib/stories/assets/styling.png +0 -0
- package/lib/stories/assets/testing.png +0 -0
- package/lib/stories/assets/theming.png +0 -0
- package/lib/stories/assets/tutorials.svg +1 -0
- package/lib/stories/assets/youtube.svg +1 -0
- package/lib/stories/button.css +35 -0
- package/lib/stories/header.css +37 -0
- package/lib/stories/page.css +73 -0
- package/lib/test-setup.d.ts +1 -0
- package/lib/test-setup.js +80 -0
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +40 -0
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.js +110 -0
- package/lib/tools/adapters/agent-runtimes/index.d.ts +9 -0
- package/lib/tools/adapters/agent-runtimes/index.js +13 -0
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +24 -0
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +50 -0
- package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +24 -0
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +51 -0
- package/lib/tools/adapters/copilotkit/CopilotKitToolAdapter.d.ts +73 -0
- package/lib/tools/adapters/copilotkit/CopilotKitToolAdapter.js +244 -0
- package/lib/tools/adapters/copilotkit/index.d.ts +10 -0
- package/lib/tools/adapters/copilotkit/index.js +14 -0
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +27 -0
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +59 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +27 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.js +58 -0
- package/lib/tools/adapters/index.d.ts +1 -0
- package/lib/tools/adapters/index.js +5 -0
- package/lib/tools/index.d.ts +6 -0
- package/lib/tools/index.js +18 -0
- package/lib/types.d.ts +5 -0
- package/lib/types.js +5 -0
- package/package.json +327 -0
- package/style/animation/Animation.module.css +174 -0
- package/style/base.css +204 -0
- package/style/index.css +6 -0
- package/style/showcase-vercel-ai.css +137 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import { cn } from '../lib/utils.js';
|
|
23
|
+
import { Text, Image, Icon, Video, AudioPlayer, Divider, } from './content/index.js';
|
|
24
|
+
import { Row, Column, List, Card, Tabs, Modal } from './layout/index.js';
|
|
25
|
+
import { Button, CheckBox, TextField, DateTimeInput, MultipleChoice, Slider, } from './interactive/index.js';
|
|
26
|
+
export function SurfaceRenderer({ surfaceId, surface, className, }) {
|
|
27
|
+
const componentTree = surface?.componentTree;
|
|
28
|
+
if (!componentTree) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return (_jsx("div", { className: cn('a2ui-surface', className), children: _jsx(ComponentRenderer, { node: componentTree, surfaceId: surfaceId }) }));
|
|
32
|
+
}
|
|
33
|
+
function ComponentRenderer({ node, surfaceId }) {
|
|
34
|
+
const renderChild = useMemo(() => (childNode) => (_jsx(ComponentRenderer, { node: childNode, surfaceId: surfaceId }, childNode.id)), [surfaceId]);
|
|
35
|
+
const children = useMemo(() => {
|
|
36
|
+
const props = node.properties;
|
|
37
|
+
if (props.children && Array.isArray(props.children)) {
|
|
38
|
+
return props.children.map(child => child ? (_jsx(ComponentWrapper, { node: child, children: _jsx(ComponentRenderer, { node: child, surfaceId: surfaceId }) }, child.id)) : null);
|
|
39
|
+
}
|
|
40
|
+
if (props.child) {
|
|
41
|
+
return (_jsx(ComponentWrapper, { node: props.child, children: _jsx(ComponentRenderer, { node: props.child, surfaceId: surfaceId }) }, props.child.id));
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}, [node.properties, surfaceId]);
|
|
45
|
+
switch (node.type) {
|
|
46
|
+
case 'Text':
|
|
47
|
+
return (_jsx(Text, { node: node, surfaceId: surfaceId }));
|
|
48
|
+
case 'Heading':
|
|
49
|
+
return (_jsx(Text, { node: node, surfaceId: surfaceId }));
|
|
50
|
+
case 'Image':
|
|
51
|
+
return (_jsx(Image, { node: node, surfaceId: surfaceId }));
|
|
52
|
+
case 'Icon':
|
|
53
|
+
return (_jsx(Icon, { node: node, surfaceId: surfaceId }));
|
|
54
|
+
case 'Video':
|
|
55
|
+
return (_jsx(Video, { node: node, surfaceId: surfaceId }));
|
|
56
|
+
case 'AudioPlayer':
|
|
57
|
+
return (_jsx(AudioPlayer, { node: node, surfaceId: surfaceId }));
|
|
58
|
+
case 'Divider':
|
|
59
|
+
return (_jsx(Divider, { node: node, surfaceId: surfaceId }));
|
|
60
|
+
case 'Row':
|
|
61
|
+
return (_jsx(Row, { node: node, surfaceId: surfaceId, children: children }));
|
|
62
|
+
case 'Column':
|
|
63
|
+
return (_jsx(Column, { node: node, surfaceId: surfaceId, children: children }));
|
|
64
|
+
case 'List':
|
|
65
|
+
return (_jsx(List, { node: node, surfaceId: surfaceId, children: children }));
|
|
66
|
+
case 'Card':
|
|
67
|
+
return (_jsx(Card, { node: node, surfaceId: surfaceId, children: children }));
|
|
68
|
+
case 'Tabs':
|
|
69
|
+
return (_jsx(Tabs, { node: node, surfaceId: surfaceId, renderChild: renderChild }));
|
|
70
|
+
case 'Modal':
|
|
71
|
+
return (_jsx(Modal, { node: node, surfaceId: surfaceId, renderChild: renderChild }));
|
|
72
|
+
case 'Button':
|
|
73
|
+
return (_jsx(Button, { node: node, surfaceId: surfaceId, children: children }));
|
|
74
|
+
case 'CheckBox':
|
|
75
|
+
return (_jsx(CheckBox, { node: node, surfaceId: surfaceId }));
|
|
76
|
+
case 'TextField':
|
|
77
|
+
return (_jsx(TextField, { node: node, surfaceId: surfaceId }));
|
|
78
|
+
case 'DateTimeInput':
|
|
79
|
+
return (_jsx(DateTimeInput, { node: node, surfaceId: surfaceId }));
|
|
80
|
+
case 'MultipleChoice':
|
|
81
|
+
return (_jsx(MultipleChoice, { node: node, surfaceId: surfaceId }));
|
|
82
|
+
case 'Slider':
|
|
83
|
+
return (_jsx(Slider, { node: node, surfaceId: surfaceId }));
|
|
84
|
+
default:
|
|
85
|
+
console.warn(`Unknown component type: ${node.type}`);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function ComponentWrapper({ node, children, }) {
|
|
90
|
+
const style = useMemo(() => {
|
|
91
|
+
const weight = node.weight;
|
|
92
|
+
if (typeof weight !== 'number') {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return { flex: weight };
|
|
96
|
+
}, [node.weight]);
|
|
97
|
+
if (!style) {
|
|
98
|
+
return _jsx(_Fragment, { children: children });
|
|
99
|
+
}
|
|
100
|
+
return _jsx("div", { style: style, children: children });
|
|
101
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
2
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
3
|
+
interface AudioPlayerProps extends A2UIComponentProps {
|
|
4
|
+
node: Types.AnyComponentNode & {
|
|
5
|
+
type: 'AudioPlayer';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function AudioPlayer({ node, surfaceId }: AudioPlayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import { useDataBinding } from '../../hooks/useDataBinding.js';
|
|
23
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
24
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
25
|
+
export function AudioPlayer({ node, surfaceId }) {
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const { resolveString } = useDataBinding(node, surfaceId);
|
|
28
|
+
const properties = node.properties;
|
|
29
|
+
const url = resolveString(properties.url ?? null) ?? '';
|
|
30
|
+
const description = resolveString(properties.description ?? null);
|
|
31
|
+
const themeClasses = useMemo(() => {
|
|
32
|
+
return classMapToString(theme.components.AudioPlayer);
|
|
33
|
+
}, [theme]);
|
|
34
|
+
if (!url) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return (_jsxs("div", { className: cn('flex flex-col gap-2', themeClasses), children: [description && (_jsx("p", { className: "text-sm text-muted-foreground", children: description })), _jsx("audio", { src: url, controls: true, className: "w-full", preload: "metadata" })] }));
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
2
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
3
|
+
interface DividerProps extends A2UIComponentProps {
|
|
4
|
+
node: Types.AnyComponentNode & {
|
|
5
|
+
type: 'Divider';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function Divider({ node }: DividerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
23
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
24
|
+
export function Divider({ node }) {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const properties = node.properties;
|
|
27
|
+
const axis = properties.axis ?? 'horizontal';
|
|
28
|
+
const themeClasses = useMemo(() => {
|
|
29
|
+
return classMapToString(theme.components.Divider);
|
|
30
|
+
}, [theme]);
|
|
31
|
+
const orientationClasses = useMemo(() => {
|
|
32
|
+
return axis === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]';
|
|
33
|
+
}, [axis]);
|
|
34
|
+
return (_jsx("div", { role: "separator", "aria-orientation": axis, className: cn(themeClasses, orientationClasses) }));
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
2
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
3
|
+
interface IconProps extends A2UIComponentProps {
|
|
4
|
+
node: Types.AnyComponentNode & {
|
|
5
|
+
type: 'Icon';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function Icon({ node, surfaceId }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import * as LucideIcons from 'lucide-react';
|
|
23
|
+
import { useDataBinding } from '../../hooks/useDataBinding.js';
|
|
24
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
25
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
26
|
+
const iconMap = {
|
|
27
|
+
accountCircle: 'UserCircle',
|
|
28
|
+
add: 'Plus',
|
|
29
|
+
arrowBack: 'ArrowLeft',
|
|
30
|
+
arrowForward: 'ArrowRight',
|
|
31
|
+
attachFile: 'Paperclip',
|
|
32
|
+
calendarToday: 'Calendar',
|
|
33
|
+
call: 'Phone',
|
|
34
|
+
camera: 'Camera',
|
|
35
|
+
check: 'Check',
|
|
36
|
+
close: 'X',
|
|
37
|
+
delete: 'Trash2',
|
|
38
|
+
download: 'Download',
|
|
39
|
+
edit: 'Pencil',
|
|
40
|
+
event: 'CalendarDays',
|
|
41
|
+
error: 'AlertCircle',
|
|
42
|
+
favorite: 'Heart',
|
|
43
|
+
favoriteOff: 'HeartOff',
|
|
44
|
+
folder: 'Folder',
|
|
45
|
+
help: 'HelpCircle',
|
|
46
|
+
home: 'Home',
|
|
47
|
+
info: 'Info',
|
|
48
|
+
locationOn: 'MapPin',
|
|
49
|
+
lock: 'Lock',
|
|
50
|
+
lockOpen: 'Unlock',
|
|
51
|
+
mail: 'Mail',
|
|
52
|
+
menu: 'Menu',
|
|
53
|
+
moreVert: 'MoreVertical',
|
|
54
|
+
moreHoriz: 'MoreHorizontal',
|
|
55
|
+
notificationsOff: 'BellOff',
|
|
56
|
+
notifications: 'Bell',
|
|
57
|
+
payment: 'CreditCard',
|
|
58
|
+
person: 'User',
|
|
59
|
+
phone: 'Phone',
|
|
60
|
+
photo: 'Image',
|
|
61
|
+
print: 'Printer',
|
|
62
|
+
refresh: 'RefreshCw',
|
|
63
|
+
search: 'Search',
|
|
64
|
+
send: 'Send',
|
|
65
|
+
settings: 'Settings',
|
|
66
|
+
share: 'Share2',
|
|
67
|
+
shoppingCart: 'ShoppingCart',
|
|
68
|
+
star: 'Star',
|
|
69
|
+
starHalf: 'StarHalf',
|
|
70
|
+
starOff: 'StarOff',
|
|
71
|
+
thumbUp: 'ThumbsUp',
|
|
72
|
+
thumbDown: 'ThumbsDown',
|
|
73
|
+
upload: 'Upload',
|
|
74
|
+
visibility: 'Eye',
|
|
75
|
+
visibilityOff: 'EyeOff',
|
|
76
|
+
warning: 'AlertTriangle',
|
|
77
|
+
};
|
|
78
|
+
export function Icon({ node, surfaceId }) {
|
|
79
|
+
const theme = useTheme();
|
|
80
|
+
const { resolveString } = useDataBinding(node, surfaceId);
|
|
81
|
+
const properties = node.properties;
|
|
82
|
+
const iconName = resolveString(properties.name ?? null) ?? '';
|
|
83
|
+
const themeClasses = useMemo(() => {
|
|
84
|
+
const iconTheme = theme.components.Icon;
|
|
85
|
+
if (iconTheme && typeof iconTheme === 'object' && 'element' in iconTheme) {
|
|
86
|
+
return classMapToString(iconTheme.element);
|
|
87
|
+
}
|
|
88
|
+
return classMapToString(theme.components.Icon);
|
|
89
|
+
}, [theme]);
|
|
90
|
+
const containerClasses = useMemo(() => {
|
|
91
|
+
const iconTheme = theme.components.Icon;
|
|
92
|
+
if (iconTheme &&
|
|
93
|
+
typeof iconTheme === 'object' &&
|
|
94
|
+
'container' in iconTheme) {
|
|
95
|
+
return classMapToString(iconTheme.container);
|
|
96
|
+
}
|
|
97
|
+
return '';
|
|
98
|
+
}, [theme]);
|
|
99
|
+
const IconComponent = useMemo(() => {
|
|
100
|
+
const lucideIconName = iconMap[iconName];
|
|
101
|
+
if (lucideIconName && lucideIconName in LucideIcons) {
|
|
102
|
+
return LucideIcons[lucideIconName];
|
|
103
|
+
}
|
|
104
|
+
return LucideIcons.HelpCircle;
|
|
105
|
+
}, [iconName]);
|
|
106
|
+
if (containerClasses) {
|
|
107
|
+
return (_jsx("div", { className: cn(containerClasses), children: _jsx(IconComponent, { className: cn(themeClasses) }) }));
|
|
108
|
+
}
|
|
109
|
+
return _jsx(IconComponent, { className: cn(themeClasses) });
|
|
110
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
2
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
3
|
+
interface ImageProps extends A2UIComponentProps {
|
|
4
|
+
node: Types.AnyComponentNode & {
|
|
5
|
+
type: 'Image';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function Image({ node, surfaceId }: ImageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import { useDataBinding } from '../../hooks/useDataBinding.js';
|
|
23
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
24
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
25
|
+
export function Image({ node, surfaceId }) {
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const { resolveString } = useDataBinding(node, surfaceId);
|
|
28
|
+
const properties = node.properties;
|
|
29
|
+
const url = resolveString(properties.url ?? null) ?? '';
|
|
30
|
+
const alt = resolveString(properties.alt ?? null) ?? '';
|
|
31
|
+
const fit = properties.fit ?? 'cover';
|
|
32
|
+
const usageHint = properties.usageHint;
|
|
33
|
+
const themeClasses = useMemo(() => {
|
|
34
|
+
const baseClasses = classMapToString(theme.components.Image.all);
|
|
35
|
+
if (usageHint && theme.components.Image[usageHint]) {
|
|
36
|
+
const hintClasses = classMapToString(theme.components.Image[usageHint]);
|
|
37
|
+
return cn(baseClasses, hintClasses);
|
|
38
|
+
}
|
|
39
|
+
return baseClasses;
|
|
40
|
+
}, [theme, usageHint]);
|
|
41
|
+
const fitClass = useMemo(() => {
|
|
42
|
+
switch (fit) {
|
|
43
|
+
case 'contain':
|
|
44
|
+
return 'object-contain';
|
|
45
|
+
case 'cover':
|
|
46
|
+
return 'object-cover';
|
|
47
|
+
case 'fill':
|
|
48
|
+
return 'object-fill';
|
|
49
|
+
case 'none':
|
|
50
|
+
return 'object-none';
|
|
51
|
+
case 'scale-down':
|
|
52
|
+
return 'object-scale-down';
|
|
53
|
+
default:
|
|
54
|
+
return 'object-cover';
|
|
55
|
+
}
|
|
56
|
+
}, [fit]);
|
|
57
|
+
if (!url) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return (_jsx("img", { src: url, alt: alt, className: cn(themeClasses, fitClass), loading: "lazy" }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
2
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
3
|
+
interface TextProps extends A2UIComponentProps {
|
|
4
|
+
node: Types.AnyComponentNode & {
|
|
5
|
+
type: 'Text';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function Text({ node, surfaceId }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import MarkdownIt from 'markdown-it';
|
|
23
|
+
import { useDataBinding } from '../../hooks/useDataBinding.js';
|
|
24
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
25
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
26
|
+
const md = new MarkdownIt({
|
|
27
|
+
html: false, // Disable HTML for security
|
|
28
|
+
breaks: true,
|
|
29
|
+
linkify: true,
|
|
30
|
+
});
|
|
31
|
+
export function Text({ node, surfaceId }) {
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
const { resolveString } = useDataBinding(node, surfaceId);
|
|
34
|
+
const properties = node.properties;
|
|
35
|
+
const text = resolveString(properties.text ?? null) ?? '';
|
|
36
|
+
const usageHint = properties.usageHint ?? 'body';
|
|
37
|
+
const themeClasses = useMemo(() => {
|
|
38
|
+
const baseClasses = classMapToString(theme.components.Text.all);
|
|
39
|
+
const hintClasses = classMapToString(theme.components.Text[usageHint] ?? theme.components.Text.body);
|
|
40
|
+
return cn(baseClasses, hintClasses);
|
|
41
|
+
}, [theme, usageHint]);
|
|
42
|
+
const htmlContent = useMemo(() => {
|
|
43
|
+
return md.render(text);
|
|
44
|
+
}, [text]);
|
|
45
|
+
const Element = useMemo(() => {
|
|
46
|
+
switch (usageHint) {
|
|
47
|
+
case 'h1':
|
|
48
|
+
return 'h1';
|
|
49
|
+
case 'h2':
|
|
50
|
+
return 'h2';
|
|
51
|
+
case 'h3':
|
|
52
|
+
return 'h3';
|
|
53
|
+
case 'h4':
|
|
54
|
+
return 'h4';
|
|
55
|
+
case 'h5':
|
|
56
|
+
return 'h5';
|
|
57
|
+
case 'caption':
|
|
58
|
+
return 'span';
|
|
59
|
+
default:
|
|
60
|
+
return 'div';
|
|
61
|
+
}
|
|
62
|
+
}, [usageHint]);
|
|
63
|
+
return (_jsx(Element, { className: themeClasses, dangerouslySetInnerHTML: { __html: htmlContent } }));
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
2
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
3
|
+
interface VideoProps extends A2UIComponentProps {
|
|
4
|
+
node: Types.AnyComponentNode & {
|
|
5
|
+
type: 'Video';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function Video({ node, surfaceId }: VideoProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import { useDataBinding } from '../../hooks/useDataBinding.js';
|
|
23
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
24
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
25
|
+
export function Video({ node, surfaceId }) {
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const { resolveString } = useDataBinding(node, surfaceId);
|
|
28
|
+
const properties = node.properties;
|
|
29
|
+
const url = resolveString(properties.url ?? null) ?? '';
|
|
30
|
+
const themeClasses = useMemo(() => {
|
|
31
|
+
return classMapToString(theme.components.Video);
|
|
32
|
+
}, [theme]);
|
|
33
|
+
if (!url) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return (_jsx("video", { src: url, controls: true, className: cn(themeClasses), preload: "metadata" }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 Google LLC
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
export { Text } from './Text.js';
|
|
21
|
+
export { Image } from './Image.js';
|
|
22
|
+
export { Icon } from './Icon.js';
|
|
23
|
+
export { Video } from './Video.js';
|
|
24
|
+
export { AudioPlayer } from './AudioPlayer.js';
|
|
25
|
+
export { Divider } from './Divider.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 Google LLC
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
export { A2UIRenderer } from './A2UIRenderer.js';
|
|
21
|
+
export { SurfaceRenderer } from './SurfaceRenderer.js';
|
|
22
|
+
export * from './content/index.js';
|
|
23
|
+
export * from './layout/index.js';
|
|
24
|
+
export * from './interactive/index.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { Types } from '@a2ui/lit/0.8';
|
|
3
|
+
import type { A2UIComponentProps } from '../../types/index.js';
|
|
4
|
+
interface ButtonProps extends A2UIComponentProps {
|
|
5
|
+
node: Types.AnyComponentNode & {
|
|
6
|
+
type: 'Button';
|
|
7
|
+
};
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function Button({ node, surfaceId, children }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2025 Google LLC
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import { useMemo, useCallback } from 'react';
|
|
22
|
+
import { useTheme } from '../../context/ThemeContext.js';
|
|
23
|
+
import { useA2UIContext } from '../../context/A2UIContext.js';
|
|
24
|
+
import { cn, classMapToString } from '../../lib/utils.js';
|
|
25
|
+
export function Button({ node, surfaceId, children }) {
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const { sendAction, processor } = useA2UIContext();
|
|
28
|
+
const properties = node.properties;
|
|
29
|
+
const action = properties.action;
|
|
30
|
+
const isPrimary = properties.primary ?? true;
|
|
31
|
+
const themeClasses = useMemo(() => {
|
|
32
|
+
return classMapToString(theme.components.Button);
|
|
33
|
+
}, [theme]);
|
|
34
|
+
const variantClasses = useMemo(() => {
|
|
35
|
+
if (isPrimary) {
|
|
36
|
+
return 'bg-primary text-primary-foreground hover:bg-primary/90';
|
|
37
|
+
}
|
|
38
|
+
return 'border border-input bg-background hover:bg-accent hover:text-accent-foreground';
|
|
39
|
+
}, [isPrimary]);
|
|
40
|
+
const handleClick = useCallback(() => {
|
|
41
|
+
if (!action?.name)
|
|
42
|
+
return;
|
|
43
|
+
const resolvedContext = {};
|
|
44
|
+
if (action.context && Array.isArray(action.context)) {
|
|
45
|
+
for (const item of action.context) {
|
|
46
|
+
const value = item.value;
|
|
47
|
+
if (typeof value === 'object' &&
|
|
48
|
+
value !== null &&
|
|
49
|
+
'path' in value &&
|
|
50
|
+
typeof value.path === 'string') {
|
|
51
|
+
const resolvedValue = processor.getData(node, value.path, surfaceId);
|
|
52
|
+
resolvedContext[item.key] = resolvedValue;
|
|
53
|
+
}
|
|
54
|
+
else if (typeof value === 'object' &&
|
|
55
|
+
value !== null &&
|
|
56
|
+
'literalString' in value) {
|
|
57
|
+
resolvedContext[item.key] = value.literalString;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
resolvedContext[item.key] = value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
sendAction({
|
|
65
|
+
type: 'a2ui.action',
|
|
66
|
+
actionId: action.name,
|
|
67
|
+
context: resolvedContext,
|
|
68
|
+
});
|
|
69
|
+
}, [action, processor, node, surfaceId, sendAction]);
|
|
70
|
+
return (_jsx("button", { type: "button", onClick: handleClick, className: cn(themeClasses, variantClasses), children: children }));
|
|
71
|
+
}
|