@tpitre/story-ui 2.6.1 → 2.7.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/README.md +36 -37
- package/dist/cli/deploy.d.ts +4 -3
- package/dist/cli/deploy.d.ts.map +1 -1
- package/dist/cli/deploy.js +542 -46
- package/dist/cli/index.js +17 -14
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +4 -110
- package/dist/cli/setup.js.map +1 -0
- package/dist/cloudflare-edge/src/mcp-session.js +462 -0
- package/dist/cloudflare-edge/src/types.js +4 -0
- package/dist/cloudflare-edge/src/worker.js +106 -0
- package/dist/cloudflare-pages/vite.config.js +14 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/index.js.map +1 -0
- package/dist/mcp-server/mcp-stdio-server.js.map +1 -0
- package/dist/mcp-server/routes/claude.js.map +1 -0
- package/dist/mcp-server/routes/components.js.map +1 -0
- package/dist/mcp-server/routes/generateStory.js.map +1 -0
- package/dist/mcp-server/routes/hybridStories.js.map +1 -0
- package/dist/mcp-server/routes/memoryStories.js.map +1 -0
- package/dist/mcp-server/routes/storySync.js.map +1 -0
- package/dist/mcp-server/routes/updateStory.js +246 -0
- package/dist/mcp-server/sessionManager.js.map +1 -0
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts +6 -0
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +1 -0
- package/dist/playground/components/AIAssistant/AIAssistant.js +109 -0
- package/dist/playground/components/AIAssistant/AIAssistant.js.map +1 -0
- package/dist/playground/components/AIAssistant/AIAssistant.module.css +166 -0
- package/dist/playground/components/Canvas/Canvas.d.ts +9 -0
- package/dist/playground/components/Canvas/Canvas.d.ts.map +1 -0
- package/dist/playground/components/Canvas/Canvas.js +58 -0
- package/dist/playground/components/Canvas/Canvas.js.map +1 -0
- package/dist/playground/components/Canvas/Canvas.module.css +189 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +9 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +1 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.js +158 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.js.map +1 -0
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts +15 -0
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +1 -0
- package/dist/playground/components/Canvas/ComponentRenderer.js +177 -0
- package/dist/playground/components/Canvas/ComponentRenderer.js.map +1 -0
- package/dist/playground/components/Canvas/DraggableComponent.d.ts +15 -0
- package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +1 -0
- package/dist/playground/components/Canvas/DraggableComponent.js +49 -0
- package/dist/playground/components/Canvas/DraggableComponent.js.map +1 -0
- package/dist/playground/components/Canvas/index.d.ts +9 -0
- package/dist/playground/components/Canvas/index.d.ts.map +1 -0
- package/dist/playground/components/Canvas/index.js +5 -0
- package/dist/playground/components/Canvas/index.js.map +1 -0
- package/dist/playground/components/CodeView/CodeView.d.ts +12 -0
- package/dist/playground/components/CodeView/CodeView.d.ts.map +1 -0
- package/dist/playground/components/CodeView/CodeView.js +77 -0
- package/dist/playground/components/CodeView/CodeView.js.map +1 -0
- package/dist/playground/components/CodeView/CodeView.module.css +178 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +17 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +1 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.js +138 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +1 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +217 -0
- package/dist/playground/components/ComponentPalette/index.d.ts +3 -0
- package/dist/playground/components/ComponentPalette/index.d.ts.map +1 -0
- package/dist/playground/components/ComponentPalette/index.js +2 -0
- package/dist/playground/components/ComponentPalette/index.js.map +1 -0
- package/dist/playground/components/DropZone/DropZone.d.ts +17 -0
- package/dist/playground/components/DropZone/DropZone.d.ts.map +1 -0
- package/dist/playground/components/DropZone/DropZone.js +73 -0
- package/dist/playground/components/DropZone/DropZone.js.map +1 -0
- package/dist/playground/components/DropZone/DropZone.module.css +86 -0
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts +10 -0
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +1 -0
- package/dist/playground/components/ExportDialog/ExportDialog.js +57 -0
- package/dist/playground/components/ExportDialog/ExportDialog.js.map +1 -0
- package/dist/playground/components/ExportDialog/ExportDialog.module.css +328 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +134 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +1 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +254 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +1 -0
- package/dist/playground/components/LayoutHelpers/index.d.ts +3 -0
- package/dist/playground/components/LayoutHelpers/index.d.ts.map +1 -0
- package/dist/playground/components/LayoutHelpers/index.js +2 -0
- package/dist/playground/components/LayoutHelpers/index.js.map +1 -0
- package/dist/playground/components/Playground/Playground.d.ts +10 -0
- package/dist/playground/components/Playground/Playground.d.ts.map +1 -0
- package/dist/playground/components/Playground/Playground.js +128 -0
- package/dist/playground/components/Playground/Playground.js.map +1 -0
- package/dist/playground/components/Playground/Playground.module.css +308 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +10 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +1 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +150 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +1 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +155 -0
- package/dist/playground/components/PropertiesPanel/index.d.ts +3 -0
- package/dist/playground/components/PropertiesPanel/index.d.ts.map +1 -0
- package/dist/playground/components/PropertiesPanel/index.js +2 -0
- package/dist/playground/components/PropertiesPanel/index.js.map +1 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +12 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.js +14 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +12 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.js +62 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts +12 -0
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/IconEditor.js +123 -0
- package/dist/playground/components/PropertyEditors/IconEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +15 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.js +46 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +432 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +19 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.js +17 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +19 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.js +162 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +214 -0
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts +14 -0
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/TextEditor.js +38 -0
- package/dist/playground/components/PropertyEditors/TextEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +23 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.js +50 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/index.d.ts +20 -0
- package/dist/playground/components/PropertyEditors/index.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/index.js +12 -0
- package/dist/playground/components/PropertyEditors/index.js.map +1 -0
- package/dist/playground/components/TreeView/TreeView.d.ts +10 -0
- package/dist/playground/components/TreeView/TreeView.d.ts.map +1 -0
- package/dist/playground/components/TreeView/TreeView.js +146 -0
- package/dist/playground/components/TreeView/TreeView.js.map +1 -0
- package/dist/playground/components/TreeView/TreeView.module.css +214 -0
- package/dist/playground/components/TreeView/index.d.ts +3 -0
- package/dist/playground/components/TreeView/index.d.ts.map +1 -0
- package/dist/playground/components/TreeView/index.js +2 -0
- package/dist/playground/components/TreeView/index.js.map +1 -0
- package/dist/playground/config/propertyDefinitions.d.ts +73 -0
- package/dist/playground/config/propertyDefinitions.d.ts.map +1 -0
- package/dist/playground/config/propertyDefinitions.js +809 -0
- package/dist/playground/config/propertyDefinitions.js.map +1 -0
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts +38 -0
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/playground/hooks/useKeyboardShortcuts.js +191 -0
- package/dist/playground/hooks/useKeyboardShortcuts.js.map +1 -0
- package/dist/playground/index.d.ts +21 -0
- package/dist/playground/index.d.ts.map +1 -0
- package/dist/playground/index.js +23 -0
- package/dist/playground/index.js.map +1 -0
- package/dist/playground/services/CodeGenerator.d.ts +73 -0
- package/dist/playground/services/CodeGenerator.d.ts.map +1 -0
- package/dist/playground/services/CodeGenerator.js +359 -0
- package/dist/playground/services/CodeGenerator.js.map +1 -0
- package/dist/playground/services/DragDropManager.d.ts +95 -0
- package/dist/playground/services/DragDropManager.d.ts.map +1 -0
- package/dist/playground/services/DragDropManager.js +408 -0
- package/dist/playground/services/DragDropManager.js.map +1 -0
- package/dist/playground/services/StoryParser.d.ts +73 -0
- package/dist/playground/services/StoryParser.d.ts.map +1 -0
- package/dist/playground/services/StoryParser.js +419 -0
- package/dist/playground/services/StoryParser.js.map +1 -0
- package/dist/playground/store/playgroundStore.d.ts +86 -0
- package/dist/playground/store/playgroundStore.d.ts.map +1 -0
- package/dist/playground/store/playgroundStore.js +337 -0
- package/dist/playground/store/playgroundStore.js.map +1 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +13 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.js +227 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +1 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +13 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.js +334 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.js.map +1 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +14 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.js +512 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.js.map +1 -0
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts +13 -0
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundProperties.stories.js +342 -0
- package/dist/playground/stories/PlaygroundProperties.stories.js.map +1 -0
- package/dist/playground/types/index.d.ts +251 -0
- package/dist/playground/types/index.d.ts.map +1 -0
- package/dist/playground/types/index.js +5 -0
- package/dist/playground/types/index.js.map +1 -0
- package/dist/scripts/verify-framework-adapters.js +105 -0
- package/dist/story-generator/componentBlacklist.js.map +1 -0
- package/dist/story-generator/componentDiscovery.js.map +1 -0
- package/dist/story-generator/configLoader.js.map +1 -0
- package/dist/story-generator/considerationsLoader.js.map +1 -0
- package/dist/story-generator/documentation-sources.js.map +1 -0
- package/dist/story-generator/documentationLoader.js.map +1 -0
- package/dist/story-generator/dynamicPackageDiscovery.js.map +1 -0
- package/dist/story-generator/enhancedComponentDiscovery.d.ts.map +1 -1
- package/dist/story-generator/enhancedComponentDiscovery.js +4 -6
- package/dist/story-generator/enhancedComponentDiscovery.js.map +1 -0
- package/dist/story-generator/generateStory.js.map +1 -0
- package/dist/story-generator/gitignoreManager.js.map +1 -0
- package/dist/story-generator/inMemoryStoryService.js.map +1 -0
- package/dist/story-generator/llm-providers/settings-manager.js +4 -4
- package/dist/story-generator/logger.js.map +1 -0
- package/dist/story-generator/postProcessStory.js.map +1 -0
- package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -1
- package/dist/story-generator/productionGitignoreManager.js +6 -0
- package/dist/story-generator/productionGitignoreManager.js.map +1 -0
- package/dist/story-generator/promptGenerator.js.map +1 -0
- package/dist/story-generator/providerPresets.d.ts +54 -0
- package/dist/story-generator/providerPresets.d.ts.map +1 -0
- package/dist/story-generator/providerPresets.js +214 -0
- package/dist/story-generator/storyHistory.js.map +1 -0
- package/dist/story-generator/storySync.js.map +1 -0
- package/dist/story-generator/storyTracker.js.map +1 -0
- package/dist/story-generator/storyValidator.js.map +1 -0
- package/dist/story-generator/test_validation.d.ts +2 -0
- package/dist/story-generator/test_validation.d.ts.map +1 -0
- package/dist/story-generator/test_validation.js +51 -0
- package/dist/story-generator/universalDesignSystemAdapter.js.map +1 -0
- package/dist/story-generator/urlRedirectService.js.map +1 -0
- package/dist/story-generator/validateStory.js.map +1 -0
- package/dist/story-ui.config.js.map +1 -0
- package/dist/story-ui.config.loader.d.ts +36 -0
- package/dist/story-ui.config.loader.d.ts.map +1 -0
- package/dist/story-ui.config.loader.js +205 -0
- package/dist/story-ui.config.loader.js.map +1 -0
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +807 -0
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +37 -0
- package/dist/temp/package/templates/StoryUI/index.js +2 -0
- package/dist/templates/StoryUI/StoryUIPanel.js.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +1 -0
- package/dist/templates/StoryUI/index.js.map +1 -0
- package/dist/templates/StoryUI/manager.d.ts +14 -0
- package/dist/templates/StoryUI/manager.d.ts.map +1 -0
- package/dist/templates/production-app/src/App.d.ts +10 -0
- package/dist/templates/production-app/src/App.d.ts.map +1 -0
- package/dist/templates/production-app/src/App.js +653 -0
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +24 -0
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +1 -0
- package/dist/templates/production-app/src/LivePreviewRenderer.js +199 -0
- package/dist/templates/production-app/src/componentRegistry.d.ts +20 -0
- package/dist/templates/production-app/src/componentRegistry.d.ts.map +1 -0
- package/dist/templates/production-app/src/componentRegistry.js +316 -0
- package/dist/templates/production-app/src/main.d.ts +9 -0
- package/dist/templates/production-app/src/main.d.ts.map +1 -0
- package/dist/templates/production-app/src/main.js +18 -0
- package/dist/templates/production-app/vite.config.d.ts +3 -0
- package/dist/templates/production-app/vite.config.d.ts.map +1 -0
- package/dist/templates/production-app/vite.config.js +71 -0
- package/dist/test-storybooks/angular-material-storybook/src/main.js +66 -0
- package/dist/test-storybooks/chakra-storybook/vite.config.js +6 -0
- package/dist/test-storybooks/mantine-storybook/vite.config.js +93 -0
- package/dist/test-storybooks/web-components-shoelace/vite.config.js +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/visual-builder/components/Canvas/Canvas.js +70 -0
- package/dist/visual-builder/components/Canvas/ComponentRenderer.js +545 -0
- package/dist/visual-builder/components/CodeExporter/CodeExporter.js +25 -0
- package/dist/visual-builder/components/CodeExporter/codeGenerator.js +99 -0
- package/dist/visual-builder/components/ComponentPalette/ComponentPalette.js +8 -0
- package/dist/visual-builder/components/ComponentPalette/ComponentPaletteItem.js +51 -0
- package/dist/visual-builder/components/EmbeddedVisualBuilder.js +107 -0
- package/dist/visual-builder/components/PropertyEditor/PropertyEditor.js +16 -0
- package/dist/visual-builder/components/PropertyEditor/PropertyForm.js +88 -0
- package/dist/visual-builder/components/PropertyEditor/SpacingControl.js +145 -0
- package/dist/visual-builder/components/PropertyEditor/SpacingEditor.js +32 -0
- package/dist/visual-builder/components/StoryManager/SaveOnlyManager.js +94 -0
- package/dist/visual-builder/components/StoryManager/StoryManager.js +68 -0
- package/dist/visual-builder/components/StoryManager/index.js +1 -0
- package/dist/visual-builder/components/VisualBuilder.js +256 -0
- package/dist/visual-builder/config/componentRegistry.js +1758 -0
- package/dist/visual-builder/decorators/VisualBuilderDecorator.js +184 -0
- package/dist/visual-builder/example-integration.js +59 -0
- package/dist/visual-builder/example.js +23 -0
- package/dist/visual-builder/hooks/useDragAndDrop.js +137 -0
- package/dist/visual-builder/hooks/useSelection.js +27 -0
- package/dist/visual-builder/index.js +7 -0
- package/dist/visual-builder/store/visualBuilderStore.js +305 -0
- package/dist/visual-builder/types/index.js +1 -0
- package/dist/visual-builder/utils/__tests__/storyFileUpdater.test.js +145 -0
- package/dist/visual-builder/utils/aiParser.js +336 -0
- package/dist/visual-builder/utils/componentTreeUtils.js +111 -0
- package/dist/visual-builder/utils/parserValidation.js +122 -0
- package/dist/visual-builder/utils/storyFileManager.js +73 -0
- package/dist/visual-builder/utils/storyFileUpdater.js +326 -0
- package/dist/visual-builder/utils/storyNameExtraction.test.js +211 -0
- package/dist/visual-builder/utils/storyPersistence.js +180 -0
- package/dist/visual-builder/utils/storyToBuilder.js +813 -0
- package/package.json +1 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
const VisualBuilderButton = ({ fileName, title, storyVariant }) => {
|
|
4
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
5
|
+
const handleOpenVisualBuilder = async () => {
|
|
6
|
+
// Check if this is an edited story
|
|
7
|
+
const isEditedStory = title?.startsWith('Edited/');
|
|
8
|
+
// Get the story source code
|
|
9
|
+
let sourceCode = '';
|
|
10
|
+
console.log('🚀 Starting Visual Builder source fetch:', {
|
|
11
|
+
fileName,
|
|
12
|
+
title,
|
|
13
|
+
isEditedStory,
|
|
14
|
+
storyVariant
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
// Try to get raw source from Vite plugin endpoint
|
|
18
|
+
const cleanFileName = fileName.replace(/\.stories\.tsx$/, '').replace(/\.stories$/, '');
|
|
19
|
+
try {
|
|
20
|
+
console.log(`🔍 Trying Vite plugin endpoint: /api/raw-source?file=${encodeURIComponent(cleanFileName)}&isEdited=${isEditedStory}`);
|
|
21
|
+
const response = await fetch(`/api/raw-source?file=${encodeURIComponent(cleanFileName)}&isEdited=${isEditedStory}`);
|
|
22
|
+
if (response.ok) {
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
if (data.success && data.source) {
|
|
25
|
+
sourceCode = data.source;
|
|
26
|
+
console.log('✅ Got raw source code from Vite plugin endpoint');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (pluginError) {
|
|
31
|
+
console.log('❌ Vite plugin endpoint not available:', pluginError);
|
|
32
|
+
}
|
|
33
|
+
// Fallback - try to get from MCP server if available
|
|
34
|
+
if (!sourceCode) {
|
|
35
|
+
const apiPort = window.STORY_UI_MCP_PORT ||
|
|
36
|
+
window.__STORY_UI_PORT__ ||
|
|
37
|
+
import.meta.env?.VITE_STORY_UI_PORT ||
|
|
38
|
+
'4001';
|
|
39
|
+
try {
|
|
40
|
+
const possibleNames = [
|
|
41
|
+
fileName,
|
|
42
|
+
cleanFileName,
|
|
43
|
+
`${cleanFileName}.stories.tsx`,
|
|
44
|
+
`${fileName}.stories.tsx`
|
|
45
|
+
];
|
|
46
|
+
for (const name of possibleNames) {
|
|
47
|
+
try {
|
|
48
|
+
const mpcResponse = await fetch(`http://localhost:${apiPort}/story-ui/visual-builder/load?fileName=${encodeURIComponent(name)}&isEdited=${isEditedStory}`);
|
|
49
|
+
if (mpcResponse.ok) {
|
|
50
|
+
const data = await mpcResponse.json();
|
|
51
|
+
if (data.success && data.content && data.content.trim().length > 0) {
|
|
52
|
+
sourceCode = data.content;
|
|
53
|
+
console.log('✅ Got source code from Visual Builder endpoint:', name);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (nameError) {
|
|
59
|
+
console.log(`❌ Failed to fetch "${name}":`, nameError.message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (mpcError) {
|
|
64
|
+
console.log('❌ MCP server not available:', mpcError);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// If no source code available, create a template
|
|
68
|
+
if (!sourceCode) {
|
|
69
|
+
console.warn('⚠️ Creating fallback template - no source available');
|
|
70
|
+
sourceCode = `// Source code not available - creating template
|
|
71
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
72
|
+
|
|
73
|
+
const meta = {
|
|
74
|
+
title: '${title || 'Generated/Component'}',
|
|
75
|
+
parameters: {
|
|
76
|
+
layout: 'centered',
|
|
77
|
+
visualBuilder: true,
|
|
78
|
+
},
|
|
79
|
+
} satisfies Meta;
|
|
80
|
+
|
|
81
|
+
export default meta;
|
|
82
|
+
type Story = StoryObj<typeof meta>;
|
|
83
|
+
|
|
84
|
+
export const Default: Story = {
|
|
85
|
+
render: () => (
|
|
86
|
+
<div>Component ready for editing in Visual Builder</div>
|
|
87
|
+
),
|
|
88
|
+
};`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.error('❌ Error fetching story source:', error);
|
|
93
|
+
}
|
|
94
|
+
// Store the source code in sessionStorage for Visual Builder to pick up
|
|
95
|
+
sessionStorage.setItem('visualBuilderInitialCode', sourceCode);
|
|
96
|
+
sessionStorage.setItem('visualBuilderSourceFile', fileName);
|
|
97
|
+
sessionStorage.setItem('visualBuilderStoryVariant', storyVariant || 'Default');
|
|
98
|
+
sessionStorage.setItem('visualBuilderIsEdited', isEditedStory ? 'true' : 'false');
|
|
99
|
+
// Clear any previous Visual Builder draft to ensure clean start
|
|
100
|
+
sessionStorage.removeItem('visualBuilderDraft');
|
|
101
|
+
console.log('📝 Stored source code for Visual Builder:', {
|
|
102
|
+
fileName,
|
|
103
|
+
sourceLength: sourceCode.length,
|
|
104
|
+
preview: sourceCode.substring(0, 200) + '...'
|
|
105
|
+
});
|
|
106
|
+
// Open Visual Builder in a new tab
|
|
107
|
+
const visualBuilderUrl = `${window.location.origin}${window.location.pathname}?path=/story/story-ui--generator`;
|
|
108
|
+
// Navigate to the Visual Builder story
|
|
109
|
+
window.location.href = visualBuilderUrl;
|
|
110
|
+
};
|
|
111
|
+
return (_jsx("button", { onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onClick: handleOpenVisualBuilder, style: {
|
|
112
|
+
position: 'fixed',
|
|
113
|
+
top: '12px',
|
|
114
|
+
right: '12px',
|
|
115
|
+
padding: '4px 8px',
|
|
116
|
+
fontSize: '11px',
|
|
117
|
+
fontWeight: 500,
|
|
118
|
+
color: isHovered ? '#8b5cf6' : '#94a3b8',
|
|
119
|
+
backgroundColor: isHovered ? 'rgba(139, 92, 246, 0.1)' : 'rgba(255, 255, 255, 0.9)',
|
|
120
|
+
border: `1px solid ${isHovered ? '#8b5cf6' : 'rgba(148, 163, 184, 0.3)'}`,
|
|
121
|
+
borderRadius: '4px',
|
|
122
|
+
cursor: 'pointer',
|
|
123
|
+
transition: 'all 0.2s ease',
|
|
124
|
+
zIndex: 9999,
|
|
125
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif',
|
|
126
|
+
boxShadow: isHovered ? '0 2px 8px rgba(139, 92, 246, 0.3)' : '0 1px 3px rgba(0, 0, 0, 0.1)',
|
|
127
|
+
backdropFilter: 'blur(8px)',
|
|
128
|
+
}, title: "Open in Visual Builder for advanced editing", children: "\uD83C\uDFA8 Edit in Visual Builder" }));
|
|
129
|
+
};
|
|
130
|
+
export const withVisualBuilderButton = (Story, context) => {
|
|
131
|
+
const [showButton, setShowButton] = useState(false);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
// Show button for ALL generated AND edited stories
|
|
134
|
+
const isEditableStory = context.title?.startsWith('Generated/') ||
|
|
135
|
+
context.title?.startsWith('Edited/') ||
|
|
136
|
+
context.id?.toLowerCase().includes('generated') ||
|
|
137
|
+
context.id?.toLowerCase().includes('edited') ||
|
|
138
|
+
context.parameters?.visualBuilder === true ||
|
|
139
|
+
context.parameters?.isEdited === true;
|
|
140
|
+
setShowButton(isEditableStory);
|
|
141
|
+
}, [context.title, context.id, context.parameters]);
|
|
142
|
+
// Extract fileName from the story ID or parameters
|
|
143
|
+
const storyId = context.id || '';
|
|
144
|
+
const storyName = context.name || 'Default';
|
|
145
|
+
const isEditedStory = context.title?.startsWith('Edited/') || context.parameters?.isEdited === true;
|
|
146
|
+
let fileName = context.parameters?.fileName || 'unknown';
|
|
147
|
+
// Clean the fileName if it contains a path
|
|
148
|
+
if (fileName && fileName !== 'unknown') {
|
|
149
|
+
fileName = fileName
|
|
150
|
+
.replace(/^\.\//, '')
|
|
151
|
+
.replace(/^.*\//, '')
|
|
152
|
+
.replace(/\.stories\.(tsx?|jsx?)$/, '')
|
|
153
|
+
.replace(/\.(tsx?|jsx?)$/, '');
|
|
154
|
+
}
|
|
155
|
+
// If no fileName parameter, try to extract from story ID
|
|
156
|
+
if (!fileName || fileName === 'unknown' && storyId) {
|
|
157
|
+
const baseId = storyId.split('--')[0];
|
|
158
|
+
if (baseId.startsWith('generated-')) {
|
|
159
|
+
fileName = baseId.substring(10);
|
|
160
|
+
}
|
|
161
|
+
else if (baseId.startsWith('edited-')) {
|
|
162
|
+
fileName = baseId.substring(7);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
fileName = baseId;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return (_jsxs(_Fragment, { children: [_jsx(Story, { ...context }), showButton && (_jsx(VisualBuilderButton, { fileName: fileName, title: context.title, storyVariant: storyName }))] }));
|
|
169
|
+
};
|
|
170
|
+
// Helper function to apply decorator to generated stories
|
|
171
|
+
export const applyToGeneratedStories = (storyExports) => {
|
|
172
|
+
if (storyExports.default) {
|
|
173
|
+
storyExports.default.decorators = [
|
|
174
|
+
...(storyExports.default.decorators || []),
|
|
175
|
+
withVisualBuilderButton
|
|
176
|
+
];
|
|
177
|
+
// Add visual builder parameter to mark this as editable
|
|
178
|
+
storyExports.default.parameters = {
|
|
179
|
+
...storyExports.default.parameters,
|
|
180
|
+
visualBuilder: true,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return storyExports;
|
|
184
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StoryUIPanel } from '../templates/StoryUI/StoryUIPanel';
|
|
3
|
+
/**
|
|
4
|
+
* Example integration showing how the Visual Builder integrates with Story UI Panel
|
|
5
|
+
*
|
|
6
|
+
* This demonstrates the complete workflow:
|
|
7
|
+
* 1. User describes a component in the AI chat
|
|
8
|
+
* 2. AI generates component code
|
|
9
|
+
* 3. User can click "Edit in Visual Builder"
|
|
10
|
+
* 4. Visual Builder loads the generated code and allows visual editing
|
|
11
|
+
* 5. User can export the updated code
|
|
12
|
+
*/
|
|
13
|
+
export const IntegrationExample = () => {
|
|
14
|
+
return (_jsx("div", { style: { height: '100vh' }, children: _jsx(StoryUIPanel, {}) }));
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Example AI-generated code that the parser should handle well
|
|
18
|
+
*/
|
|
19
|
+
export const sampleAICode = `
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import { Button, TextInput, Stack, Card, Title, Group } from '@mantine/core';
|
|
22
|
+
|
|
23
|
+
export const LoginForm = () => {
|
|
24
|
+
return (
|
|
25
|
+
<Card shadow="sm" padding="lg" radius="md" withBorder>
|
|
26
|
+
<Stack gap="md">
|
|
27
|
+
<Title order={2}>Login</Title>
|
|
28
|
+
<TextInput
|
|
29
|
+
label="Email"
|
|
30
|
+
placeholder="Enter your email"
|
|
31
|
+
required
|
|
32
|
+
/>
|
|
33
|
+
<TextInput
|
|
34
|
+
label="Password"
|
|
35
|
+
placeholder="Enter your password"
|
|
36
|
+
type="password"
|
|
37
|
+
required
|
|
38
|
+
/>
|
|
39
|
+
<Group justify="space-between">
|
|
40
|
+
<Button variant="outline">Cancel</Button>
|
|
41
|
+
<Button>Login</Button>
|
|
42
|
+
</Group>
|
|
43
|
+
</Stack>
|
|
44
|
+
</Card>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* Test the parser with sample code
|
|
50
|
+
*/
|
|
51
|
+
export const testParser = () => {
|
|
52
|
+
const { parseAIGeneratedCode } = require('./utils/aiParser');
|
|
53
|
+
const result = parseAIGeneratedCode(sampleAICode);
|
|
54
|
+
console.log('Parse Result:', result);
|
|
55
|
+
console.log('Errors:', result.errors);
|
|
56
|
+
console.log('Warnings:', result.warnings);
|
|
57
|
+
console.log('Components:', result.components);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MantineProvider, createTheme } from '@mantine/core';
|
|
3
|
+
import { VisualBuilder } from './components/VisualBuilder';
|
|
4
|
+
const theme = createTheme({
|
|
5
|
+
/** Put your mantine theme override here */
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Example usage of the Visual Builder component
|
|
9
|
+
*
|
|
10
|
+
* This demonstrates how to integrate the Visual Builder into your React application.
|
|
11
|
+
* The Visual Builder provides a complete drag-and-drop interface for building UI components.
|
|
12
|
+
*/
|
|
13
|
+
export const VisualBuilderExample = () => {
|
|
14
|
+
return (_jsx(MantineProvider, { theme: theme, children: _jsx("div", { style: { height: '100vh', width: '100vw' }, children: _jsx(VisualBuilder, {}) }) }));
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Standalone Visual Builder for development/testing
|
|
18
|
+
*/
|
|
19
|
+
export const StandaloneVisualBuilder = () => {
|
|
20
|
+
return (_jsx(MantineProvider, { children: _jsx(VisualBuilder, { height: "100vh", style: {
|
|
21
|
+
fontFamily: 'system-ui, sans-serif'
|
|
22
|
+
} }) }));
|
|
23
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
3
|
+
import { useVisualBuilderStore } from '../store/visualBuilderStore';
|
|
4
|
+
import { getComponentConfig, CONTAINER_COMPONENTS } from '../config/componentRegistry';
|
|
5
|
+
export const useDragAndDrop = () => {
|
|
6
|
+
const { setDraggedComponent, addComponent, moveComponent, moveComponentBetweenContainers, selectComponent } = useVisualBuilderStore();
|
|
7
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
|
8
|
+
activationConstraint: {
|
|
9
|
+
distance: 8,
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
const handleDragStart = useCallback((event) => {
|
|
13
|
+
const { active } = event;
|
|
14
|
+
const dragData = active.data.current;
|
|
15
|
+
if (dragData?.isFromPalette) {
|
|
16
|
+
// Dragging from component palette
|
|
17
|
+
const config = getComponentConfig(dragData.componentType);
|
|
18
|
+
if (config) {
|
|
19
|
+
const component = {
|
|
20
|
+
id: `temp-${Date.now()}`,
|
|
21
|
+
type: config.type,
|
|
22
|
+
displayName: config.displayName,
|
|
23
|
+
category: config.category,
|
|
24
|
+
props: { ...config.defaultProps },
|
|
25
|
+
children: []
|
|
26
|
+
};
|
|
27
|
+
setDraggedComponent(component);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Dragging existing component (reordering)
|
|
32
|
+
setDraggedComponent(dragData?.component || null);
|
|
33
|
+
}
|
|
34
|
+
}, [setDraggedComponent]);
|
|
35
|
+
const handleDragOver = useCallback((_event) => {
|
|
36
|
+
// Handle drag over for visual feedback
|
|
37
|
+
// Add visual feedback logic here if needed
|
|
38
|
+
// This could include highlighting valid drop zones
|
|
39
|
+
}, []);
|
|
40
|
+
const handleDragEnd = useCallback((event) => {
|
|
41
|
+
const { active, over } = event;
|
|
42
|
+
if (!over) {
|
|
43
|
+
setDraggedComponent(null);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const dragData = active.data.current;
|
|
47
|
+
const dropData = over.data.current;
|
|
48
|
+
if (dragData?.isFromPalette) {
|
|
49
|
+
// Adding new component from palette
|
|
50
|
+
const config = getComponentConfig(dragData.componentType);
|
|
51
|
+
if (config) {
|
|
52
|
+
const component = {
|
|
53
|
+
id: `${config.type}-${Date.now()}`,
|
|
54
|
+
type: config.type,
|
|
55
|
+
displayName: config.displayName,
|
|
56
|
+
category: config.category,
|
|
57
|
+
props: { ...config.defaultProps },
|
|
58
|
+
children: CONTAINER_COMPONENTS.includes(config.type) ? [] : undefined
|
|
59
|
+
};
|
|
60
|
+
// Determine the target for drop
|
|
61
|
+
let targetId = undefined;
|
|
62
|
+
let insertIndex = undefined;
|
|
63
|
+
// Check if dropped on an insertion point
|
|
64
|
+
if (dropData?.isInsertionPoint) {
|
|
65
|
+
// Insert at specific index in specific parent (or root)
|
|
66
|
+
targetId = dropData.parentId || undefined; // null means root level
|
|
67
|
+
insertIndex = dropData.insertIndex;
|
|
68
|
+
}
|
|
69
|
+
// Check if dropped on a container drop zone
|
|
70
|
+
else if (dropData?.isContainer && dropData?.componentId) {
|
|
71
|
+
targetId = dropData.componentId;
|
|
72
|
+
insertIndex = dropData.insertIndex; // Append to end
|
|
73
|
+
}
|
|
74
|
+
// Check if dropped on canvas
|
|
75
|
+
else if (dropData?.isCanvas || over.id === 'canvas') {
|
|
76
|
+
targetId = undefined; // Root level
|
|
77
|
+
}
|
|
78
|
+
// Check if over.id ends with '-drop' (container drop zone)
|
|
79
|
+
else if (typeof over.id === 'string' && over.id.endsWith('-drop')) {
|
|
80
|
+
targetId = over.id.replace('-drop', '');
|
|
81
|
+
}
|
|
82
|
+
addComponent(component, targetId, insertIndex);
|
|
83
|
+
// Auto-select the new component
|
|
84
|
+
selectComponent({
|
|
85
|
+
id: component.id,
|
|
86
|
+
type: component.type,
|
|
87
|
+
props: component.props
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (dragData?.component) {
|
|
92
|
+
// Reordering existing components
|
|
93
|
+
const componentId = dragData.component.id;
|
|
94
|
+
if (dropData?.isInsertionPoint) {
|
|
95
|
+
// Handle insertion point drops for precise positioning
|
|
96
|
+
const targetParentId = dropData.parentId;
|
|
97
|
+
const insertIndex = dropData.insertIndex;
|
|
98
|
+
// Move to the specific insertion point
|
|
99
|
+
moveComponentBetweenContainers(componentId, dragData.parentId || null, targetParentId, insertIndex);
|
|
100
|
+
}
|
|
101
|
+
else if (dropData?.isContainer && dropData?.componentId) {
|
|
102
|
+
// Move to container - determine if it's between containers or within same container
|
|
103
|
+
const targetContainerId = dropData.componentId;
|
|
104
|
+
const insertIndex = dropData.insertIndex;
|
|
105
|
+
// Use the enhanced move function for better container handling
|
|
106
|
+
moveComponentBetweenContainers(componentId, dragData.parentId || null, targetContainerId, insertIndex);
|
|
107
|
+
}
|
|
108
|
+
else if (dropData?.isCanvas || over.id === 'canvas') {
|
|
109
|
+
// Move to root level (canvas)
|
|
110
|
+
moveComponentBetweenContainers(componentId, dragData.parentId || null, null, undefined);
|
|
111
|
+
}
|
|
112
|
+
else if (typeof over.id === 'string' && over.id.endsWith('-drop')) {
|
|
113
|
+
// Handle container drop zones
|
|
114
|
+
const containerId = over.id.replace('-drop', '');
|
|
115
|
+
moveComponentBetweenContainers(componentId, dragData.parentId || null, containerId, undefined);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Default: try to move relative to the over component
|
|
119
|
+
const overComponentId = typeof over.id === 'string' ? over.id : String(over.id);
|
|
120
|
+
if (overComponentId !== componentId) {
|
|
121
|
+
moveComponent(componentId, overComponentId, undefined, 'after');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
setDraggedComponent(null);
|
|
126
|
+
}, [setDraggedComponent, addComponent, moveComponent, selectComponent]);
|
|
127
|
+
const handleDragCancel = useCallback(() => {
|
|
128
|
+
setDraggedComponent(null);
|
|
129
|
+
}, [setDraggedComponent]);
|
|
130
|
+
return {
|
|
131
|
+
sensors,
|
|
132
|
+
handleDragStart,
|
|
133
|
+
handleDragOver,
|
|
134
|
+
handleDragEnd,
|
|
135
|
+
handleDragCancel
|
|
136
|
+
};
|
|
137
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useVisualBuilderStore } from '../store/visualBuilderStore';
|
|
3
|
+
export const useSelection = () => {
|
|
4
|
+
const { selectedComponent, selectComponent } = useVisualBuilderStore();
|
|
5
|
+
const handleComponentSelect = useCallback((component) => {
|
|
6
|
+
selectComponent({
|
|
7
|
+
id: component.id,
|
|
8
|
+
type: component.type,
|
|
9
|
+
props: component.props
|
|
10
|
+
});
|
|
11
|
+
}, [selectComponent]);
|
|
12
|
+
const handleCanvasClick = useCallback((event) => {
|
|
13
|
+
// If clicking on empty canvas area, deselect
|
|
14
|
+
if (event.target === event.currentTarget) {
|
|
15
|
+
selectComponent(null);
|
|
16
|
+
}
|
|
17
|
+
}, [selectComponent]);
|
|
18
|
+
const isSelected = useCallback((componentId) => {
|
|
19
|
+
return selectedComponent?.id === componentId;
|
|
20
|
+
}, [selectedComponent]);
|
|
21
|
+
return {
|
|
22
|
+
selectedComponent,
|
|
23
|
+
handleComponentSelect,
|
|
24
|
+
handleCanvasClick,
|
|
25
|
+
isSelected
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Visual Builder exports
|
|
2
|
+
export { VisualBuilder } from './components/VisualBuilder';
|
|
3
|
+
export { EmbeddedVisualBuilder } from './components/EmbeddedVisualBuilder';
|
|
4
|
+
export { useVisualBuilderStore } from './store/visualBuilderStore';
|
|
5
|
+
export { getComponentConfig, getComponentsByCategory, MANTINE_COMPONENTS } from './config/componentRegistry';
|
|
6
|
+
export { parseAIGeneratedCode, createBasicLayout } from './utils/aiParser';
|
|
7
|
+
export { parseStoryUIToBuilder, extractJSXFromStory, validateParsedComponents, isViteTransformedCode, preprocessStoryCode } from './utils/storyToBuilder';
|