@invect/ui 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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/Invect-CWpIwZ5F.js +92738 -0
- package/dist/Invect.d.ts +25 -0
- package/dist/InvectShell.d.ts +14 -0
- package/dist/api/agent-tools.api.d.ts +1 -0
- package/dist/api/client.d.ts +207 -0
- package/dist/api/credentials.api.d.ts +47 -0
- package/dist/api/executions.api.d.ts +43 -0
- package/dist/api/flows.api.d.ts +100 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/api/node-data.api.d.ts +66 -0
- package/dist/api/query-keys.d.ts +22 -0
- package/dist/api/triggers.api.d.ts +44 -0
- package/dist/api/types.d.ts +147 -0
- package/dist/api/use-flow-run-stream.d.ts +12 -0
- package/dist/assets/invect-branding.d.ts +4 -0
- package/dist/assets/provider-icons/index.d.ts +8 -0
- package/dist/babel-C9OtljFZ.js +9721 -0
- package/dist/components/PageLayout.d.ts +17 -0
- package/dist/components/chat/ChatInput.d.ts +17 -0
- package/dist/components/chat/ChatMessageList.d.ts +14 -0
- package/dist/components/chat/ChatModelSelector.d.ts +11 -0
- package/dist/components/chat/ChatPanel.d.ts +19 -0
- package/dist/components/chat/ChatPromptOverlay.d.ts +13 -0
- package/dist/components/chat/ChatProviderSelector.d.ts +9 -0
- package/dist/components/chat/ChatSettingsPanel.d.ts +11 -0
- package/dist/components/chat/InlineCredentialSetup.d.ts +9 -0
- package/dist/components/chat/MarkdownRenderer.d.ts +7 -0
- package/dist/components/chat/chat-memory.d.ts +21 -0
- package/dist/components/chat/chat.store.d.ts +416 -0
- package/dist/components/chat/index.d.ts +5 -0
- package/dist/components/chat/use-chat.d.ts +28 -0
- package/dist/components/credentials/CreateCredentialModal.d.ts +13 -0
- package/dist/components/credentials/CredentialDetailDialog.d.ts +17 -0
- package/dist/components/credentials/EditCredentialModal.d.ts +11 -0
- package/dist/components/credentials/OAuth2ConnectButton.d.ts +38 -0
- package/dist/components/credentials/OAuth2ProviderSelector.d.ts +15 -0
- package/dist/components/credentials/credential-utils.d.ts +12 -0
- package/dist/components/credentials/index.d.ts +9 -0
- package/dist/components/dashboard/FailedRunsAlert.d.ts +3 -0
- package/dist/components/dashboard/FlowCard.d.ts +7 -0
- package/dist/components/dashboard/RecentActivityTable.d.ts +9 -0
- package/dist/components/dashboard/StatCard.d.ts +10 -0
- package/dist/components/dashboard/index.d.ts +5 -0
- package/dist/components/dashboard/status-helpers.d.ts +5 -0
- package/dist/components/flow-editor/ActionsSidebar.d.ts +2 -0
- package/dist/components/flow-editor/FlowEditor.d.ts +21 -0
- package/dist/components/flow-editor/FlowHeader.d.ts +9 -0
- package/dist/components/flow-editor/FlowLayout.d.ts +24 -0
- package/dist/components/flow-editor/ModeSwitcher.d.ts +7 -0
- package/dist/components/flow-editor/NodeSidebar.d.ts +24 -0
- package/dist/components/flow-editor/RunControls.d.ts +12 -0
- package/dist/components/flow-editor/ToolConfigPanel.d.ts +16 -0
- package/dist/components/flow-editor/ValidationPanel.d.ts +5 -0
- package/dist/components/flow-editor/flow-editor.store.d.ts +1 -0
- package/dist/components/flow-editor/index.d.ts +6 -0
- package/dist/components/flow-editor/inline-edit.d.ts +10 -0
- package/dist/components/flow-editor/node-config-panel/ConfigFieldWithTemplate.d.ts +26 -0
- package/dist/components/flow-editor/node-config-panel/CredentialCombobox.d.ts +21 -0
- package/dist/components/flow-editor/node-config-panel/CredentialsSection.d.ts +19 -0
- package/dist/components/flow-editor/node-config-panel/DroppableInput.d.ts +20 -0
- package/dist/components/flow-editor/node-config-panel/DynamicSelectField.d.ts +22 -0
- package/dist/components/flow-editor/node-config-panel/JsonPreviewPanel.d.ts +25 -0
- package/dist/components/flow-editor/node-config-panel/NodeConfigPanel.d.ts +14 -0
- package/dist/components/flow-editor/node-config-panel/NodeConfigPanelHeader.d.ts +15 -0
- package/dist/components/flow-editor/node-config-panel/ParametersSection.d.ts +16 -0
- package/dist/components/flow-editor/node-config-panel/SearchableSelectField.d.ts +17 -0
- package/dist/components/flow-editor/node-config-panel/SwitchCasesField.d.ts +18 -0
- package/dist/components/flow-editor/node-config-panel/hooks/index.d.ts +2 -0
- package/dist/components/flow-editor/node-config-panel/hooks/use-node-config-panel-state.d.ts +24 -0
- package/dist/components/flow-editor/node-config-panel/hooks/use-node-execution.d.ts +46 -0
- package/dist/components/flow-editor/node-config-panel/hooks/use-upstream-slots.d.ts +16 -0
- package/dist/components/flow-editor/node-config-panel/panels/AgentToolsPanel.d.ts +18 -0
- package/dist/components/flow-editor/node-config-panel/panels/ConfigurationPanel.d.ts +49 -0
- package/dist/components/flow-editor/node-config-panel/panels/DataMapperPane.d.ts +40 -0
- package/dist/components/flow-editor/node-config-panel/panels/InputPanel.d.ts +49 -0
- package/dist/components/flow-editor/node-config-panel/panels/OutputPanel.d.ts +7 -0
- package/dist/components/flow-editor/node-config-panel/panels/index.d.ts +4 -0
- package/dist/components/flow-editor/node-config-panel/types.d.ts +19 -0
- package/dist/components/flow-editor/node-config-panel/use-node-config-panel-store.d.ts +49 -0
- package/dist/components/flow-editor/node-config-panel/use-node-config-state.d.ts +26 -0
- package/dist/components/flow-editor/node-config-panel/use-run-node.d.ts +16 -0
- package/dist/components/flow-editor/node-config-panel/utils.d.ts +9 -0
- package/dist/components/flow-editor/serialize-to-sdk.d.ts +20 -0
- package/dist/components/flow-editor/toolbar-context.d.ts +2 -0
- package/dist/components/flow-editor/use-copy-paste.d.ts +7 -0
- package/dist/components/flow-editor/use-copy-paste.types.d.ts +38 -0
- package/dist/components/flow-editor/use-flow-editor.d.ts +44 -0
- package/dist/components/flow-runs-table/FlowRunsTable.d.ts +6 -0
- package/dist/components/flow-runs-table/index.d.ts +1 -0
- package/dist/components/flow-viewer/FlowRunsView.d.ts +7 -0
- package/dist/components/flow-viewer/FlowStatusView.d.ts +21 -0
- package/dist/components/flow-viewer/RunSelector.d.ts +13 -0
- package/dist/components/flow-viewer/RunsSidebar.d.ts +14 -0
- package/dist/components/flow-viewer/agent-tool-executions-list.d.ts +7 -0
- package/dist/components/flow-viewer/index.d.ts +1 -0
- package/dist/components/flow-viewer/logs-panel.d.ts +18 -0
- package/dist/components/flow-viewer/use-execution-log-data.d.ts +113 -0
- package/dist/components/graph/BatchFlowEdge.d.ts +33 -0
- package/dist/components/graph/LayoutSelector.d.ts +9 -0
- package/dist/components/graph/index.d.ts +47 -0
- package/dist/components/graph/styleUtils.d.ts +124 -0
- package/dist/components/nodes/AgentConfigPanel.d.ts +24 -0
- package/dist/components/nodes/AgentNode.d.ts +8 -0
- package/dist/components/nodes/AgentToolsBox.d.ts +41 -0
- package/dist/components/nodes/NodeAppendix.d.ts +19 -0
- package/dist/components/nodes/NodeStatusIndicator.d.ts +30 -0
- package/dist/components/nodes/NodeViewContext.d.ts +18 -0
- package/dist/components/nodes/ToolParamField.d.ts +28 -0
- package/dist/components/nodes/ToolSelectorModal.d.ts +80 -0
- package/dist/components/nodes/ToolSelectorParts.d.ts +30 -0
- package/dist/components/nodes/UniversalNode.d.ts +2 -0
- package/dist/components/nodes/createContextAwareNodes.d.ts +6 -0
- package/dist/components/nodes/index.d.ts +22 -0
- package/dist/components/nodes/nodeRegistry.d.ts +13 -0
- package/dist/components/nodes/withNodeContext.d.ts +7 -0
- package/dist/components/shared/InvectLoader.d.ts +8 -0
- package/dist/components/shared/InvectLogo.d.ts +9 -0
- package/dist/components/shared/ProviderIcon.d.ts +23 -0
- package/dist/components/side-menu/side-menu.d.ts +4 -0
- package/dist/components/sidebar/BaseSidebar.d.ts +17 -0
- package/dist/components/sidebar/index.d.ts +1 -0
- package/dist/components/triggers/CronPreview.d.ts +12 -0
- package/dist/components/triggers/index.d.ts +1 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +13 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/codemirror-js-editor.d.ts +25 -0
- package/dist/components/ui/codemirror-json-editor.d.ts +18 -0
- package/dist/components/ui/codemirror-nunjucks-editor.d.ts +13 -0
- package/dist/components/ui/codemirror-vscode-theme.d.ts +24 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/dialog.d.ts +18 -0
- package/dist/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/components/ui/empty-state.d.ts +21 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/popover.d.ts +10 -0
- package/dist/components/ui/resizable.d.ts +8 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/select.d.ts +18 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/switch.d.ts +3 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tree-view.d.ts +107 -0
- package/dist/contexts/AgentToolCallbacksContext.d.ts +23 -0
- package/dist/contexts/ApiContext.d.ts +11 -0
- package/dist/contexts/FlowDataContext.d.ts +9 -0
- package/dist/contexts/NodeRegistryContext.d.ts +14 -0
- package/dist/contexts/PluginRegistryContext.d.ts +39 -0
- package/dist/contexts/ThemeProvider.d.ts +18 -0
- package/dist/contexts/ValidationContext.d.ts +22 -0
- package/dist/demo/DemoInvect.d.ts +11 -0
- package/dist/demo/FlowViewer.d.ts +31 -0
- package/dist/demo/demo-api-client.d.ts +33 -0
- package/dist/demo/index.d.ts +6 -0
- package/dist/demo/sample-data.d.ts +1538 -0
- package/dist/demo.d.ts +2 -0
- package/dist/demo.js +2774 -0
- package/dist/estree-ClbRfS-1.js +7076 -0
- package/dist/fonts/geist-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/iosevka-latin-400-normal.woff2 +0 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-document-title.d.ts +1 -0
- package/dist/hooks/use-flow-data.d.ts +22 -0
- package/dist/hooks/use-invect-portal-class.d.ts +21 -0
- package/dist/hooks/useFlowEditorStore.d.ts +1 -0
- package/dist/index.css +3 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +717 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/prettier.d.ts +13 -0
- package/dist/routes/all-flow-runs.d.ts +5 -0
- package/dist/routes/credentials.d.ts +5 -0
- package/dist/routes/flow-route-layout.d.ts +19 -0
- package/dist/routes/flow-runs.d.ts +5 -0
- package/dist/routes/flow.d.ts +5 -0
- package/dist/routes/home.d.ts +5 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/standalone-C3Df7W52.js +3463 -0
- package/dist/stores/executionViewStore.d.ts +64 -0
- package/dist/stores/flow-editor.store.d.ts +137 -0
- package/dist/stores/flowEditorStore.d.ts +1 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/uiStore.d.ts +45 -0
- package/dist/types/agent-tools.types.d.ts +53 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/node-definition.types.d.ts +85 -0
- package/dist/types/plugin.types.d.ts +100 -0
- package/dist/utils/credentialBranding.d.ts +8 -0
- package/dist/utils/credentialFiltering.d.ts +20 -0
- package/dist/utils/flowTransformations.d.ts +16 -0
- package/dist/utils/layoutUtils.d.ts +23 -0
- package/dist/utils/nodeReferenceUtils.d.ts +37 -0
- package/dist/vendor.d.ts +5 -0
- package/package.json +130 -0
- package/src/.DS_Store +0 -0
- package/src/Invect.tsx +229 -0
- package/src/InvectShell.tsx +55 -0
- package/src/api/agent-tools.api.ts +23 -0
- package/src/api/client.ts +899 -0
- package/src/api/credentials.api.ts +197 -0
- package/src/api/executions.api.ts +228 -0
- package/src/api/flows.api.ts +195 -0
- package/src/api/index.ts +17 -0
- package/src/api/node-data.api.ts +167 -0
- package/src/api/query-keys.ts +44 -0
- package/src/api/triggers.api.ts +120 -0
- package/src/api/types.ts +212 -0
- package/src/api/use-flow-run-stream.ts +206 -0
- package/src/app.css +560 -0
- package/src/assets/.DS_Store +0 -0
- package/src/assets/favicon.ico +0 -0
- package/src/assets/fonts/geist-cyrillic-wght-normal.woff2 +0 -0
- package/src/assets/fonts/geist-latin-ext-wght-normal.woff2 +0 -0
- package/src/assets/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/src/assets/fonts/iosevka-latin-400-normal.woff2 +0 -0
- package/src/assets/invect-branding.ts +51 -0
- package/src/assets/provider-icons/anthropic.svg +1 -0
- package/src/assets/provider-icons/anthropic_light.svg +1 -0
- package/src/assets/provider-icons/github.svg +1 -0
- package/src/assets/provider-icons/github_light.svg +1 -0
- package/src/assets/provider-icons/gmail.svg +1 -0
- package/src/assets/provider-icons/google_calendar.svg +1 -0
- package/src/assets/provider-icons/google_docs.svg +1 -0
- package/src/assets/provider-icons/google_drive.svg +1 -0
- package/src/assets/provider-icons/google_sheets.svg +1 -0
- package/src/assets/provider-icons/index.ts +55 -0
- package/src/assets/provider-icons/linear.svg +1 -0
- package/src/assets/provider-icons/openai.svg +1 -0
- package/src/assets/provider-icons/postgres.svg +1 -0
- package/src/assets/provider-icons/slack.svg +1 -0
- package/src/assets/small-loader-dark.svg +22 -0
- package/src/assets/small-loader-light.svg +22 -0
- package/src/assets/small.svg +7 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/PageLayout.tsx +55 -0
- package/src/components/chat/ChatInput.tsx +115 -0
- package/src/components/chat/ChatMessageList.tsx +788 -0
- package/src/components/chat/ChatModelSelector.tsx +208 -0
- package/src/components/chat/ChatPanel.tsx +243 -0
- package/src/components/chat/ChatPromptOverlay.tsx +150 -0
- package/src/components/chat/ChatProviderSelector.tsx +135 -0
- package/src/components/chat/ChatSettingsPanel.tsx +277 -0
- package/src/components/chat/InlineCredentialSetup.tsx +343 -0
- package/src/components/chat/MarkdownRenderer.tsx +140 -0
- package/src/components/chat/chat-memory.ts +88 -0
- package/src/components/chat/chat.store.ts +479 -0
- package/src/components/chat/index.ts +5 -0
- package/src/components/chat/use-chat.ts +473 -0
- package/src/components/credentials/CreateCredentialModal.tsx +609 -0
- package/src/components/credentials/CredentialDetailDialog.tsx +882 -0
- package/src/components/credentials/EditCredentialModal.tsx +399 -0
- package/src/components/credentials/OAuth2ConnectButton.tsx +288 -0
- package/src/components/credentials/OAuth2ProviderSelector.tsx +360 -0
- package/src/components/credentials/credential-utils.ts +99 -0
- package/src/components/credentials/index.ts +10 -0
- package/src/components/dashboard/FailedRunsAlert.tsx +67 -0
- package/src/components/dashboard/FlowCard.tsx +64 -0
- package/src/components/dashboard/RecentActivityTable.tsx +92 -0
- package/src/components/dashboard/StatCard.tsx +32 -0
- package/src/components/dashboard/index.ts +5 -0
- package/src/components/dashboard/status-helpers.tsx +102 -0
- package/src/components/flow-editor/ActionsSidebar.tsx +503 -0
- package/src/components/flow-editor/FlowEditor.tsx +1002 -0
- package/src/components/flow-editor/FlowHeader.tsx +87 -0
- package/src/components/flow-editor/FlowLayout.tsx +117 -0
- package/src/components/flow-editor/ModeSwitcher.tsx +49 -0
- package/src/components/flow-editor/NodeSidebar.tsx +343 -0
- package/src/components/flow-editor/RunControls.tsx +109 -0
- package/src/components/flow-editor/ToolConfigPanel.tsx +434 -0
- package/src/components/flow-editor/ValidationPanel.tsx +167 -0
- package/src/components/flow-editor/flow-editor.store.ts +2 -0
- package/src/components/flow-editor/index.ts +6 -0
- package/src/components/flow-editor/inline-edit.tsx +111 -0
- package/src/components/flow-editor/node-config-panel/ConfigFieldWithTemplate.tsx +334 -0
- package/src/components/flow-editor/node-config-panel/CredentialCombobox.tsx +217 -0
- package/src/components/flow-editor/node-config-panel/CredentialsSection.tsx +154 -0
- package/src/components/flow-editor/node-config-panel/DroppableInput.tsx +45 -0
- package/src/components/flow-editor/node-config-panel/DynamicSelectField.tsx +223 -0
- package/src/components/flow-editor/node-config-panel/JsonPreviewPanel.tsx +134 -0
- package/src/components/flow-editor/node-config-panel/NodeConfigPanel.tsx +650 -0
- package/src/components/flow-editor/node-config-panel/NodeConfigPanelHeader.tsx +91 -0
- package/src/components/flow-editor/node-config-panel/ParametersSection.tsx +144 -0
- package/src/components/flow-editor/node-config-panel/SearchableSelectField.tsx +126 -0
- package/src/components/flow-editor/node-config-panel/SwitchCasesField.tsx +212 -0
- package/src/components/flow-editor/node-config-panel/hooks/index.ts +2 -0
- package/src/components/flow-editor/node-config-panel/hooks/use-node-config-panel-state.ts +284 -0
- package/src/components/flow-editor/node-config-panel/hooks/use-node-execution.ts +287 -0
- package/src/components/flow-editor/node-config-panel/hooks/use-upstream-slots.ts +310 -0
- package/src/components/flow-editor/node-config-panel/panels/AgentToolsPanel.tsx +837 -0
- package/src/components/flow-editor/node-config-panel/panels/ConfigurationPanel.tsx +383 -0
- package/src/components/flow-editor/node-config-panel/panels/DataMapperPane.tsx +456 -0
- package/src/components/flow-editor/node-config-panel/panels/InputPanel.tsx +338 -0
- package/src/components/flow-editor/node-config-panel/panels/OutputPanel.tsx +109 -0
- package/src/components/flow-editor/node-config-panel/panels/index.ts +4 -0
- package/src/components/flow-editor/node-config-panel/types.ts +20 -0
- package/src/components/flow-editor/node-config-panel/use-node-config-panel-store.ts +283 -0
- package/src/components/flow-editor/node-config-panel/use-node-config-state.ts +172 -0
- package/src/components/flow-editor/node-config-panel/use-run-node.ts +147 -0
- package/src/components/flow-editor/node-config-panel/utils.ts +73 -0
- package/src/components/flow-editor/serialize-to-sdk.ts +204 -0
- package/src/components/flow-editor/toolbar-context.ts +9 -0
- package/src/components/flow-editor/use-copy-paste.ts +575 -0
- package/src/components/flow-editor/use-copy-paste.types.ts +35 -0
- package/src/components/flow-editor/use-flow-editor.ts +241 -0
- package/src/components/flow-runs-table/FlowRunsTable.tsx +631 -0
- package/src/components/flow-runs-table/index.ts +1 -0
- package/src/components/flow-viewer/FlowRunsView.tsx +268 -0
- package/src/components/flow-viewer/FlowStatusView.tsx +351 -0
- package/src/components/flow-viewer/RunSelector.tsx +422 -0
- package/src/components/flow-viewer/RunsSidebar.tsx +125 -0
- package/src/components/flow-viewer/agent-tool-executions-list.tsx +298 -0
- package/src/components/flow-viewer/index.ts +1 -0
- package/src/components/flow-viewer/logs-panel.tsx +567 -0
- package/src/components/flow-viewer/use-execution-log-data.ts +374 -0
- package/src/components/graph/BatchFlowEdge.tsx +229 -0
- package/src/components/graph/LayoutSelector.tsx +42 -0
- package/src/components/graph/index.ts +61 -0
- package/src/components/graph/styleUtils.ts +375 -0
- package/src/components/nodes/.DS_Store +0 -0
- package/src/components/nodes/AgentConfigPanel.tsx +1033 -0
- package/src/components/nodes/AgentNode.tsx +298 -0
- package/src/components/nodes/AgentToolsBox.tsx +193 -0
- package/src/components/nodes/NodeAppendix.tsx +98 -0
- package/src/components/nodes/NodeStatusIndicator.tsx +74 -0
- package/src/components/nodes/NodeViewContext.tsx +45 -0
- package/src/components/nodes/ToolParamField.tsx +282 -0
- package/src/components/nodes/ToolSelectorModal.tsx +648 -0
- package/src/components/nodes/ToolSelectorParts.tsx +505 -0
- package/src/components/nodes/UniversalNode.tsx +356 -0
- package/src/components/nodes/createContextAwareNodes.ts +19 -0
- package/src/components/nodes/index.ts +45 -0
- package/src/components/nodes/nodeRegistry.ts +50 -0
- package/src/components/nodes/withNodeContext.tsx +55 -0
- package/src/components/shared/InvectLoader.tsx +59 -0
- package/src/components/shared/InvectLogo.tsx +59 -0
- package/src/components/shared/ProviderIcon.tsx +115 -0
- package/src/components/side-menu/side-menu.tsx +267 -0
- package/src/components/sidebar/BaseSidebar.tsx +148 -0
- package/src/components/sidebar/index.ts +1 -0
- package/src/components/triggers/CronPreview.tsx +243 -0
- package/src/components/triggers/index.ts +1 -0
- package/src/components/ui/alert-dialog.tsx +152 -0
- package/src/components/ui/badge.tsx +39 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +75 -0
- package/src/components/ui/codemirror-js-editor.tsx +432 -0
- package/src/components/ui/codemirror-json-editor.tsx +816 -0
- package/src/components/ui/codemirror-nunjucks-editor.tsx +451 -0
- package/src/components/ui/codemirror-vscode-theme.ts +243 -0
- package/src/components/ui/collapsible.tsx +12 -0
- package/src/components/ui/command.tsx +162 -0
- package/src/components/ui/dialog.tsx +140 -0
- package/src/components/ui/dropdown-menu.tsx +232 -0
- package/src/components/ui/empty-state.tsx +93 -0
- package/src/components/ui/input.tsx +26 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/popover.tsx +53 -0
- package/src/components/ui/resizable.tsx +61 -0
- package/src/components/ui/scroll-area.tsx +56 -0
- package/src/components/ui/select.tsx +179 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/slider.tsx +58 -0
- package/src/components/ui/switch.tsx +22 -0
- package/src/components/ui/table.tsx +90 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/tooltip.tsx +54 -0
- package/src/components/ui/tree-view.tsx +574 -0
- package/src/contexts/AgentToolCallbacksContext.tsx +31 -0
- package/src/contexts/ApiContext.tsx +51 -0
- package/src/contexts/FlowDataContext.tsx +21 -0
- package/src/contexts/NodeRegistryContext.tsx +54 -0
- package/src/contexts/PluginRegistryContext.tsx +182 -0
- package/src/contexts/ThemeProvider.tsx +106 -0
- package/src/contexts/ValidationContext.tsx +122 -0
- package/src/demo/DemoInvect.tsx +42 -0
- package/src/demo/FlowViewer.tsx +294 -0
- package/src/demo/demo-api-client.ts +246 -0
- package/src/demo/index.ts +28 -0
- package/src/demo/sample-data.ts +1980 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-document-title.ts +8 -0
- package/src/hooks/use-flow-data.ts +144 -0
- package/src/hooks/use-invect-portal-class.ts +27 -0
- package/src/hooks/useFlowEditorStore.ts +2 -0
- package/src/index.ts +70 -0
- package/src/lib/utils.ts +6 -0
- package/src/prettier.d.ts +13 -0
- package/src/routes/all-flow-runs.tsx +27 -0
- package/src/routes/credentials.tsx +362 -0
- package/src/routes/flow-route-layout.tsx +113 -0
- package/src/routes/flow-runs.tsx +22 -0
- package/src/routes/flow.tsx +22 -0
- package/src/routes/home.tsx +282 -0
- package/src/services/index.ts +6 -0
- package/src/stores/executionViewStore.ts +211 -0
- package/src/stores/flow-editor.store.ts +738 -0
- package/src/stores/flowEditorStore.ts +2 -0
- package/src/stores/index.ts +10 -0
- package/src/stores/uiStore.ts +189 -0
- package/src/types/agent-tools.types.ts +64 -0
- package/src/types/index.ts +5 -0
- package/src/types/node-definition.types.ts +104 -0
- package/src/types/plugin.types.ts +123 -0
- package/src/utils/credentialBranding.ts +116 -0
- package/src/utils/credentialFiltering.ts +68 -0
- package/src/utils/flowTransformations.ts +137 -0
- package/src/utils/layoutUtils.ts +127 -0
- package/src/utils/nodeReferenceUtils.ts +135 -0
- package/src/vendor.d.ts +7 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DialogHeader, DialogTitle } from '../../ui/dialog';
|
|
2
|
+
import { InlineEdit } from '../inline-edit';
|
|
3
|
+
import { cn } from '../../../lib/utils';
|
|
4
|
+
import { Button } from '../../ui/button';
|
|
5
|
+
import { Badge } from '../../ui/badge';
|
|
6
|
+
import { Loader2, Play } from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
interface NodeConfigPanelHeaderProps {
|
|
9
|
+
label: string;
|
|
10
|
+
onLabelChange: (value: string) => void;
|
|
11
|
+
nodeTypeLabel: string;
|
|
12
|
+
Icon: React.ComponentType<{ className?: string }>;
|
|
13
|
+
categoryColor: string;
|
|
14
|
+
onRunNode?: () => void;
|
|
15
|
+
runButtonLabel?: string;
|
|
16
|
+
runDisabled?: boolean;
|
|
17
|
+
isRunning?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function NodeConfigPanelHeader({
|
|
21
|
+
label,
|
|
22
|
+
onLabelChange,
|
|
23
|
+
nodeTypeLabel,
|
|
24
|
+
Icon,
|
|
25
|
+
categoryColor,
|
|
26
|
+
onRunNode,
|
|
27
|
+
runButtonLabel = 'Run Node',
|
|
28
|
+
runDisabled = false,
|
|
29
|
+
isRunning = false,
|
|
30
|
+
}: NodeConfigPanelHeaderProps) {
|
|
31
|
+
const handleRunClick = () => {
|
|
32
|
+
if (runDisabled || isRunning) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (onRunNode) {
|
|
36
|
+
onRunNode();
|
|
37
|
+
} else {
|
|
38
|
+
// Provide a safe fallback so the button still responds even if no handler is passed
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.warn('Run Node action not implemented yet');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<DialogHeader className="pt-0 pb-2 text-left border-b border-border">
|
|
46
|
+
<DialogTitle className="sr-only">Configure {label || 'selected'} node</DialogTitle>
|
|
47
|
+
<div className="flex items-center justify-between gap-3">
|
|
48
|
+
<div className="flex items-center gap-3 min-w-0">
|
|
49
|
+
<div
|
|
50
|
+
className={cn(
|
|
51
|
+
'flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border',
|
|
52
|
+
categoryColor,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<Icon className="w-4 h-4" />
|
|
56
|
+
</div>
|
|
57
|
+
<div className="min-w-0">
|
|
58
|
+
<InlineEdit
|
|
59
|
+
value={label}
|
|
60
|
+
onChange={onLabelChange}
|
|
61
|
+
placeholder="Untitled Node"
|
|
62
|
+
displayClassName="text-base font-semibold"
|
|
63
|
+
inputClassName="text-base font-semibold h-auto py-0.5 px-1.5"
|
|
64
|
+
/>
|
|
65
|
+
<Badge variant="outline" className="text-[10px] h-4 px-1.5 capitalize">
|
|
66
|
+
{nodeTypeLabel}
|
|
67
|
+
</Badge>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<Button
|
|
71
|
+
size="sm"
|
|
72
|
+
className="px-4 gap-2 shrink-0"
|
|
73
|
+
onClick={handleRunClick}
|
|
74
|
+
disabled={runDisabled || isRunning}
|
|
75
|
+
>
|
|
76
|
+
{isRunning ? (
|
|
77
|
+
<>
|
|
78
|
+
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
|
79
|
+
Running…
|
|
80
|
+
</>
|
|
81
|
+
) : (
|
|
82
|
+
<>
|
|
83
|
+
<Play className="w-3.5 h-3.5" />
|
|
84
|
+
{runButtonLabel}
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
</DialogHeader>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import type { NodeParamField } from '../../../types/node-definition.types';
|
|
3
|
+
import { ConfigFieldWithTemplate } from './ConfigFieldWithTemplate';
|
|
4
|
+
import { Button } from '../../ui/button';
|
|
5
|
+
import { ChevronDown, ChevronRight, Settings2 } from 'lucide-react';
|
|
6
|
+
import { cn } from '../../../lib/utils';
|
|
7
|
+
|
|
8
|
+
interface ParametersSectionProps {
|
|
9
|
+
fields: NodeParamField[];
|
|
10
|
+
formValues: Record<string, unknown>;
|
|
11
|
+
onFieldChange: (fieldName: string, value: unknown) => void;
|
|
12
|
+
emptyMessage?: string;
|
|
13
|
+
portalContainer?: HTMLElement | null;
|
|
14
|
+
/** Action / node type id — passed through to ConfigFieldWithTemplate for dynamic option loading. */
|
|
15
|
+
nodeType?: string;
|
|
16
|
+
/** Input data from upstream nodes — passed through for autocomplete in code fields. */
|
|
17
|
+
inputData?: Record<string, unknown>;
|
|
18
|
+
/** Per-field validation errors keyed by field name. */
|
|
19
|
+
fieldErrors?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get the template modes object from form values.
|
|
24
|
+
* Template modes track which fields are in "template mode" vs "static mode".
|
|
25
|
+
*/
|
|
26
|
+
function getTemplateModes(formValues: Record<string, unknown>): Record<string, boolean> {
|
|
27
|
+
const modes = formValues._templateModes;
|
|
28
|
+
if (modes && typeof modes === 'object' && !Array.isArray(modes)) {
|
|
29
|
+
return modes as Record<string, boolean>;
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const ParametersSection = ({
|
|
35
|
+
fields,
|
|
36
|
+
formValues,
|
|
37
|
+
onFieldChange,
|
|
38
|
+
emptyMessage,
|
|
39
|
+
portalContainer,
|
|
40
|
+
nodeType,
|
|
41
|
+
inputData,
|
|
42
|
+
fieldErrors,
|
|
43
|
+
}: ParametersSectionProps) => {
|
|
44
|
+
const templateModes = getTemplateModes(formValues);
|
|
45
|
+
const [showExtended, setShowExtended] = useState(false);
|
|
46
|
+
|
|
47
|
+
// Separate standard and extended fields
|
|
48
|
+
const { standardFields, extendedFields } = useMemo(() => {
|
|
49
|
+
const standard: NodeParamField[] = [];
|
|
50
|
+
const extended: NodeParamField[] = [];
|
|
51
|
+
|
|
52
|
+
for (const field of fields) {
|
|
53
|
+
if (field.extended) {
|
|
54
|
+
extended.push(field);
|
|
55
|
+
} else {
|
|
56
|
+
standard.push(field);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { standardFields: standard, extendedFields: extended };
|
|
61
|
+
}, [fields]);
|
|
62
|
+
const hasExpandableFields = useMemo(
|
|
63
|
+
() => fields.some((field) => ['textarea', 'json', 'code'].includes(field.type)),
|
|
64
|
+
[fields],
|
|
65
|
+
);
|
|
66
|
+
const hasExpandableExtendedFields = useMemo(
|
|
67
|
+
() => extendedFields.some((field) => ['textarea', 'json', 'code'].includes(field.type)),
|
|
68
|
+
[extendedFields],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const handleTemplateModeChange = useCallback(
|
|
72
|
+
(fieldName: string, enabled: boolean) => {
|
|
73
|
+
const currentModes = getTemplateModes(formValues);
|
|
74
|
+
const updatedModes = {
|
|
75
|
+
...currentModes,
|
|
76
|
+
[fieldName]: enabled,
|
|
77
|
+
};
|
|
78
|
+
onFieldChange('_templateModes', updatedModes);
|
|
79
|
+
},
|
|
80
|
+
[formValues, onFieldChange],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const renderField = (field: NodeParamField) => (
|
|
84
|
+
<ConfigFieldWithTemplate
|
|
85
|
+
key={field.name}
|
|
86
|
+
field={field}
|
|
87
|
+
value={formValues[field.name]}
|
|
88
|
+
onChange={(value) => onFieldChange(field.name, value)}
|
|
89
|
+
templateMode={templateModes[field.name] ?? false}
|
|
90
|
+
onTemplateModeChange={(enabled) => handleTemplateModeChange(field.name, enabled)}
|
|
91
|
+
portalContainer={portalContainer}
|
|
92
|
+
nodeType={nodeType}
|
|
93
|
+
formValues={formValues}
|
|
94
|
+
inputData={inputData}
|
|
95
|
+
error={fieldErrors?.[field.name]}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (!fields.length) {
|
|
100
|
+
return <div className="text-xs text-muted-foreground">{emptyMessage}</div>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div className={cn('flex flex-col gap-3 text-xs', hasExpandableFields && 'flex-1 min-h-0')}>
|
|
105
|
+
{/* Standard fields */}
|
|
106
|
+
{standardFields.map(renderField)}
|
|
107
|
+
|
|
108
|
+
{/* Extended options section */}
|
|
109
|
+
{extendedFields.length > 0 && (
|
|
110
|
+
<div className="flex flex-col gap-2 mt-1">
|
|
111
|
+
<Button
|
|
112
|
+
variant="ghost"
|
|
113
|
+
size="sm"
|
|
114
|
+
className={cn(
|
|
115
|
+
'justify-start gap-1.5 h-7 px-2 text-[11px] text-muted-foreground hover:text-foreground',
|
|
116
|
+
showExtended && 'text-foreground',
|
|
117
|
+
)}
|
|
118
|
+
onClick={() => setShowExtended(!showExtended)}
|
|
119
|
+
>
|
|
120
|
+
{showExtended ? (
|
|
121
|
+
<ChevronDown className="w-3.5 h-3.5" />
|
|
122
|
+
) : (
|
|
123
|
+
<ChevronRight className="w-3.5 h-3.5" />
|
|
124
|
+
)}
|
|
125
|
+
<Settings2 className="w-3 h-3" />
|
|
126
|
+
<span>More Options</span>
|
|
127
|
+
<span className="text-muted-foreground">({extendedFields.length})</span>
|
|
128
|
+
</Button>
|
|
129
|
+
|
|
130
|
+
{showExtended && (
|
|
131
|
+
<div
|
|
132
|
+
className={cn(
|
|
133
|
+
'flex flex-col gap-3 pl-3 ml-2 border-l-2 border-muted',
|
|
134
|
+
hasExpandableExtendedFields && 'flex-1 min-h-0',
|
|
135
|
+
)}
|
|
136
|
+
>
|
|
137
|
+
{extendedFields.map(renderField)}
|
|
138
|
+
</div>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { Check, ChevronsUpDown } from 'lucide-react';
|
|
3
|
+
import { cn } from '../../../lib/utils';
|
|
4
|
+
import { Button } from '../../ui/button';
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover';
|
|
6
|
+
import {
|
|
7
|
+
Command,
|
|
8
|
+
CommandEmpty,
|
|
9
|
+
CommandGroup,
|
|
10
|
+
CommandInput,
|
|
11
|
+
CommandItem,
|
|
12
|
+
CommandList,
|
|
13
|
+
} from '../../ui/command';
|
|
14
|
+
|
|
15
|
+
interface SearchableSelectFieldProps {
|
|
16
|
+
id?: string;
|
|
17
|
+
value: string;
|
|
18
|
+
options: { label: string; value: string }[];
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
onChange: (value: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A searchable select field using a combobox pattern (Popover + Command).
|
|
26
|
+
* Used for select fields with many options (e.g. model lists).
|
|
27
|
+
*/
|
|
28
|
+
export function SearchableSelectField({
|
|
29
|
+
id,
|
|
30
|
+
value,
|
|
31
|
+
options,
|
|
32
|
+
placeholder = 'Select…',
|
|
33
|
+
disabled,
|
|
34
|
+
onChange,
|
|
35
|
+
}: SearchableSelectFieldProps) {
|
|
36
|
+
const [open, setOpen] = useState(false);
|
|
37
|
+
const [search, setSearch] = useState('');
|
|
38
|
+
|
|
39
|
+
const filtered = useMemo(() => {
|
|
40
|
+
if (!search) {
|
|
41
|
+
return options;
|
|
42
|
+
}
|
|
43
|
+
const lower = search.toLowerCase();
|
|
44
|
+
return options.filter(
|
|
45
|
+
(o) => o.label.toLowerCase().includes(lower) || o.value.toLowerCase().includes(lower),
|
|
46
|
+
);
|
|
47
|
+
}, [options, search]);
|
|
48
|
+
|
|
49
|
+
const handleSelect = useCallback(
|
|
50
|
+
(val: string) => {
|
|
51
|
+
onChange(val);
|
|
52
|
+
setOpen(false);
|
|
53
|
+
setSearch('');
|
|
54
|
+
},
|
|
55
|
+
[onChange],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!open) {
|
|
60
|
+
setSearch('');
|
|
61
|
+
}
|
|
62
|
+
}, [open]);
|
|
63
|
+
|
|
64
|
+
const displayLabel = useMemo(() => {
|
|
65
|
+
if (!value) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const match = options.find((o) => o.value === value);
|
|
69
|
+
return match?.label ?? value;
|
|
70
|
+
}, [value, options]);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
74
|
+
<PopoverTrigger asChild>
|
|
75
|
+
<Button
|
|
76
|
+
variant="outline"
|
|
77
|
+
role="combobox"
|
|
78
|
+
aria-expanded={open}
|
|
79
|
+
id={id}
|
|
80
|
+
disabled={disabled}
|
|
81
|
+
className={cn(
|
|
82
|
+
'w-full justify-between font-mono text-xs h-9',
|
|
83
|
+
!value && 'text-muted-foreground',
|
|
84
|
+
)}
|
|
85
|
+
>
|
|
86
|
+
<span className="truncate">{displayLabel ?? placeholder}</span>
|
|
87
|
+
<ChevronsUpDown className="w-3 h-3 ml-auto opacity-50 shrink-0" />
|
|
88
|
+
</Button>
|
|
89
|
+
</PopoverTrigger>
|
|
90
|
+
<PopoverContent className="w-(--radix-popover-trigger-width) p-0" align="start">
|
|
91
|
+
<Command shouldFilter={false}>
|
|
92
|
+
<CommandInput
|
|
93
|
+
placeholder="Search…"
|
|
94
|
+
className="h-8 text-xs"
|
|
95
|
+
value={search}
|
|
96
|
+
onValueChange={setSearch}
|
|
97
|
+
/>
|
|
98
|
+
<CommandList className="max-h-52">
|
|
99
|
+
{filtered.length === 0 && (
|
|
100
|
+
<CommandEmpty className="text-xs">
|
|
101
|
+
{search ? 'No matching options' : 'No options available'}
|
|
102
|
+
</CommandEmpty>
|
|
103
|
+
)}
|
|
104
|
+
{filtered.length > 0 && (
|
|
105
|
+
<CommandGroup>
|
|
106
|
+
{filtered
|
|
107
|
+
.filter((o) => o.value !== '')
|
|
108
|
+
.map((option) => (
|
|
109
|
+
<CommandItem
|
|
110
|
+
key={option.value}
|
|
111
|
+
value={option.value}
|
|
112
|
+
onSelect={() => handleSelect(option.value)}
|
|
113
|
+
className="font-mono text-xs"
|
|
114
|
+
>
|
|
115
|
+
<span className="truncate">{option.label}</span>
|
|
116
|
+
{value === option.value && <Check className="w-3 h-3 ml-auto shrink-0" />}
|
|
117
|
+
</CommandItem>
|
|
118
|
+
))}
|
|
119
|
+
</CommandGroup>
|
|
120
|
+
)}
|
|
121
|
+
</CommandList>
|
|
122
|
+
</Command>
|
|
123
|
+
</PopoverContent>
|
|
124
|
+
</Popover>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { Button } from '../../ui/button';
|
|
3
|
+
import { Input } from '../../ui/input';
|
|
4
|
+
import { Label } from '../../ui/label';
|
|
5
|
+
import { Plus, Trash2, ArrowUp, ArrowDown, Lock } from 'lucide-react';
|
|
6
|
+
import { toReferenceId } from '../../../utils/nodeReferenceUtils';
|
|
7
|
+
import { useFlowEditorStore } from '../flow-editor.store';
|
|
8
|
+
import { CodeMirrorJsEditor } from '../../ui/codemirror-js-editor';
|
|
9
|
+
|
|
10
|
+
interface SwitchCase {
|
|
11
|
+
slug: string;
|
|
12
|
+
label: string;
|
|
13
|
+
expression: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface SwitchCasesFieldProps {
|
|
17
|
+
value: unknown;
|
|
18
|
+
onChange: (value: SwitchCase[]) => void;
|
|
19
|
+
nodeId: string | null;
|
|
20
|
+
inputData?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Custom field renderer for the switch node's `cases` parameter.
|
|
25
|
+
* Renders an ordered list of cases, each with a label, slug, and JS expression.
|
|
26
|
+
* The default branch is always shown at the bottom and cannot be removed.
|
|
27
|
+
*/
|
|
28
|
+
export function SwitchCasesField({ value, onChange, nodeId, inputData }: SwitchCasesFieldProps) {
|
|
29
|
+
const removeEdgesBySourceHandle = useFlowEditorStore((s) => s.removeEdgesBySourceHandle);
|
|
30
|
+
const edges = useFlowEditorStore((s) => s.edges);
|
|
31
|
+
|
|
32
|
+
const cases: SwitchCase[] = Array.isArray(value) ? (value as SwitchCase[]) : [];
|
|
33
|
+
|
|
34
|
+
const hasEdgesForHandle = useCallback(
|
|
35
|
+
(slug: string) => {
|
|
36
|
+
if (!nodeId) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return edges.some((e) => e.source === nodeId && e.sourceHandle === slug);
|
|
40
|
+
},
|
|
41
|
+
[nodeId, edges],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const generateUniqueSlug = useCallback((label: string, existingSlugs: Set<string>) => {
|
|
45
|
+
let base = toReferenceId(label);
|
|
46
|
+
if (!base) {
|
|
47
|
+
base = 'case';
|
|
48
|
+
}
|
|
49
|
+
if (base === 'default') {
|
|
50
|
+
base = 'case_default';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let slug = base;
|
|
54
|
+
let counter = 2;
|
|
55
|
+
while (existingSlugs.has(slug)) {
|
|
56
|
+
slug = `${base}_${counter}`;
|
|
57
|
+
counter++;
|
|
58
|
+
}
|
|
59
|
+
return slug;
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const handleAddCase = useCallback(() => {
|
|
63
|
+
const existingSlugs = new Set(cases.map((c) => c.slug));
|
|
64
|
+
existingSlugs.add('default');
|
|
65
|
+
const index = cases.length;
|
|
66
|
+
const label = `Case ${index}`;
|
|
67
|
+
const slug = generateUniqueSlug(label, existingSlugs);
|
|
68
|
+
onChange([...cases, { slug, label, expression: '' }]);
|
|
69
|
+
}, [cases, onChange, generateUniqueSlug]);
|
|
70
|
+
|
|
71
|
+
const handleRemoveCase = useCallback(
|
|
72
|
+
(index: number) => {
|
|
73
|
+
const removed = cases[index];
|
|
74
|
+
if (removed && nodeId) {
|
|
75
|
+
removeEdgesBySourceHandle(nodeId, removed.slug);
|
|
76
|
+
}
|
|
77
|
+
onChange(cases.filter((_, i) => i !== index));
|
|
78
|
+
},
|
|
79
|
+
[cases, onChange, nodeId, removeEdgesBySourceHandle],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const handleUpdateCase = useCallback(
|
|
83
|
+
(index: number, field: keyof SwitchCase, val: string) => {
|
|
84
|
+
const updated = [...cases];
|
|
85
|
+
const existing = updated[index];
|
|
86
|
+
if (!existing) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (field === 'label') {
|
|
91
|
+
const hasEdges = hasEdgesForHandle(existing.slug);
|
|
92
|
+
if (!hasEdges) {
|
|
93
|
+
// Auto-update slug when label changes and no edges are connected
|
|
94
|
+
const existingSlugs = new Set(cases.map((c, i) => (i === index ? '' : c.slug)));
|
|
95
|
+
existingSlugs.add('default');
|
|
96
|
+
existingSlugs.delete('');
|
|
97
|
+
const newSlug = generateUniqueSlug(val, existingSlugs);
|
|
98
|
+
updated[index] = { ...existing, label: val, slug: newSlug };
|
|
99
|
+
} else {
|
|
100
|
+
updated[index] = { ...existing, label: val };
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
updated[index] = { ...existing, [field]: val };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onChange(updated);
|
|
107
|
+
},
|
|
108
|
+
[cases, onChange, hasEdgesForHandle, generateUniqueSlug],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const handleMoveCase = useCallback(
|
|
112
|
+
(index: number, direction: -1 | 1) => {
|
|
113
|
+
const newIndex = index + direction;
|
|
114
|
+
if (newIndex < 0 || newIndex >= cases.length) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const updated = [...cases];
|
|
118
|
+
const temp = updated[index];
|
|
119
|
+
updated[index] = updated[newIndex] as (typeof updated)[number];
|
|
120
|
+
updated[newIndex] = temp as (typeof updated)[number];
|
|
121
|
+
onChange(updated);
|
|
122
|
+
},
|
|
123
|
+
[cases, onChange],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className="flex flex-col gap-2">
|
|
128
|
+
<Label className="text-xs">Cases</Label>
|
|
129
|
+
|
|
130
|
+
{cases.map((c, index) => (
|
|
131
|
+
<div
|
|
132
|
+
key={c.slug}
|
|
133
|
+
className="flex flex-col gap-1.5 p-2 rounded-md border border-border bg-muted/30"
|
|
134
|
+
>
|
|
135
|
+
<div className="flex items-center gap-1">
|
|
136
|
+
<span className="text-[10px] text-muted-foreground font-mono w-4 shrink-0">
|
|
137
|
+
{index + 1}.
|
|
138
|
+
</span>
|
|
139
|
+
<Input
|
|
140
|
+
className="h-6 text-xs flex-1"
|
|
141
|
+
value={c.label}
|
|
142
|
+
onChange={(e) => handleUpdateCase(index, 'label', e.target.value)}
|
|
143
|
+
placeholder="Case label"
|
|
144
|
+
/>
|
|
145
|
+
<div className="flex items-center gap-0.5">
|
|
146
|
+
<Button
|
|
147
|
+
variant="ghost"
|
|
148
|
+
size="sm"
|
|
149
|
+
className="h-6 w-6 p-0"
|
|
150
|
+
onClick={() => handleMoveCase(index, -1)}
|
|
151
|
+
disabled={index === 0}
|
|
152
|
+
title="Move up"
|
|
153
|
+
>
|
|
154
|
+
<ArrowUp className="w-3 h-3" />
|
|
155
|
+
</Button>
|
|
156
|
+
<Button
|
|
157
|
+
variant="ghost"
|
|
158
|
+
size="sm"
|
|
159
|
+
className="h-6 w-6 p-0"
|
|
160
|
+
onClick={() => handleMoveCase(index, 1)}
|
|
161
|
+
disabled={index === cases.length - 1}
|
|
162
|
+
title="Move down"
|
|
163
|
+
>
|
|
164
|
+
<ArrowDown className="w-3 h-3" />
|
|
165
|
+
</Button>
|
|
166
|
+
<Button
|
|
167
|
+
variant="ghost"
|
|
168
|
+
size="sm"
|
|
169
|
+
className="h-6 w-6 p-0 text-destructive hover:text-destructive"
|
|
170
|
+
onClick={() => handleRemoveCase(index)}
|
|
171
|
+
title="Remove case"
|
|
172
|
+
>
|
|
173
|
+
<Trash2 className="w-3 h-3" />
|
|
174
|
+
</Button>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
<div className="pl-5">
|
|
178
|
+
<CodeMirrorJsEditor
|
|
179
|
+
value={c.expression}
|
|
180
|
+
onChange={(val) => handleUpdateCase(index, 'expression', val)}
|
|
181
|
+
placeholder='priority === "high"'
|
|
182
|
+
inputData={inputData}
|
|
183
|
+
hideGutter
|
|
184
|
+
hideToolbar
|
|
185
|
+
hideResize
|
|
186
|
+
defaultHeight={76}
|
|
187
|
+
minHeight={76}
|
|
188
|
+
maxHeight={76}
|
|
189
|
+
/>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
))}
|
|
193
|
+
|
|
194
|
+
{/* Default branch — always present, not removable */}
|
|
195
|
+
<div className="flex items-center gap-2 p-2 rounded-md border border-border bg-muted/20">
|
|
196
|
+
<Lock className="w-3 h-3 text-muted-foreground shrink-0" />
|
|
197
|
+
<span className="text-xs text-muted-foreground">Default — matches when no case does</span>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<Button
|
|
201
|
+
variant="outline"
|
|
202
|
+
size="sm"
|
|
203
|
+
className="h-7 text-xs gap-1"
|
|
204
|
+
onClick={handleAddCase}
|
|
205
|
+
disabled={cases.length >= 4}
|
|
206
|
+
>
|
|
207
|
+
<Plus className="w-3 h-3" />
|
|
208
|
+
Add Case
|
|
209
|
+
</Button>
|
|
210
|
+
</div>
|
|
211
|
+
);
|
|
212
|
+
}
|