@flowdrop/flowdrop 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +252 -0
- package/dist/adapters/WorkflowAdapter.d.ts +167 -0
- package/dist/adapters/WorkflowAdapter.js +368 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +96 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.js +626 -0
- package/dist/adapters/agentspec/agentAdapter.d.ts +59 -0
- package/dist/adapters/agentspec/agentAdapter.js +91 -0
- package/dist/adapters/agentspec/autoLayout.d.ts +34 -0
- package/dist/adapters/agentspec/autoLayout.js +127 -0
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +73 -0
- package/dist/adapters/agentspec/componentTypeDefaults.js +238 -0
- package/dist/adapters/agentspec/defaultNodeTypes.d.ts +53 -0
- package/dist/adapters/agentspec/defaultNodeTypes.js +561 -0
- package/dist/adapters/agentspec/index.d.ts +37 -0
- package/dist/adapters/agentspec/index.js +39 -0
- package/dist/adapters/agentspec/validator.d.ts +34 -0
- package/dist/adapters/agentspec/validator.js +169 -0
- package/dist/api/enhanced-client.d.ts +183 -0
- package/dist/api/enhanced-client.js +430 -0
- package/dist/components/App.svelte +981 -0
- package/dist/components/App.svelte.d.ts +54 -0
- package/dist/components/CanvasBanner.stories.svelte +29 -0
- package/dist/components/CanvasBanner.stories.svelte.d.ts +27 -0
- package/dist/components/CanvasBanner.svelte +57 -0
- package/dist/components/CanvasBanner.svelte.d.ts +8 -0
- package/dist/components/ConfigForm.svelte +1138 -0
- package/dist/components/ConfigForm.svelte.d.ts +44 -0
- package/dist/components/ConfigModal.svelte +188 -0
- package/dist/components/ConfigModal.svelte.d.ts +13 -0
- package/dist/components/ConfigPanel.stories.svelte +47 -0
- package/dist/components/ConfigPanel.stories.svelte.d.ts +27 -0
- package/dist/components/ConfigPanel.svelte +182 -0
- package/dist/components/ConfigPanel.svelte.d.ts +32 -0
- package/dist/components/ConnectionLine.svelte +32 -0
- package/dist/components/ConnectionLine.svelte.d.ts +3 -0
- package/dist/components/EdgeRefresher.svelte +41 -0
- package/dist/components/EdgeRefresher.svelte.d.ts +9 -0
- package/dist/components/FlowDropZone.svelte +83 -0
- package/dist/components/FlowDropZone.svelte.d.ts +13 -0
- package/dist/components/LoadingSpinner.stories.svelte +30 -0
- package/dist/components/LoadingSpinner.stories.svelte.d.ts +27 -0
- package/dist/components/LoadingSpinner.svelte +36 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +8 -0
- package/dist/components/Logo.stories.svelte +22 -0
- package/dist/components/Logo.stories.svelte.d.ts +27 -0
- package/dist/components/Logo.svelte +102 -0
- package/dist/components/Logo.svelte.d.ts +26 -0
- package/dist/components/LogsSidebar.svelte +563 -0
- package/dist/components/LogsSidebar.svelte.d.ts +17 -0
- package/dist/components/MarkdownDisplay.stories.svelte +36 -0
- package/dist/components/MarkdownDisplay.stories.svelte.d.ts +27 -0
- package/dist/components/MarkdownDisplay.svelte +29 -0
- package/dist/components/MarkdownDisplay.svelte.d.ts +7 -0
- package/dist/components/Navbar.stories.svelte +53 -0
- package/dist/components/Navbar.stories.svelte.d.ts +27 -0
- package/dist/components/Navbar.svelte +726 -0
- package/dist/components/Navbar.svelte.d.ts +29 -0
- package/dist/components/NodeSidebar.svelte +762 -0
- package/dist/components/NodeSidebar.svelte.d.ts +9 -0
- package/dist/components/NodeStatusOverlay.stories.svelte +85 -0
- package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +27 -0
- package/dist/components/NodeStatusOverlay.svelte +327 -0
- package/dist/components/NodeStatusOverlay.svelte.d.ts +11 -0
- package/dist/components/PipelineStatus.svelte +314 -0
- package/dist/components/PipelineStatus.svelte.d.ts +20 -0
- package/dist/components/PortCoordinateTracker.svelte +58 -0
- package/dist/components/PortCoordinateTracker.svelte.d.ts +12 -0
- package/dist/components/ReadOnlyDetails.svelte +170 -0
- package/dist/components/ReadOnlyDetails.svelte.d.ts +25 -0
- package/dist/components/SchemaForm.stories.svelte +116 -0
- package/dist/components/SchemaForm.stories.svelte.d.ts +27 -0
- package/dist/components/SchemaForm.svelte +536 -0
- package/dist/components/SchemaForm.svelte.d.ts +83 -0
- package/dist/components/SettingsModal.svelte +279 -0
- package/dist/components/SettingsModal.svelte.d.ts +23 -0
- package/dist/components/SettingsPanel.svelte +638 -0
- package/dist/components/SettingsPanel.svelte.d.ts +21 -0
- package/dist/components/StatusIcon.stories.svelte +60 -0
- package/dist/components/StatusIcon.stories.svelte.d.ts +27 -0
- package/dist/components/StatusIcon.svelte +119 -0
- package/dist/components/StatusIcon.svelte.d.ts +10 -0
- package/dist/components/StatusLabel.stories.svelte +17 -0
- package/dist/components/StatusLabel.stories.svelte.d.ts +27 -0
- package/dist/components/StatusLabel.svelte +33 -0
- package/dist/components/StatusLabel.svelte.d.ts +7 -0
- package/dist/components/ThemeToggle.stories.svelte +25 -0
- package/dist/components/ThemeToggle.stories.svelte.d.ts +27 -0
- package/dist/components/ThemeToggle.svelte +185 -0
- package/dist/components/ThemeToggle.svelte.d.ts +14 -0
- package/dist/components/UniversalNode.svelte +155 -0
- package/dist/components/UniversalNode.svelte.d.ts +15 -0
- package/dist/components/WorkflowEditor.svelte +1035 -0
- package/dist/components/WorkflowEditor.svelte.d.ts +23 -0
- package/dist/components/form/FormArray.svelte +1049 -0
- package/dist/components/form/FormArray.svelte.d.ts +22 -0
- package/dist/components/form/FormAutocomplete.svelte +1009 -0
- package/dist/components/form/FormAutocomplete.svelte.d.ts +25 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte +28 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormCheckboxGroup.svelte +155 -0
- package/dist/components/form/FormCheckboxGroup.svelte.d.ts +17 -0
- package/dist/components/form/FormCodeEditor.svelte +458 -0
- package/dist/components/form/FormCodeEditor.svelte.d.ts +25 -0
- package/dist/components/form/FormField.svelte +417 -0
- package/dist/components/form/FormField.svelte.d.ts +29 -0
- package/dist/components/form/FormFieldLight.svelte +425 -0
- package/dist/components/form/FormFieldLight.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte +53 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormFieldWrapper.svelte +125 -0
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldset.svelte +142 -0
- package/dist/components/form/FormFieldset.svelte.d.ts +11 -0
- package/dist/components/form/FormMarkdownEditor.svelte +752 -0
- package/dist/components/form/FormMarkdownEditor.svelte.d.ts +33 -0
- package/dist/components/form/FormNumberField.stories.svelte +36 -0
- package/dist/components/form/FormNumberField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormNumberField.svelte +112 -0
- package/dist/components/form/FormNumberField.svelte.d.ts +25 -0
- package/dist/components/form/FormRangeField.stories.svelte +31 -0
- package/dist/components/form/FormRangeField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormRangeField.svelte +246 -0
- package/dist/components/form/FormRangeField.svelte.d.ts +23 -0
- package/dist/components/form/FormSelect.stories.svelte +50 -0
- package/dist/components/form/FormSelect.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormSelect.svelte +129 -0
- package/dist/components/form/FormSelect.svelte.d.ts +20 -0
- package/dist/components/form/FormTemplateEditor.svelte +825 -0
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +41 -0
- package/dist/components/form/FormTextField.stories.svelte +30 -0
- package/dist/components/form/FormTextField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextField.svelte +91 -0
- package/dist/components/form/FormTextField.svelte.d.ts +19 -0
- package/dist/components/form/FormTextarea.stories.svelte +34 -0
- package/dist/components/form/FormTextarea.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextarea.svelte +97 -0
- package/dist/components/form/FormTextarea.svelte.d.ts +21 -0
- package/dist/components/form/FormToggle.stories.svelte +30 -0
- package/dist/components/form/FormToggle.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormToggle.svelte +126 -0
- package/dist/components/form/FormToggle.svelte.d.ts +19 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +136 -0
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +32 -0
- package/dist/components/form/index.d.ts +50 -0
- package/dist/components/form/index.js +54 -0
- package/dist/components/form/templateAutocomplete.d.ts +29 -0
- package/dist/components/form/templateAutocomplete.js +254 -0
- package/dist/components/form/types.d.ts +485 -0
- package/dist/components/form/types.js +73 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte +52 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +401 -0
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +71 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte +292 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +25 -0
- package/dist/components/interrupt/FormPrompt.svelte +236 -0
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/InterruptBubble.svelte +601 -0
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte +67 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ReviewPrompt.svelte +861 -0
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte +47 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/TextInputPrompt.svelte +346 -0
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/index.d.ts +13 -0
- package/dist/components/interrupt/index.js +15 -0
- package/dist/components/layouts/MainLayout.svelte +718 -0
- package/dist/components/layouts/MainLayout.svelte.d.ts +62 -0
- package/dist/components/nodes/GatewayNode.stories.svelte +108 -0
- package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/GatewayNode.svelte +591 -0
- package/dist/components/nodes/GatewayNode.svelte.d.ts +15 -0
- package/dist/components/nodes/IdeaNode.stories.svelte +52 -0
- package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/IdeaNode.svelte +455 -0
- package/dist/components/nodes/IdeaNode.svelte.d.ts +24 -0
- package/dist/components/nodes/NotesNode.stories.svelte +76 -0
- package/dist/components/nodes/NotesNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/NotesNode.svelte +378 -0
- package/dist/components/nodes/NotesNode.svelte.d.ts +24 -0
- package/dist/components/nodes/SimpleNode.stories.svelte +159 -0
- package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SimpleNode.svelte +451 -0
- package/dist/components/nodes/SimpleNode.svelte.d.ts +25 -0
- package/dist/components/nodes/SquareNode.stories.svelte +82 -0
- package/dist/components/nodes/SquareNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SquareNode.svelte +407 -0
- package/dist/components/nodes/SquareNode.svelte.d.ts +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/TerminalNode.svelte +690 -0
- package/dist/components/nodes/TerminalNode.svelte.d.ts +25 -0
- package/dist/components/nodes/ToolNode.stories.svelte +189 -0
- package/dist/components/nodes/ToolNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/ToolNode.svelte +471 -0
- package/dist/components/nodes/ToolNode.svelte.d.ts +36 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte +55 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/WorkflowNode.svelte +571 -0
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +15 -0
- package/dist/components/playground/ChatPanel.svelte +905 -0
- package/dist/components/playground/ChatPanel.svelte.d.ts +46 -0
- package/dist/components/playground/ExecutionLogs.svelte +488 -0
- package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
- package/dist/components/playground/InputCollector.svelte +444 -0
- package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
- package/dist/components/playground/MessageBubble.stories.svelte +62 -0
- package/dist/components/playground/MessageBubble.stories.svelte.d.ts +27 -0
- package/dist/components/playground/MessageBubble.svelte +633 -0
- package/dist/components/playground/MessageBubble.svelte.d.ts +24 -0
- package/dist/components/playground/Playground.svelte +1075 -0
- package/dist/components/playground/Playground.svelte.d.ts +25 -0
- package/dist/components/playground/PlaygroundModal.svelte +220 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +25 -0
- package/dist/components/playground/SessionManager.svelte +538 -0
- package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
- package/dist/config/agentSpecEndpoints.d.ts +70 -0
- package/dist/config/agentSpecEndpoints.js +65 -0
- package/dist/config/constants.d.ts +43 -0
- package/dist/config/constants.js +31 -0
- package/dist/config/defaultCategories.d.ts +7 -0
- package/dist/config/defaultCategories.js +126 -0
- package/dist/config/defaultPortConfig.d.ts +6 -0
- package/dist/config/defaultPortConfig.js +201 -0
- package/dist/config/endpoints.d.ts +160 -0
- package/dist/config/endpoints.js +146 -0
- package/dist/config/runtimeConfig.d.ts +47 -0
- package/dist/config/runtimeConfig.js +80 -0
- package/dist/core/index.d.ts +75 -0
- package/dist/core/index.js +92 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +36 -0
- package/dist/editor/index.d.ts +95 -0
- package/dist/editor/index.js +138 -0
- package/dist/form/code.d.ts +101 -0
- package/dist/form/code.js +168 -0
- package/dist/form/fieldRegistry.d.ts +169 -0
- package/dist/form/fieldRegistry.js +152 -0
- package/dist/form/full.d.ts +56 -0
- package/dist/form/full.js +80 -0
- package/dist/form/index.d.ts +77 -0
- package/dist/form/index.js +91 -0
- package/dist/form/markdown.d.ts +69 -0
- package/dist/form/markdown.js +103 -0
- package/dist/helpers/nodeLayoutHelper.d.ts +14 -0
- package/dist/helpers/nodeLayoutHelper.js +19 -0
- package/dist/helpers/proximityConnect.d.ts +94 -0
- package/dist/helpers/proximityConnect.js +314 -0
- package/dist/helpers/workflowEditorHelper.d.ts +183 -0
- package/dist/helpers/workflowEditorHelper.js +595 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +64 -0
- package/dist/mocks/app-environment.d.ts +8 -0
- package/dist/mocks/app-environment.js +16 -0
- package/dist/mocks/app-forms.d.ts +2 -0
- package/dist/mocks/app-forms.js +22 -0
- package/dist/mocks/app-navigation.d.ts +5 -0
- package/dist/mocks/app-navigation.js +36 -0
- package/dist/mocks/app-stores.d.ts +14 -0
- package/dist/mocks/app-stores.js +26 -0
- package/dist/playground/index.d.ts +131 -0
- package/dist/playground/index.js +172 -0
- package/dist/playground/mount.d.ts +203 -0
- package/dist/playground/mount.js +235 -0
- package/dist/registry/BaseRegistry.d.ts +92 -0
- package/dist/registry/BaseRegistry.js +124 -0
- package/dist/registry/builtinFormats.d.ts +23 -0
- package/dist/registry/builtinFormats.js +70 -0
- package/dist/registry/builtinNodes.d.ts +77 -0
- package/dist/registry/builtinNodes.js +211 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/nodeComponentRegistry.d.ts +276 -0
- package/dist/registry/nodeComponentRegistry.js +262 -0
- package/dist/registry/plugin.d.ts +215 -0
- package/dist/registry/plugin.js +249 -0
- package/dist/registry/workflowFormatRegistry.d.ts +122 -0
- package/dist/registry/workflowFormatRegistry.js +96 -0
- package/dist/schema/index.d.ts +23 -0
- package/dist/schema/index.js +23 -0
- package/dist/schemas/v1/workflow.schema.json +1078 -0
- package/dist/services/agentSpecExecutionService.d.ts +106 -0
- package/dist/services/agentSpecExecutionService.js +334 -0
- package/dist/services/api.d.ts +115 -0
- package/dist/services/api.js +214 -0
- package/dist/services/apiVariableService.d.ts +114 -0
- package/dist/services/apiVariableService.js +338 -0
- package/dist/services/autoSaveService.d.ts +112 -0
- package/dist/services/autoSaveService.js +227 -0
- package/dist/services/categoriesApi.d.ts +14 -0
- package/dist/services/categoriesApi.js +49 -0
- package/dist/services/draftStorage.d.ts +171 -0
- package/dist/services/draftStorage.js +299 -0
- package/dist/services/dynamicSchemaService.d.ts +108 -0
- package/dist/services/dynamicSchemaService.js +444 -0
- package/dist/services/globalSave.d.ts +69 -0
- package/dist/services/globalSave.js +248 -0
- package/dist/services/historyService.d.ts +208 -0
- package/dist/services/historyService.js +321 -0
- package/dist/services/interruptService.d.ts +133 -0
- package/dist/services/interruptService.js +280 -0
- package/dist/services/nodeExecutionService.d.ts +63 -0
- package/dist/services/nodeExecutionService.js +266 -0
- package/dist/services/playgroundService.d.ts +130 -0
- package/dist/services/playgroundService.js +321 -0
- package/dist/services/portConfigApi.d.ts +14 -0
- package/dist/services/portConfigApi.js +54 -0
- package/dist/services/settingsService.d.ts +92 -0
- package/dist/services/settingsService.js +196 -0
- package/dist/services/toastService.d.ts +156 -0
- package/dist/services/toastService.js +265 -0
- package/dist/services/variableService.d.ts +141 -0
- package/dist/services/variableService.js +463 -0
- package/dist/services/workflowStorage.d.ts +37 -0
- package/dist/services/workflowStorage.js +116 -0
- package/dist/settings/index.d.ts +25 -0
- package/dist/settings/index.js +33 -0
- package/dist/stores/categoriesStore.svelte.d.ts +32 -0
- package/dist/stores/categoriesStore.svelte.js +77 -0
- package/dist/stores/editorStateMachine.svelte.d.ts +42 -0
- package/dist/stores/editorStateMachine.svelte.js +132 -0
- package/dist/stores/historyStore.svelte.d.ts +136 -0
- package/dist/stores/historyStore.svelte.js +207 -0
- package/dist/stores/interruptStore.svelte.d.ts +179 -0
- package/dist/stores/interruptStore.svelte.js +346 -0
- package/dist/stores/playgroundStore.svelte.d.ts +230 -0
- package/dist/stores/playgroundStore.svelte.js +515 -0
- package/dist/stores/portCoordinateStore.svelte.d.ts +66 -0
- package/dist/stores/portCoordinateStore.svelte.js +186 -0
- package/dist/stores/settingsStore.svelte.d.ts +158 -0
- package/dist/stores/settingsStore.svelte.js +544 -0
- package/dist/stores/workflowStore.svelte.d.ts +260 -0
- package/dist/stores/workflowStore.svelte.js +649 -0
- package/dist/stories/CanvasDecorator.svelte +49 -0
- package/dist/stories/CanvasDecorator.svelte.d.ts +8 -0
- package/dist/stories/NodeDecorator.svelte +73 -0
- package/dist/stories/NodeDecorator.svelte.d.ts +8 -0
- package/dist/stories/utils.d.ts +93 -0
- package/dist/stories/utils.js +122 -0
- package/dist/styles/base.css +1300 -0
- package/dist/styles/toast.css +35 -0
- package/dist/styles/tokens.css +475 -0
- package/dist/svelte-app.d.ts +150 -0
- package/dist/svelte-app.js +295 -0
- package/dist/types/agentspec.d.ts +318 -0
- package/dist/types/agentspec.js +48 -0
- package/dist/types/auth.d.ts +263 -0
- package/dist/types/auth.js +229 -0
- package/dist/types/config.d.ts +151 -0
- package/dist/types/config.js +7 -0
- package/dist/types/events.d.ts +190 -0
- package/dist/types/events.js +30 -0
- package/dist/types/index.d.ts +1234 -0
- package/dist/types/index.js +27 -0
- package/dist/types/interrupt.d.ts +390 -0
- package/dist/types/interrupt.js +145 -0
- package/dist/types/interruptState.d.ts +211 -0
- package/dist/types/interruptState.js +308 -0
- package/dist/types/playground.d.ts +351 -0
- package/dist/types/playground.js +95 -0
- package/dist/types/settings.d.ts +189 -0
- package/dist/types/settings.js +97 -0
- package/dist/types/uischema.d.ts +144 -0
- package/dist/types/uischema.js +51 -0
- package/dist/utils/colors.d.ts +288 -0
- package/dist/utils/colors.js +548 -0
- package/dist/utils/config.d.ts +37 -0
- package/dist/utils/config.js +226 -0
- package/dist/utils/connections.d.ts +125 -0
- package/dist/utils/connections.js +414 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.js +44 -0
- package/dist/utils/fetchWithAuth.d.ts +25 -0
- package/dist/utils/fetchWithAuth.js +34 -0
- package/dist/utils/handleIds.d.ts +35 -0
- package/dist/utils/handleIds.js +58 -0
- package/dist/utils/handlePositioning.d.ts +31 -0
- package/dist/utils/handlePositioning.js +35 -0
- package/dist/utils/icons.d.ts +106 -0
- package/dist/utils/icons.js +157 -0
- package/dist/utils/logger.d.ts +47 -0
- package/dist/utils/logger.js +72 -0
- package/dist/utils/nodeStatus.d.ts +53 -0
- package/dist/utils/nodeStatus.js +183 -0
- package/dist/utils/nodeTypes.d.ts +117 -0
- package/dist/utils/nodeTypes.js +244 -0
- package/dist/utils/nodeWrapper.d.ts +39 -0
- package/dist/utils/nodeWrapper.js +62 -0
- package/dist/utils/performanceUtils.d.ts +30 -0
- package/dist/utils/performanceUtils.js +108 -0
- package/dist/utils/sanitize.d.ts +19 -0
- package/dist/utils/sanitize.js +31 -0
- package/dist/utils/uischema.d.ts +52 -0
- package/dist/utils/uischema.js +88 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.js +39 -0
- package/package.json +292 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AutocompleteConfig } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Props interface for FormAutocomplete component
|
|
4
|
+
*/
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Field identifier */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Current selected value (string for single, string[] for multiple) */
|
|
9
|
+
value: string | string[];
|
|
10
|
+
/** Autocomplete configuration */
|
|
11
|
+
autocomplete: AutocompleteConfig;
|
|
12
|
+
/** Whether the field is required */
|
|
13
|
+
required?: boolean;
|
|
14
|
+
/** Placeholder text */
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/** Whether the field is disabled */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** ARIA description ID */
|
|
19
|
+
ariaDescribedBy?: string;
|
|
20
|
+
/** Callback when value changes */
|
|
21
|
+
onChange: (value: string | string[]) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const FormAutocomplete: import("svelte").Component<Props, {}, "">;
|
|
24
|
+
type FormAutocomplete = ReturnType<typeof FormAutocomplete>;
|
|
25
|
+
export default FormAutocomplete;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import FormCheckboxGroup from './FormCheckboxGroup.svelte';
|
|
4
|
+
import { fn } from 'storybook/test';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: 'Form/FormCheckboxGroup',
|
|
8
|
+
component: FormCheckboxGroup,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
disabled: { control: 'boolean' }
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
id: 'demo-checkbox-group',
|
|
15
|
+
options: ['Email', 'SMS', 'Push Notification', 'Webhook'],
|
|
16
|
+
value: [],
|
|
17
|
+
onChange: fn()
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<Story name="No Selection" args={{ value: [] }} />
|
|
23
|
+
|
|
24
|
+
<Story name="Pre-selected" args={{ value: ['Email', 'Push Notification'] }} />
|
|
25
|
+
|
|
26
|
+
<Story name="All Selected" args={{ value: ['Email', 'SMS', 'Push Notification', 'Webhook'] }} />
|
|
27
|
+
|
|
28
|
+
<Story name="Disabled" args={{ value: ['Email'], disabled: true }} />
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default FormCheckboxGroup;
|
|
2
|
+
type FormCheckboxGroup = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const FormCheckboxGroup: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
import FormCheckboxGroup from './FormCheckboxGroup.svelte';
|
|
15
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
16
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
17
|
+
$$bindings?: Bindings;
|
|
18
|
+
} & Exports;
|
|
19
|
+
(internal: unknown, props: {
|
|
20
|
+
$$events?: Events;
|
|
21
|
+
$$slots?: Slots;
|
|
22
|
+
}): Exports & {
|
|
23
|
+
$set?: any;
|
|
24
|
+
$on?: any;
|
|
25
|
+
};
|
|
26
|
+
z_$$bindings?: Bindings;
|
|
27
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
FormCheckboxGroup Component
|
|
3
|
+
Checkbox group for multiple value selection (enum with multiple=true)
|
|
4
|
+
|
|
5
|
+
Features:
|
|
6
|
+
- Custom styled checkboxes with check icon
|
|
7
|
+
- Animated checkbox state transitions
|
|
8
|
+
- Focus-visible states for keyboard navigation
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import Icon from '@iconify/svelte';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
/** Field identifier (used for ARIA) */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Current selected values */
|
|
18
|
+
value: string[];
|
|
19
|
+
/** Available options */
|
|
20
|
+
options: string[];
|
|
21
|
+
/** Whether the field is disabled (read-only) */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** ARIA description ID */
|
|
24
|
+
ariaDescribedBy?: string;
|
|
25
|
+
/** Callback when value changes */
|
|
26
|
+
onChange: (value: string[]) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
id,
|
|
31
|
+
value = [],
|
|
32
|
+
options = [],
|
|
33
|
+
disabled = false,
|
|
34
|
+
ariaDescribedBy,
|
|
35
|
+
onChange
|
|
36
|
+
}: Props = $props();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Handle checkbox toggle
|
|
40
|
+
*/
|
|
41
|
+
function handleCheckboxChange(option: string, checked: boolean): void {
|
|
42
|
+
const currentValues = Array.isArray(value) ? [...value] : [];
|
|
43
|
+
|
|
44
|
+
if (checked) {
|
|
45
|
+
if (!currentValues.includes(option)) {
|
|
46
|
+
onChange([...currentValues, option]);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
onChange(currentValues.filter((v) => v !== option));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div
|
|
55
|
+
class="form-checkbox-group"
|
|
56
|
+
role="group"
|
|
57
|
+
aria-labelledby="{id}-label"
|
|
58
|
+
aria-describedby={ariaDescribedBy}
|
|
59
|
+
>
|
|
60
|
+
{#each options as option (option)}
|
|
61
|
+
{@const isChecked = Array.isArray(value) && value.includes(option)}
|
|
62
|
+
<label class="form-checkbox-item">
|
|
63
|
+
<input
|
|
64
|
+
type="checkbox"
|
|
65
|
+
class="form-checkbox__input"
|
|
66
|
+
value={option}
|
|
67
|
+
checked={isChecked}
|
|
68
|
+
{disabled}
|
|
69
|
+
onchange={(e) => handleCheckboxChange(option, e.currentTarget.checked)}
|
|
70
|
+
/>
|
|
71
|
+
<span class="form-checkbox__custom" aria-hidden="true">
|
|
72
|
+
<Icon icon="heroicons:check" />
|
|
73
|
+
</span>
|
|
74
|
+
<span class="form-checkbox__label">
|
|
75
|
+
{option}
|
|
76
|
+
</span>
|
|
77
|
+
</label>
|
|
78
|
+
{/each}
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<style>
|
|
82
|
+
.form-checkbox-group {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
gap: 0.625rem;
|
|
86
|
+
padding: 0.75rem;
|
|
87
|
+
background-color: var(--fd-muted);
|
|
88
|
+
border: 1px solid var(--fd-border);
|
|
89
|
+
border-radius: var(--fd-radius-lg);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.form-checkbox-item {
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 0.625rem;
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
padding: 0.375rem;
|
|
98
|
+
margin: -0.375rem;
|
|
99
|
+
border-radius: var(--fd-radius-md);
|
|
100
|
+
transition: background-color var(--fd-transition-fast);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.form-checkbox-item:hover {
|
|
104
|
+
background-color: var(--fd-subtle);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.form-checkbox__input {
|
|
108
|
+
position: absolute;
|
|
109
|
+
opacity: 0;
|
|
110
|
+
width: 0;
|
|
111
|
+
height: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.form-checkbox__custom {
|
|
115
|
+
width: 1.125rem;
|
|
116
|
+
height: 1.125rem;
|
|
117
|
+
border: 1.5px solid var(--fd-border-strong);
|
|
118
|
+
border-radius: var(--fd-radius-sm);
|
|
119
|
+
background-color: var(--fd-background);
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
transition: all var(--fd-transition-fast);
|
|
124
|
+
flex-shrink: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.form-checkbox__custom :global(svg) {
|
|
128
|
+
width: 0.75rem;
|
|
129
|
+
height: 0.75rem;
|
|
130
|
+
color: var(--fd-primary-foreground);
|
|
131
|
+
opacity: 0;
|
|
132
|
+
transform: scale(0.5);
|
|
133
|
+
transition: all var(--fd-transition-fast);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.form-checkbox__input:checked + .form-checkbox__custom {
|
|
137
|
+
background-color: var(--fd-primary);
|
|
138
|
+
border-color: var(--fd-primary);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.form-checkbox__input:checked + .form-checkbox__custom :global(svg) {
|
|
142
|
+
opacity: 1;
|
|
143
|
+
transform: scale(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.form-checkbox__input:focus-visible + .form-checkbox__custom {
|
|
147
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.form-checkbox__label {
|
|
151
|
+
font-size: var(--fd-text-sm);
|
|
152
|
+
color: var(--fd-foreground);
|
|
153
|
+
line-height: 1.4;
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Field identifier (used for ARIA) */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Current selected values */
|
|
5
|
+
value: string[];
|
|
6
|
+
/** Available options */
|
|
7
|
+
options: string[];
|
|
8
|
+
/** Whether the field is disabled (read-only) */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** ARIA description ID */
|
|
11
|
+
ariaDescribedBy?: string;
|
|
12
|
+
/** Callback when value changes */
|
|
13
|
+
onChange: (value: string[]) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const FormCheckboxGroup: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type FormCheckboxGroup = ReturnType<typeof FormCheckboxGroup>;
|
|
17
|
+
export default FormCheckboxGroup;
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
FormCodeEditor Component
|
|
3
|
+
CodeMirror-based code editor for JSON and other structured data
|
|
4
|
+
|
|
5
|
+
Features:
|
|
6
|
+
- JSON syntax highlighting with CodeMirror 6
|
|
7
|
+
- Real-time JSON validation with error display
|
|
8
|
+
- Auto-formatting on blur (optional)
|
|
9
|
+
- Dark/light theme support
|
|
10
|
+
- Consistent styling with other form components
|
|
11
|
+
- Proper ARIA attributes for accessibility
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
Use with schema format: "json" or format: "code" to render this editor
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import { onMount, onDestroy } from 'svelte';
|
|
19
|
+
import {
|
|
20
|
+
EditorView,
|
|
21
|
+
lineNumbers,
|
|
22
|
+
highlightActiveLineGutter,
|
|
23
|
+
drawSelection
|
|
24
|
+
} from '@codemirror/view';
|
|
25
|
+
import { EditorState } from '@codemirror/state';
|
|
26
|
+
import { history, historyKeymap } from '@codemirror/commands';
|
|
27
|
+
import { highlightSpecialChars, highlightActiveLine } from '@codemirror/view';
|
|
28
|
+
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
|
|
29
|
+
import { keymap } from '@codemirror/view';
|
|
30
|
+
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
|
31
|
+
import { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
32
|
+
import { oneDark } from '@codemirror/theme-one-dark';
|
|
33
|
+
import { linter } from '@codemirror/lint';
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
/** Field identifier */
|
|
37
|
+
id: string;
|
|
38
|
+
/** Current value - can be string (raw JSON) or object */
|
|
39
|
+
value: unknown;
|
|
40
|
+
/** Placeholder text shown when empty */
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
/** Whether the field is required */
|
|
43
|
+
required?: boolean;
|
|
44
|
+
/** Whether to use dark theme */
|
|
45
|
+
darkTheme?: boolean;
|
|
46
|
+
/** Editor height in pixels or CSS value */
|
|
47
|
+
height?: string;
|
|
48
|
+
/** Whether to auto-format JSON on blur */
|
|
49
|
+
autoFormat?: boolean;
|
|
50
|
+
/** Whether the field is disabled (read-only) */
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/** ARIA description ID */
|
|
53
|
+
ariaDescribedBy?: string;
|
|
54
|
+
/** Callback when value changes */
|
|
55
|
+
onChange: (value: unknown) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let {
|
|
59
|
+
id,
|
|
60
|
+
value = '',
|
|
61
|
+
placeholder = '{}',
|
|
62
|
+
required = false,
|
|
63
|
+
darkTheme = false,
|
|
64
|
+
height = '200px',
|
|
65
|
+
autoFormat = true,
|
|
66
|
+
disabled = false,
|
|
67
|
+
ariaDescribedBy,
|
|
68
|
+
onChange
|
|
69
|
+
}: Props = $props();
|
|
70
|
+
|
|
71
|
+
/** Reference to the container element */
|
|
72
|
+
let containerRef: HTMLDivElement | undefined = $state(undefined);
|
|
73
|
+
|
|
74
|
+
/** CodeMirror editor instance */
|
|
75
|
+
let editorView: EditorView | undefined = $state(undefined);
|
|
76
|
+
|
|
77
|
+
/** Current validation error message */
|
|
78
|
+
let validationError: string | undefined = $state(undefined);
|
|
79
|
+
|
|
80
|
+
/** Flag to prevent update loops */
|
|
81
|
+
let isInternalUpdate = false;
|
|
82
|
+
|
|
83
|
+
/** Flag to skip $effect when change originated from the editor */
|
|
84
|
+
let isEditorUpdate = false;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Convert value to JSON string for editor display
|
|
88
|
+
*/
|
|
89
|
+
function valueToString(val: unknown): string {
|
|
90
|
+
if (val === undefined || val === null) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
if (typeof val === 'string') {
|
|
94
|
+
// Check if it's already a valid JSON string
|
|
95
|
+
try {
|
|
96
|
+
JSON.parse(val);
|
|
97
|
+
return val;
|
|
98
|
+
} catch {
|
|
99
|
+
// Not valid JSON, return as-is
|
|
100
|
+
return val;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Convert object to formatted JSON string
|
|
104
|
+
return JSON.stringify(val, null, 2);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Validate JSON and return parsed value or undefined if invalid
|
|
109
|
+
*/
|
|
110
|
+
function validateAndParse(content: string): { valid: boolean; value?: unknown; error?: string } {
|
|
111
|
+
if (!content.trim()) {
|
|
112
|
+
return { valid: true, value: undefined };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const parsed = JSON.parse(content);
|
|
117
|
+
return { valid: true, value: parsed };
|
|
118
|
+
} catch (e) {
|
|
119
|
+
const error = e instanceof Error ? e.message : 'Invalid JSON';
|
|
120
|
+
return { valid: false, error };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Handle editor content changes
|
|
126
|
+
*/
|
|
127
|
+
function handleUpdate(update: { docChanged: boolean; state: EditorState }): void {
|
|
128
|
+
if (!update.docChanged || isInternalUpdate) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const content = update.state.doc.toString();
|
|
133
|
+
const result = validateAndParse(content);
|
|
134
|
+
|
|
135
|
+
isEditorUpdate = true;
|
|
136
|
+
if (result.valid) {
|
|
137
|
+
validationError = undefined;
|
|
138
|
+
// Emit the parsed value (object) not the string
|
|
139
|
+
onChange(result.value);
|
|
140
|
+
} else {
|
|
141
|
+
validationError = result.error;
|
|
142
|
+
// Still emit the raw string so user can continue editing
|
|
143
|
+
onChange(content);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Format JSON content (used on blur if autoFormat is enabled)
|
|
149
|
+
*/
|
|
150
|
+
function formatContent(): void {
|
|
151
|
+
if (!editorView || !autoFormat) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const content = editorView.state.doc.toString();
|
|
156
|
+
const result = validateAndParse(content);
|
|
157
|
+
|
|
158
|
+
if (result.valid && result.value !== undefined) {
|
|
159
|
+
const formatted = JSON.stringify(result.value, null, 2);
|
|
160
|
+
if (formatted !== content) {
|
|
161
|
+
isInternalUpdate = true;
|
|
162
|
+
editorView.dispatch({
|
|
163
|
+
changes: {
|
|
164
|
+
from: 0,
|
|
165
|
+
to: editorView.state.doc.length,
|
|
166
|
+
insert: formatted
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
isInternalUpdate = false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Create editor extensions array
|
|
176
|
+
* Uses minimal setup for better performance (no auto-closing brackets, no autocompletion)
|
|
177
|
+
* When disabled is true, adds readOnly/editable so the editor cannot be modified
|
|
178
|
+
*/
|
|
179
|
+
function createExtensions() {
|
|
180
|
+
const extensions = [
|
|
181
|
+
// Essential visual features
|
|
182
|
+
lineNumbers(),
|
|
183
|
+
highlightActiveLineGutter(),
|
|
184
|
+
highlightSpecialChars(),
|
|
185
|
+
highlightActiveLine(),
|
|
186
|
+
drawSelection(),
|
|
187
|
+
|
|
188
|
+
// Editing features (skip when read-only)
|
|
189
|
+
...(disabled
|
|
190
|
+
? []
|
|
191
|
+
: [history(), keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab])]),
|
|
192
|
+
|
|
193
|
+
// Read-only: prevent document changes and mark content as non-editable
|
|
194
|
+
...(disabled ? [EditorState.readOnly.of(true), EditorView.editable.of(false)] : []),
|
|
195
|
+
|
|
196
|
+
// Syntax highlighting - use default for light mode, oneDark handles dark mode
|
|
197
|
+
...(darkTheme ? [oneDark] : [syntaxHighlighting(defaultHighlightStyle, { fallback: true })]),
|
|
198
|
+
|
|
199
|
+
// JSON-specific features
|
|
200
|
+
json(),
|
|
201
|
+
linter(jsonParseLinter(), { delay: 1000 }),
|
|
202
|
+
|
|
203
|
+
// Update listener (only fires on user edit when not disabled)
|
|
204
|
+
EditorView.updateListener.of(handleUpdate),
|
|
205
|
+
|
|
206
|
+
// Custom theme
|
|
207
|
+
EditorView.theme({
|
|
208
|
+
'&': {
|
|
209
|
+
height: height,
|
|
210
|
+
fontSize: '0.8125rem',
|
|
211
|
+
fontFamily: "'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace"
|
|
212
|
+
},
|
|
213
|
+
'.cm-scroller': {
|
|
214
|
+
overflow: 'auto'
|
|
215
|
+
},
|
|
216
|
+
'.cm-content': {
|
|
217
|
+
minHeight: '100px'
|
|
218
|
+
},
|
|
219
|
+
'&.cm-focused': {
|
|
220
|
+
outline: 'none'
|
|
221
|
+
}
|
|
222
|
+
}),
|
|
223
|
+
EditorView.lineWrapping
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
return extensions;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Initialize CodeMirror editor on mount
|
|
231
|
+
*/
|
|
232
|
+
onMount(() => {
|
|
233
|
+
if (!containerRef) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const initialContent = valueToString(value);
|
|
238
|
+
|
|
239
|
+
editorView = new EditorView({
|
|
240
|
+
state: EditorState.create({
|
|
241
|
+
doc: initialContent,
|
|
242
|
+
extensions: createExtensions()
|
|
243
|
+
}),
|
|
244
|
+
parent: containerRef
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// Validate initial content
|
|
248
|
+
if (initialContent) {
|
|
249
|
+
const result = validateAndParse(initialContent);
|
|
250
|
+
if (!result.valid) {
|
|
251
|
+
validationError = result.error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Clean up editor on destroy
|
|
258
|
+
*/
|
|
259
|
+
onDestroy(() => {
|
|
260
|
+
if (editorView) {
|
|
261
|
+
editorView.destroy();
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Update editor content when value prop changes externally
|
|
267
|
+
*/
|
|
268
|
+
$effect(() => {
|
|
269
|
+
if (!editorView) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const newContent = valueToString(value);
|
|
274
|
+
|
|
275
|
+
// Skip if the change originated from the editor itself
|
|
276
|
+
if (isEditorUpdate) {
|
|
277
|
+
isEditorUpdate = false;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const currentContent = editorView.state.doc.toString();
|
|
282
|
+
|
|
283
|
+
// Only update if content actually changed and wasn't from internal edit
|
|
284
|
+
if (newContent !== currentContent && !isInternalUpdate) {
|
|
285
|
+
isInternalUpdate = true;
|
|
286
|
+
editorView.dispatch({
|
|
287
|
+
changes: {
|
|
288
|
+
from: 0,
|
|
289
|
+
to: editorView.state.doc.length,
|
|
290
|
+
insert: newContent
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
isInternalUpdate = false;
|
|
294
|
+
|
|
295
|
+
// Validate new content
|
|
296
|
+
const result = validateAndParse(newContent);
|
|
297
|
+
validationError = result.valid ? undefined : result.error;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
</script>
|
|
301
|
+
|
|
302
|
+
<div class="form-code-editor" class:form-code-editor--error={validationError}>
|
|
303
|
+
<!-- Hidden input for form submission compatibility -->
|
|
304
|
+
<input
|
|
305
|
+
type="hidden"
|
|
306
|
+
{id}
|
|
307
|
+
name={id}
|
|
308
|
+
value={typeof value === 'string' ? value : JSON.stringify(value)}
|
|
309
|
+
aria-describedby={ariaDescribedBy}
|
|
310
|
+
aria-required={required}
|
|
311
|
+
/>
|
|
312
|
+
|
|
313
|
+
<!-- CodeMirror container -->
|
|
314
|
+
<div
|
|
315
|
+
bind:this={containerRef}
|
|
316
|
+
class="form-code-editor__container"
|
|
317
|
+
class:form-code-editor__container--dark={darkTheme}
|
|
318
|
+
role="textbox"
|
|
319
|
+
aria-multiline="true"
|
|
320
|
+
aria-label="JSON editor"
|
|
321
|
+
onblur={formatContent}
|
|
322
|
+
></div>
|
|
323
|
+
|
|
324
|
+
<!-- Validation error display -->
|
|
325
|
+
{#if validationError}
|
|
326
|
+
<div class="form-code-editor__error" role="alert">
|
|
327
|
+
<svg
|
|
328
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
329
|
+
viewBox="0 0 20 20"
|
|
330
|
+
fill="currentColor"
|
|
331
|
+
class="form-code-editor__error-icon"
|
|
332
|
+
>
|
|
333
|
+
<path
|
|
334
|
+
fill-rule="evenodd"
|
|
335
|
+
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z"
|
|
336
|
+
clip-rule="evenodd"
|
|
337
|
+
/>
|
|
338
|
+
</svg>
|
|
339
|
+
<span>{validationError}</span>
|
|
340
|
+
</div>
|
|
341
|
+
{/if}
|
|
342
|
+
|
|
343
|
+
<!-- Placeholder hint when empty -->
|
|
344
|
+
{#if !value && placeholder}
|
|
345
|
+
<div class="form-code-editor__placeholder">
|
|
346
|
+
Start typing or paste JSON. Example: <code>{placeholder}</code>
|
|
347
|
+
</div>
|
|
348
|
+
{/if}
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
<style>
|
|
352
|
+
.form-code-editor {
|
|
353
|
+
position: relative;
|
|
354
|
+
width: 100%;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.form-code-editor__container {
|
|
358
|
+
border: 1px solid var(--fd-border);
|
|
359
|
+
border-radius: var(--fd-radius-lg);
|
|
360
|
+
overflow: hidden;
|
|
361
|
+
background-color: var(--fd-muted);
|
|
362
|
+
transition: all var(--fd-transition-normal);
|
|
363
|
+
box-shadow: var(--fd-shadow-sm);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.form-code-editor__container:hover {
|
|
367
|
+
border-color: var(--fd-border-strong);
|
|
368
|
+
background-color: var(--fd-background);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.form-code-editor__container:focus-within {
|
|
372
|
+
border-color: var(--fd-primary);
|
|
373
|
+
background-color: var(--fd-background);
|
|
374
|
+
box-shadow:
|
|
375
|
+
0 0 0 3px rgba(59, 130, 246, 0.12),
|
|
376
|
+
var(--fd-shadow-sm);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.form-code-editor--error .form-code-editor__container {
|
|
380
|
+
border-color: var(--fd-error);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.form-code-editor--error .form-code-editor__container:focus-within {
|
|
384
|
+
border-color: var(--fd-error);
|
|
385
|
+
box-shadow:
|
|
386
|
+
0 0 0 3px rgba(239, 68, 68, 0.12),
|
|
387
|
+
var(--fd-shadow-sm);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* Dark theme overrides */
|
|
391
|
+
.form-code-editor__container--dark {
|
|
392
|
+
background-color: #282c34;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.form-code-editor__container--dark:hover,
|
|
396
|
+
.form-code-editor__container--dark:focus-within {
|
|
397
|
+
background-color: #282c34;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/* CodeMirror styling overrides */
|
|
401
|
+
.form-code-editor__container :global(.cm-editor) {
|
|
402
|
+
border-radius: var(--fd-radius-lg);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.form-code-editor__container :global(.cm-gutters) {
|
|
406
|
+
background-color: var(--fd-subtle);
|
|
407
|
+
border-right: 1px solid var(--fd-border);
|
|
408
|
+
border-radius: var(--fd-radius-lg) 0 0 var(--fd-radius-lg);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.form-code-editor__container--dark :global(.cm-gutters) {
|
|
412
|
+
background-color: #21252b;
|
|
413
|
+
border-right-color: #3e4451;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/* Error message */
|
|
417
|
+
.form-code-editor__error {
|
|
418
|
+
display: flex;
|
|
419
|
+
align-items: flex-start;
|
|
420
|
+
gap: 0.375rem;
|
|
421
|
+
margin-top: 0.5rem;
|
|
422
|
+
padding: 0.5rem 0.75rem;
|
|
423
|
+
background-color: var(--fd-error-muted);
|
|
424
|
+
border: 1px solid var(--fd-error);
|
|
425
|
+
border-radius: var(--fd-radius-md);
|
|
426
|
+
color: var(--fd-error-hover);
|
|
427
|
+
font-size: var(--fd-text-xs);
|
|
428
|
+
line-height: 1.4;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.form-code-editor__error-icon {
|
|
432
|
+
width: 1rem;
|
|
433
|
+
height: 1rem;
|
|
434
|
+
flex-shrink: 0;
|
|
435
|
+
margin-top: 0.0625rem;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.form-code-editor__error span {
|
|
439
|
+
word-break: break-word;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* Placeholder hint */
|
|
443
|
+
.form-code-editor__placeholder {
|
|
444
|
+
margin-top: 0.5rem;
|
|
445
|
+
font-size: var(--fd-text-xs);
|
|
446
|
+
color: var(--fd-muted-foreground);
|
|
447
|
+
font-style: italic;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.form-code-editor__placeholder code {
|
|
451
|
+
padding: 0.125rem 0.375rem;
|
|
452
|
+
background-color: var(--fd-subtle);
|
|
453
|
+
border-radius: var(--fd-radius-sm);
|
|
454
|
+
font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace;
|
|
455
|
+
font-size: 0.6875rem;
|
|
456
|
+
font-style: normal;
|
|
457
|
+
}
|
|
458
|
+
</style>
|