@datalayer/agent-runtimes 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/lib/{examples/components → components}/AgentConfiguration.d.ts +54 -9
- package/lib/components/AgentConfiguration.js +585 -0
- package/lib/{examples/components → components}/FooterMetrics.d.ts +1 -2
- package/lib/{examples/components → components}/Header.d.ts +1 -6
- package/lib/{examples/components → components}/Header.js +5 -39
- package/lib/{examples/components → components}/HeaderControls.d.ts +1 -2
- package/lib/{examples/components → components}/HeaderControls.js +1 -1
- package/lib/{examples/components → components}/LexicalEditor.d.ts +2 -3
- package/lib/{examples/components → components}/LexicalEditor.js +2 -2
- package/lib/components/MainContent.d.ts +34 -0
- package/lib/{examples/components → components}/MainContent.js +18 -9
- package/lib/components/McpServerManager.d.ts +30 -0
- package/lib/components/McpServerManager.js +331 -0
- package/lib/{examples/components → components}/MockFileBrowser.d.ts +1 -2
- package/lib/{examples/components → components}/SessionTabs.d.ts +2 -3
- package/lib/{examples/components → components}/TimeTravel.d.ts +1 -2
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +472 -22
- package/lib/components/chat/components/Chat.d.ts +37 -3
- package/lib/components/chat/components/Chat.js +29 -10
- package/lib/components/chat/components/ChatFloating.d.ts +27 -2
- package/lib/components/chat/components/ChatFloating.js +17 -10
- package/lib/components/chat/components/ChatPopupStandalone.js +1 -1
- package/lib/components/chat/components/ChatSidebar.d.ts +1 -1
- package/lib/components/chat/components/ChatStandalone.d.ts +1 -1
- package/lib/components/chat/components/ChatStandalone.js +1 -1
- package/lib/components/chat/components/ContextDistribution.d.ts +70 -6
- package/lib/components/chat/components/ContextDistribution.js +13 -6
- package/lib/components/chat/components/ContextInspector.d.ts +81 -0
- package/lib/components/chat/components/ContextInspector.js +263 -0
- package/lib/components/chat/components/ContextPanel.d.ts +112 -0
- package/lib/components/chat/components/ContextPanel.js +368 -0
- package/lib/components/chat/components/base/ChatBase.d.ts +74 -19
- package/lib/components/chat/components/base/ChatBase.js +296 -37
- package/lib/components/chat/components/index.d.ts +3 -1
- package/lib/components/chat/components/index.js +2 -0
- package/lib/components/chat/extensions/ExtensionRegistry.d.ts +1 -1
- package/lib/components/chat/extensions/index.d.ts +1 -0
- package/lib/components/chat/index.d.ts +3 -3
- package/lib/components/chat/protocols/AGUIAdapter.js +24 -4
- package/lib/components/chat/protocols/VercelAIAdapter.js +35 -1
- package/lib/components/chat/store/chatStore.d.ts +2 -3
- package/lib/components/chat/store/conversationStore.d.ts +83 -0
- package/lib/components/chat/store/conversationStore.js +174 -0
- package/lib/components/chat/store/index.d.ts +2 -1
- package/lib/components/chat/store/index.js +1 -0
- package/lib/components/chat/types/inference.d.ts +17 -0
- package/lib/components/chat/types/protocol.d.ts +10 -0
- package/lib/components/index.d.ts +23 -0
- package/lib/components/index.js +11 -0
- package/lib/config/agents/code-ai/agents.d.ts +25 -0
- package/lib/config/agents/code-ai/agents.js +70 -0
- package/lib/config/agents/code-ai/index.d.ts +1 -0
- package/lib/config/agents/code-ai/index.js +5 -0
- package/lib/config/agents/codemode-paper/agents.d.ts +29 -0
- package/lib/config/agents/codemode-paper/agents.js +288 -0
- package/lib/config/agents/codemode-paper/index.d.ts +1 -0
- package/lib/config/agents/codemode-paper/index.js +5 -0
- package/lib/config/agents/datalayer-ai/agents.d.ts +29 -0
- package/lib/config/agents/datalayer-ai/agents.js +267 -0
- package/lib/config/agents/datalayer-ai/index.d.ts +1 -0
- package/lib/config/agents/datalayer-ai/index.js +5 -0
- package/lib/config/agents/index.d.ts +19 -0
- package/lib/config/agents/index.js +38 -0
- package/lib/config/envvars.d.ts +28 -0
- package/lib/config/envvars.js +115 -0
- package/lib/config/index.d.ts +5 -0
- package/lib/config/index.js +9 -0
- package/lib/config/mcpServers.d.ts +18 -0
- package/lib/config/mcpServers.js +153 -0
- package/lib/config/skills.d.ts +27 -0
- package/lib/config/skills.js +60 -0
- package/lib/{lib → config}/utils.d.ts +1 -1
- package/lib/{lib → config}/utils.js +2 -2
- package/lib/examples/AgentRuntimeLexical2Example.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexical2Example.js +3 -2
- package/lib/examples/AgentRuntimeLexicalExample.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexicalExample.js +5 -3
- package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +3 -3
- package/lib/examples/AgentRuntimeNotebookExample.js +1 -1
- package/lib/examples/AgentSpaceFormExample.d.ts +2 -2
- package/lib/examples/AgentSpaceFormExample.js +215 -35
- package/lib/examples/CopilotKitLexicalExample.d.ts +1 -0
- package/lib/examples/CopilotKitLexicalExample.js +3 -2
- package/lib/examples/index.d.ts +1 -0
- package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +43 -43
- package/lib/hooks/useAGUI.d.ts +1 -1
- package/lib/hooks/useAGUI.js +1 -1
- package/lib/identity/types.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/runtime/index.d.ts +3 -0
- package/lib/runtime/runtimeStore.d.ts +3 -4
- package/lib/runtime/useAgentConnection.d.ts +2 -3
- package/lib/runtime/useAgentRuntime.d.ts +2 -3
- package/lib/stories/Cell.stories.js +1 -1
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +1 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -0
- package/lib/types.d.ts +158 -0
- package/package.json +5 -6
- package/scripts/apply-patches.sh +1 -1
- package/scripts/codegen/generate_agents.py +863 -0
- package/scripts/codegen/generate_envvars.py +302 -0
- package/scripts/codegen/generate_mcp_servers.py +436 -0
- package/scripts/codegen/generate_skills.py +334 -0
- package/scripts/download-ai-elements.py +35 -20
- package/scripts/sync-jupyter.sh +6 -0
- package/lib/components/ui/accordion.d.ts +0 -7
- package/lib/components/ui/accordion.js +0 -22
- package/lib/components/ui/alert-dialog.d.ts +0 -14
- package/lib/components/ui/alert-dialog.js +0 -43
- package/lib/components/ui/alert.d.ts +0 -9
- package/lib/components/ui/alert.js +0 -24
- package/lib/components/ui/aspect-ratio.d.ts +0 -3
- package/lib/components/ui/aspect-ratio.js +0 -11
- package/lib/components/ui/avatar.d.ts +0 -6
- package/lib/components/ui/avatar.js +0 -18
- package/lib/components/ui/badge.d.ts +0 -9
- package/lib/components/ui/badge.js +0 -22
- package/lib/components/ui/breadcrumb.d.ts +0 -11
- package/lib/components/ui/breadcrumb.js +0 -27
- package/lib/components/ui/button-group.d.ts +0 -11
- package/lib/components/ui/button-group.js +0 -31
- package/lib/components/ui/button.d.ts +0 -13
- package/lib/components/ui/button.js +0 -39
- package/lib/components/ui/calendar.d.ts +0 -8
- package/lib/components/ui/calendar.js +0 -80
- package/lib/components/ui/card.d.ts +0 -9
- package/lib/components/ui/card.js +0 -24
- package/lib/components/ui/carousel.d.ts +0 -19
- package/lib/components/ui/carousel.js +0 -95
- package/lib/components/ui/chart.d.ts +0 -53
- package/lib/components/ui/chart.js +0 -136
- package/lib/components/ui/checkbox.d.ts +0 -4
- package/lib/components/ui/checkbox.js +0 -13
- package/lib/components/ui/collapsible.d.ts +0 -5
- package/lib/components/ui/collapsible.js +0 -17
- package/lib/components/ui/command.d.ts +0 -18
- package/lib/components/ui/command.js +0 -38
- package/lib/components/ui/context-menu.d.ts +0 -25
- package/lib/components/ui/context-menu.js +0 -55
- package/lib/components/ui/dialog.d.ts +0 -15
- package/lib/components/ui/dialog.js +0 -40
- package/lib/components/ui/drawer.d.ts +0 -13
- package/lib/components/ui/drawer.js +0 -39
- package/lib/components/ui/dropdown-menu.d.ts +0 -25
- package/lib/components/ui/dropdown-menu.js +0 -55
- package/lib/components/ui/empty.d.ts +0 -11
- package/lib/components/ui/empty.js +0 -37
- package/lib/components/ui/field.d.ts +0 -24
- package/lib/components/ui/field.js +0 -80
- package/lib/components/ui/form.d.ts +0 -24
- package/lib/components/ui/form.js +0 -63
- package/lib/components/ui/hover-card.d.ts +0 -6
- package/lib/components/ui/hover-card.js +0 -18
- package/lib/components/ui/input-group.d.ts +0 -19
- package/lib/components/ui/input-group.js +0 -69
- package/lib/components/ui/input-otp.d.ts +0 -11
- package/lib/components/ui/input-otp.js +0 -25
- package/lib/components/ui/input.d.ts +0 -3
- package/lib/components/ui/input.js +0 -6
- package/lib/components/ui/item.d.ts +0 -23
- package/lib/components/ui/item.js +0 -66
- package/lib/components/ui/kbd.d.ts +0 -3
- package/lib/components/ui/kbd.js +0 -13
- package/lib/components/ui/label.d.ts +0 -4
- package/lib/components/ui/label.js +0 -12
- package/lib/components/ui/menubar.d.ts +0 -26
- package/lib/components/ui/menubar.js +0 -58
- package/lib/components/ui/navigation-menu.d.ts +0 -14
- package/lib/components/ui/navigation-menu.js +0 -31
- package/lib/components/ui/pagination.d.ts +0 -13
- package/lib/components/ui/pagination.js +0 -29
- package/lib/components/ui/popover.d.ts +0 -7
- package/lib/components/ui/popover.js +0 -21
- package/lib/components/ui/progress.d.ts +0 -4
- package/lib/components/ui/progress.js +0 -12
- package/lib/components/ui/radio-group.d.ts +0 -5
- package/lib/components/ui/radio-group.js +0 -16
- package/lib/components/ui/resizable.d.ts +0 -8
- package/lib/components/ui/resizable.js +0 -19
- package/lib/components/ui/scroll-area.d.ts +0 -5
- package/lib/components/ui/scroll-area.js +0 -17
- package/lib/components/ui/select.d.ts +0 -15
- package/lib/components/ui/select.js +0 -42
- package/lib/components/ui/separator.d.ts +0 -4
- package/lib/components/ui/separator.js +0 -12
- package/lib/components/ui/sheet.d.ts +0 -13
- package/lib/components/ui/sheet.js +0 -44
- package/lib/components/ui/sidebar.d.ts +0 -69
- package/lib/components/ui/sidebar.js +0 -216
- package/lib/components/ui/skeleton.d.ts +0 -2
- package/lib/components/ui/skeleton.js +0 -10
- package/lib/components/ui/slider.d.ts +0 -4
- package/lib/components/ui/slider.js +0 -18
- package/lib/components/ui/sonner.d.ts +0 -3
- package/lib/components/ui/sonner.js +0 -25
- package/lib/components/ui/spinner.d.ts +0 -2
- package/lib/components/ui/spinner.js +0 -11
- package/lib/components/ui/switch.d.ts +0 -4
- package/lib/components/ui/switch.js +0 -12
- package/lib/components/ui/table.d.ts +0 -10
- package/lib/components/ui/table.js +0 -32
- package/lib/components/ui/tabs.d.ts +0 -7
- package/lib/components/ui/tabs.js +0 -21
- package/lib/components/ui/textarea.d.ts +0 -3
- package/lib/components/ui/textarea.js +0 -6
- package/lib/components/ui/toast.d.ts +0 -15
- package/lib/components/ui/toast.js +0 -38
- package/lib/components/ui/toaster.d.ts +0 -1
- package/lib/components/ui/toaster.js +0 -14
- package/lib/components/ui/toggle-group.d.ts +0 -9
- package/lib/components/ui/toggle-group.js +0 -26
- package/lib/components/ui/toggle.d.ts +0 -9
- package/lib/components/ui/toggle.js +0 -30
- package/lib/components/ui/tooltip.d.ts +0 -7
- package/lib/components/ui/tooltip.js +0 -21
- package/lib/components/vercel-ai-elements/artifact.d.ts +0 -23
- package/lib/components/vercel-ai-elements/artifact.js +0 -24
- package/lib/components/vercel-ai-elements/code-block.d.ts +0 -17
- package/lib/components/vercel-ai-elements/code-block.js +0 -94
- package/lib/components/vercel-ai-elements/conversation.d.ts +0 -15
- package/lib/components/vercel-ai-elements/conversation.js +0 -21
- package/lib/components/vercel-ai-elements/loader.d.ts +0 -5
- package/lib/components/vercel-ai-elements/loader.js +0 -8
- package/lib/components/vercel-ai-elements/message.d.ts +0 -46
- package/lib/components/vercel-ai-elements/message.js +0 -109
- package/lib/components/vercel-ai-elements/model-selector.d.ts +0 -35
- package/lib/components/vercel-ai-elements/model-selector.js +0 -22
- package/lib/components/vercel-ai-elements/prompt-input.d.ts +0 -195
- package/lib/components/vercel-ai-elements/prompt-input.js +0 -589
- package/lib/components/vercel-ai-elements/reasoning.d.ts +0 -26
- package/lib/components/vercel-ai-elements/reasoning.js +0 -80
- package/lib/components/vercel-ai-elements/shimmer.d.ts +0 -9
- package/lib/components/vercel-ai-elements/shimmer.js +0 -22
- package/lib/components/vercel-ai-elements/sources.d.ts +0 -12
- package/lib/components/vercel-ai-elements/sources.js +0 -13
- package/lib/components/vercel-ai-elements/suggestion.d.ts +0 -10
- package/lib/components/vercel-ai-elements/suggestion.js +0 -16
- package/lib/components/vercel-ai-elements/tool.d.ts +0 -23
- package/lib/components/vercel-ai-elements/tool.js +0 -52
- package/lib/examples/components/AgentConfiguration.js +0 -382
- package/lib/examples/components/MainContent.d.ts +0 -19
- package/lib/examples/components/index.d.ts +0 -10
- package/lib/examples/components/index.js +0 -13
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +0 -12
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +0 -69
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +0 -85
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +0 -62
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +0 -51
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +0 -9
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +0 -56
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +0 -50
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +0 -16
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +0 -72
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +0 -9
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +0 -43
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +0 -31
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +0 -54
- package/lib/examples/vercel-ai-elements/index.d.ts +0 -13
- package/lib/examples/vercel-ai-elements/index.js +0 -17
- package/lib/examples/vercel-ai-elements/main.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/main.js +0 -9
- package/lib/examples/vercel-ai-elements/showcase.css +0 -128
- package/lib/hooks/useToast.d.ts +0 -44
- package/lib/hooks/useToast.js +0 -128
- package/patches/@datalayer+jupyter-lexical+1.0.8.patch +0 -11628
- package/patches/@datalayer+jupyter-react+2.0.2.patch +0 -5338
- package/style/showcase-vercel-ai.css +0 -137
- /package/lib/{examples/components → components}/FooterMetrics.js +0 -0
- /package/lib/{examples/components → components}/MockFileBrowser.js +0 -0
- /package/lib/{examples/components → components}/SessionTabs.js +0 -0
- /package/lib/{examples/components → components}/TimeTravel.js +0 -0
- /package/lib/{models → types}/AIAgent.d.ts +0 -0
- /package/lib/{models → types}/AIAgent.js +0 -0
- /package/lib/{models → types}/index.d.ts +0 -0
- /package/lib/{models → types}/index.js +0 -0
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*
|
|
5
|
-
* Showcase-specific styles for Vercel AI Elements
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/* Additional showcase-specific styles */
|
|
9
|
-
:root {
|
|
10
|
-
--showcase-max-width: 1400px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.showcase-container {
|
|
14
|
-
max-width: var(--showcase-max-width);
|
|
15
|
-
margin: 0 auto;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Ensure proper spacing in showcase examples */
|
|
19
|
-
.space-y-8 > * + * {
|
|
20
|
-
margin-top: 2rem;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.space-y-4 > * + * {
|
|
24
|
-
margin-top: 1rem;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.space-y-3 > * + * {
|
|
28
|
-
margin-top: 0.75rem;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.space-y-2 > * + * {
|
|
32
|
-
margin-top: 0.5rem;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* Prose styles for documentation content */
|
|
36
|
-
.prose {
|
|
37
|
-
color: var(--color-fg-default);
|
|
38
|
-
max-width: 65ch;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.prose h1 {
|
|
42
|
-
font-size: 2em;
|
|
43
|
-
margin-top: 0;
|
|
44
|
-
margin-bottom: 0.8em;
|
|
45
|
-
line-height: 1.1;
|
|
46
|
-
font-weight: 700;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.prose h2 {
|
|
50
|
-
font-size: 1.5em;
|
|
51
|
-
margin-top: 2em;
|
|
52
|
-
margin-bottom: 1em;
|
|
53
|
-
line-height: 1.3;
|
|
54
|
-
font-weight: 600;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.prose h3 {
|
|
58
|
-
font-size: 1.25em;
|
|
59
|
-
margin-top: 1.6em;
|
|
60
|
-
margin-bottom: 0.6em;
|
|
61
|
-
line-height: 1.4;
|
|
62
|
-
font-weight: 600;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.prose p {
|
|
66
|
-
margin-top: 1.25em;
|
|
67
|
-
margin-bottom: 1.25em;
|
|
68
|
-
line-height: 1.7;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.prose pre {
|
|
72
|
-
background-color: var(--color-canvas-subtle);
|
|
73
|
-
border-radius: 0.375rem;
|
|
74
|
-
padding: 1em;
|
|
75
|
-
overflow-x: auto;
|
|
76
|
-
margin-top: 1.7em;
|
|
77
|
-
margin-bottom: 1.7em;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.prose code {
|
|
81
|
-
background-color: var(--color-canvas-subtle);
|
|
82
|
-
border-radius: 0.25rem;
|
|
83
|
-
padding: 0.2em 0.4em;
|
|
84
|
-
font-size: 0.875em;
|
|
85
|
-
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.prose pre code {
|
|
89
|
-
background-color: transparent;
|
|
90
|
-
padding: 0;
|
|
91
|
-
font-size: inherit;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.prose ul {
|
|
95
|
-
margin-top: 1.25em;
|
|
96
|
-
margin-bottom: 1.25em;
|
|
97
|
-
padding-left: 1.625em;
|
|
98
|
-
list-style-type: disc;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.prose li {
|
|
102
|
-
margin-top: 0.5em;
|
|
103
|
-
margin-bottom: 0.5em;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.prose strong {
|
|
107
|
-
font-weight: 600;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* Ensure code blocks in examples are visible */
|
|
111
|
-
.border {
|
|
112
|
-
border-width: 1px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/* Dark mode adjustments */
|
|
116
|
-
@media (prefers-color-scheme: dark) {
|
|
117
|
-
.prose {
|
|
118
|
-
color: var(--color-fg-default);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.prose code {
|
|
122
|
-
background-color: rgba(110, 118, 129, 0.4);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.prose pre {
|
|
126
|
-
background-color: rgba(110, 118, 129, 0.2);
|
|
127
|
-
}
|
|
128
|
-
}
|
package/lib/hooks/useToast.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { ToastActionElement, ToastProps } from '@/components/ui/toast';
|
|
3
|
-
type ToasterToast = ToastProps & {
|
|
4
|
-
id: string;
|
|
5
|
-
title?: React.ReactNode;
|
|
6
|
-
description?: React.ReactNode;
|
|
7
|
-
action?: ToastActionElement;
|
|
8
|
-
};
|
|
9
|
-
declare const actionTypes: {
|
|
10
|
-
readonly ADD_TOAST: "ADD_TOAST";
|
|
11
|
-
readonly UPDATE_TOAST: "UPDATE_TOAST";
|
|
12
|
-
readonly DISMISS_TOAST: "DISMISS_TOAST";
|
|
13
|
-
readonly REMOVE_TOAST: "REMOVE_TOAST";
|
|
14
|
-
};
|
|
15
|
-
type ActionType = typeof actionTypes;
|
|
16
|
-
type Action = {
|
|
17
|
-
type: ActionType['ADD_TOAST'];
|
|
18
|
-
toast: ToasterToast;
|
|
19
|
-
} | {
|
|
20
|
-
type: ActionType['UPDATE_TOAST'];
|
|
21
|
-
toast: Partial<ToasterToast>;
|
|
22
|
-
} | {
|
|
23
|
-
type: ActionType['DISMISS_TOAST'];
|
|
24
|
-
toastId?: ToasterToast['id'];
|
|
25
|
-
} | {
|
|
26
|
-
type: ActionType['REMOVE_TOAST'];
|
|
27
|
-
toastId?: ToasterToast['id'];
|
|
28
|
-
};
|
|
29
|
-
interface State {
|
|
30
|
-
toasts: ToasterToast[];
|
|
31
|
-
}
|
|
32
|
-
export declare const reducer: (state: State, action: Action) => State;
|
|
33
|
-
type Toast = Omit<ToasterToast, 'id'>;
|
|
34
|
-
declare function toast({ ...props }: Toast): {
|
|
35
|
-
id: string;
|
|
36
|
-
dismiss: () => void;
|
|
37
|
-
update: (props: ToasterToast) => void;
|
|
38
|
-
};
|
|
39
|
-
declare function useToast(): {
|
|
40
|
-
toast: typeof toast;
|
|
41
|
-
dismiss: (toastId?: string) => void;
|
|
42
|
-
toasts: ToasterToast[];
|
|
43
|
-
};
|
|
44
|
-
export { useToast, toast };
|
package/lib/hooks/useToast.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
const TOAST_LIMIT = 1;
|
|
7
|
-
const TOAST_REMOVE_DELAY = 1000000;
|
|
8
|
-
const actionTypes = {
|
|
9
|
-
ADD_TOAST: 'ADD_TOAST',
|
|
10
|
-
UPDATE_TOAST: 'UPDATE_TOAST',
|
|
11
|
-
DISMISS_TOAST: 'DISMISS_TOAST',
|
|
12
|
-
REMOVE_TOAST: 'REMOVE_TOAST',
|
|
13
|
-
};
|
|
14
|
-
let count = 0;
|
|
15
|
-
function genId() {
|
|
16
|
-
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
17
|
-
return count.toString();
|
|
18
|
-
}
|
|
19
|
-
const toastTimeouts = new Map();
|
|
20
|
-
const addToRemoveQueue = (toastId) => {
|
|
21
|
-
if (toastTimeouts.has(toastId)) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const timeout = setTimeout(() => {
|
|
25
|
-
toastTimeouts.delete(toastId);
|
|
26
|
-
dispatch({
|
|
27
|
-
type: 'REMOVE_TOAST',
|
|
28
|
-
toastId: toastId,
|
|
29
|
-
});
|
|
30
|
-
}, TOAST_REMOVE_DELAY);
|
|
31
|
-
toastTimeouts.set(toastId, timeout);
|
|
32
|
-
};
|
|
33
|
-
export const reducer = (state, action) => {
|
|
34
|
-
switch (action.type) {
|
|
35
|
-
case 'ADD_TOAST':
|
|
36
|
-
return {
|
|
37
|
-
...state,
|
|
38
|
-
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
39
|
-
};
|
|
40
|
-
case 'UPDATE_TOAST':
|
|
41
|
-
return {
|
|
42
|
-
...state,
|
|
43
|
-
toasts: state.toasts.map(t => t.id === action.toast.id ? { ...t, ...action.toast } : t),
|
|
44
|
-
};
|
|
45
|
-
case 'DISMISS_TOAST': {
|
|
46
|
-
const { toastId } = action;
|
|
47
|
-
if (toastId) {
|
|
48
|
-
addToRemoveQueue(toastId);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
state.toasts.forEach(toast => {
|
|
52
|
-
addToRemoveQueue(toast.id);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
...state,
|
|
57
|
-
toasts: state.toasts.map(t => t.id === toastId || toastId === undefined
|
|
58
|
-
? {
|
|
59
|
-
...t,
|
|
60
|
-
open: false,
|
|
61
|
-
}
|
|
62
|
-
: t),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
case 'REMOVE_TOAST':
|
|
66
|
-
if (action.toastId === undefined) {
|
|
67
|
-
return {
|
|
68
|
-
...state,
|
|
69
|
-
toasts: [],
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
...state,
|
|
74
|
-
toasts: state.toasts.filter(t => t.id !== action.toastId),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const listeners = [];
|
|
79
|
-
let memoryState = { toasts: [] };
|
|
80
|
-
function dispatch(action) {
|
|
81
|
-
memoryState = reducer(memoryState, action);
|
|
82
|
-
listeners.forEach(listener => {
|
|
83
|
-
listener(memoryState);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function toast({ ...props }) {
|
|
87
|
-
const id = genId();
|
|
88
|
-
const update = (props) => dispatch({
|
|
89
|
-
type: 'UPDATE_TOAST',
|
|
90
|
-
toast: { ...props, id },
|
|
91
|
-
});
|
|
92
|
-
const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id });
|
|
93
|
-
dispatch({
|
|
94
|
-
type: 'ADD_TOAST',
|
|
95
|
-
toast: {
|
|
96
|
-
...props,
|
|
97
|
-
id,
|
|
98
|
-
open: true,
|
|
99
|
-
onOpenChange: open => {
|
|
100
|
-
if (!open)
|
|
101
|
-
dismiss();
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
id: id,
|
|
107
|
-
dismiss,
|
|
108
|
-
update,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function useToast() {
|
|
112
|
-
const [state, setState] = React.useState(memoryState);
|
|
113
|
-
React.useEffect(() => {
|
|
114
|
-
listeners.push(setState);
|
|
115
|
-
return () => {
|
|
116
|
-
const index = listeners.indexOf(setState);
|
|
117
|
-
if (index > -1) {
|
|
118
|
-
listeners.splice(index, 1);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}, [state]);
|
|
122
|
-
return {
|
|
123
|
-
...state,
|
|
124
|
-
toast,
|
|
125
|
-
dismiss: (toastId) => dispatch({ type: 'DISMISS_TOAST', toastId }),
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
export { useToast, toast };
|