@tpitre/story-ui 2.8.0 → 3.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/dist/cli/index.js +0 -0
- package/dist/cli/index.js.map +1 -0
- 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.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/logger.js.map +1 -0
- package/dist/story-generator/postProcessStory.js.map +1 -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.d.ts.map +1 -1
- package/dist/templates/StoryUI/StoryUIPanel.js +30 -2
- 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/package.json +1 -1
- package/templates/StoryUI/StoryUIPanel.tsx +35 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/* AI Assistant styles */
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
padding: 16px;
|
|
5
|
+
height: 100%;
|
|
6
|
+
overflow-y: auto;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.section {
|
|
10
|
+
margin-bottom: 24px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.label {
|
|
14
|
+
display: block;
|
|
15
|
+
font-size: 14px;
|
|
16
|
+
font-weight: 500;
|
|
17
|
+
color: #374151;
|
|
18
|
+
margin-bottom: 8px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.textarea {
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding: 12px;
|
|
24
|
+
border: 1px solid #d1d5db;
|
|
25
|
+
border-radius: 8px;
|
|
26
|
+
font-size: 14px;
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
resize: vertical;
|
|
29
|
+
transition: border-color 0.2s;
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.textarea:focus {
|
|
34
|
+
outline: none;
|
|
35
|
+
border-color: #3b82f6;
|
|
36
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.textarea:disabled {
|
|
40
|
+
background: #f3f4f6;
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.buttonGroup {
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: 8px;
|
|
47
|
+
margin-top: 12px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.button {
|
|
51
|
+
flex: 1;
|
|
52
|
+
padding: 10px 16px;
|
|
53
|
+
border-radius: 8px;
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
font-weight: 500;
|
|
56
|
+
font-family: inherit;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
transition: all 0.2s;
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
gap: 8px;
|
|
63
|
+
border: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.button:disabled {
|
|
67
|
+
opacity: 0.5;
|
|
68
|
+
cursor: not-allowed;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.primaryButton {
|
|
72
|
+
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
|
|
73
|
+
color: white;
|
|
74
|
+
box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.primaryButton:hover:not(:disabled) {
|
|
78
|
+
transform: translateY(-1px);
|
|
79
|
+
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.secondaryButton {
|
|
83
|
+
background: white;
|
|
84
|
+
color: #3b82f6;
|
|
85
|
+
border: 1px solid #3b82f6;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.secondaryButton:hover:not(:disabled) {
|
|
89
|
+
background: #eff6ff;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.icon {
|
|
93
|
+
font-size: 16px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.spinner {
|
|
97
|
+
width: 14px;
|
|
98
|
+
height: 14px;
|
|
99
|
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
100
|
+
border-top-color: white;
|
|
101
|
+
border-radius: 50%;
|
|
102
|
+
animation: spin 0.6s linear infinite;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@keyframes spin {
|
|
106
|
+
to { transform: rotate(360deg); }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.error {
|
|
110
|
+
margin-top: 12px;
|
|
111
|
+
padding: 12px;
|
|
112
|
+
background: #fee2e2;
|
|
113
|
+
border: 1px solid #fecaca;
|
|
114
|
+
border-radius: 8px;
|
|
115
|
+
color: #dc2626;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: flex-start;
|
|
119
|
+
gap: 8px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.errorIcon {
|
|
123
|
+
flex-shrink: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.sectionTitle {
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
font-weight: 600;
|
|
129
|
+
color: #1f2937;
|
|
130
|
+
margin: 0 0 12px 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.suggestions {
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-wrap: wrap;
|
|
136
|
+
gap: 8px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.suggestion {
|
|
140
|
+
padding: 6px 12px;
|
|
141
|
+
background: #f3f4f6;
|
|
142
|
+
border: 1px solid #e5e7eb;
|
|
143
|
+
border-radius: 6px;
|
|
144
|
+
font-size: 13px;
|
|
145
|
+
color: #4b5563;
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
transition: all 0.2s;
|
|
148
|
+
font-family: inherit;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.suggestion:hover {
|
|
152
|
+
background: #e5e7eb;
|
|
153
|
+
color: #1f2937;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.tips {
|
|
157
|
+
margin: 0;
|
|
158
|
+
padding-left: 20px;
|
|
159
|
+
color: #6b7280;
|
|
160
|
+
font-size: 13px;
|
|
161
|
+
line-height: 1.6;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.tips li {
|
|
165
|
+
margin-bottom: 6px;
|
|
166
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../../playground/components/Canvas/Canvas.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAyC,MAAM,OAAO,CAAC;AAO9D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA6HxC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Canvas - Main rendering surface for visual components
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useRef, useCallback } from 'react';
|
|
6
|
+
import { usePlaygroundStore } from '../../store/playgroundStore';
|
|
7
|
+
import { DropZone } from '../DropZone/DropZone';
|
|
8
|
+
import { DraggableComponent } from './DraggableComponent';
|
|
9
|
+
import styles from './Canvas.module.css';
|
|
10
|
+
export const Canvas = ({ onReady }) => {
|
|
11
|
+
const canvasRef = useRef(null);
|
|
12
|
+
const { components, rootId, selectedIds, hoveredId, canvasZoom, canvasOffset, showGrid, gridSize, mode, selectComponent, deselectAll, setHoveredComponent } = usePlaygroundStore();
|
|
13
|
+
// Notify when canvas is ready
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
onReady?.();
|
|
16
|
+
}, [onReady]);
|
|
17
|
+
// Handle canvas click for deselection
|
|
18
|
+
const handleCanvasClick = useCallback((e) => {
|
|
19
|
+
// Only deselect if clicking directly on canvas
|
|
20
|
+
if (e.target === e.currentTarget) {
|
|
21
|
+
deselectAll();
|
|
22
|
+
}
|
|
23
|
+
}, [deselectAll]);
|
|
24
|
+
// Handle keyboard shortcuts
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const handleKeyDown = (e) => {
|
|
27
|
+
// Delete selected components
|
|
28
|
+
if ((e.key === 'Delete' || e.key === 'Backspace') && selectedIds.size > 0) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
// Implementation would go here
|
|
31
|
+
}
|
|
32
|
+
// Select all
|
|
33
|
+
if (e.metaKey && e.key === 'a') {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
// Implementation would go here
|
|
36
|
+
}
|
|
37
|
+
// Deselect all
|
|
38
|
+
if (e.key === 'Escape') {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
deselectAll();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
44
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
45
|
+
}, [selectedIds, deselectAll]);
|
|
46
|
+
// Get root component
|
|
47
|
+
const rootComponent = components.get(rootId);
|
|
48
|
+
if (!rootComponent) {
|
|
49
|
+
return (_jsx("div", { className: styles.canvas, children: _jsxs("div", { className: styles.emptyState, children: [_jsx("p", { children: "No components to display" }), _jsx("p", { className: styles.hint, children: "Use the AI Assistant to generate a layout or drag components from the palette" })] }) }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsx("div", { ref: canvasRef, className: styles.canvas, onClick: handleCanvasClick, "data-mode": mode, "data-canvas": true, children: _jsxs("div", { className: styles.viewport, style: {
|
|
52
|
+
transform: `scale(${canvasZoom}) translate(${canvasOffset.x}px, ${canvasOffset.y}px)`,
|
|
53
|
+
transformOrigin: 'top left'
|
|
54
|
+
}, children: [showGrid && (_jsx("div", { className: styles.grid, style: {
|
|
55
|
+
backgroundSize: `${gridSize}px ${gridSize}px`
|
|
56
|
+
} })), _jsx("div", { className: styles.componentContainer, children: _jsx(DropZone, { id: "root-drop-zone", componentId: rootId, accepts: ['all'], showIndicator: mode === 'edit', children: _jsx(DraggableComponent, { component: rootComponent, isRoot: true, isSelected: selectedIds.has(rootId), isHovered: hoveredId === rootId, onSelect: (id) => selectComponent(id), onHover: (id) => setHoveredComponent(id) }) }) }), selectedIds.size > 0 && (_jsx("div", { className: styles.selectionOverlay }))] }) }));
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=Canvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../../../../playground/components/Canvas/Canvas.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAMzC,MAAM,CAAC,MAAM,MAAM,GAA0B,CAAC,EAAE,OAAO,EAAE,EAAE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U,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EACnC,SAAS,EAAE,SAAS,KAAK,MAAM,EAC/B,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,EACrC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,CAAC,GACxC,GACO,GACP,EAGL,WAAW,CAAC,IAAI,GAAG,CAAC,IAAI,CACvB,cAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,GAEjC,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/* Canvas styles */
|
|
2
|
+
|
|
3
|
+
.canvas {
|
|
4
|
+
flex: 1;
|
|
5
|
+
position: relative;
|
|
6
|
+
background: #fafafa;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
height: 100%;
|
|
9
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.viewport {
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
position: relative;
|
|
16
|
+
transition: transform 0.2s ease-out;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.grid {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
background-image:
|
|
26
|
+
linear-gradient(0deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
|
|
27
|
+
linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
|
|
28
|
+
background-size: 8px 8px;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.componentContainer {
|
|
33
|
+
position: relative;
|
|
34
|
+
width: 100%;
|
|
35
|
+
min-height: 100vh;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.component {
|
|
39
|
+
position: relative;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
transition: outline 0.2s ease;
|
|
42
|
+
font-family: inherit;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.component:hover {
|
|
46
|
+
outline: 1px solid #93c5fd;
|
|
47
|
+
outline-offset: 2px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.component.selected {
|
|
51
|
+
outline: 2px solid #3b82f6;
|
|
52
|
+
outline-offset: 2px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.component.hovered {
|
|
56
|
+
outline: 1px dashed #60a5fa;
|
|
57
|
+
outline-offset: 2px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.component.root {
|
|
61
|
+
cursor: default;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.emptyState {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
height: 100%;
|
|
70
|
+
color: #6b7280;
|
|
71
|
+
text-align: center;
|
|
72
|
+
padding: 32px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.emptyState p {
|
|
76
|
+
margin: 8px 0;
|
|
77
|
+
font-size: 16px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.emptyState .hint {
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
color: #9ca3af;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.selectionOverlay {
|
|
86
|
+
position: absolute;
|
|
87
|
+
top: 0;
|
|
88
|
+
left: 0;
|
|
89
|
+
right: 0;
|
|
90
|
+
bottom: 0;
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Mode-specific styles */
|
|
95
|
+
.canvas[data-mode="view"] .component {
|
|
96
|
+
cursor: default;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.canvas[data-mode="view"] .component:hover {
|
|
100
|
+
outline: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Helper component indicators */
|
|
104
|
+
[data-helper] {
|
|
105
|
+
position: relative;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-helper]::before {
|
|
109
|
+
content: attr(data-helper);
|
|
110
|
+
position: absolute;
|
|
111
|
+
top: 2px;
|
|
112
|
+
right: 2px;
|
|
113
|
+
font-size: 10px;
|
|
114
|
+
color: #9ca3af;
|
|
115
|
+
background: rgba(255, 255, 255, 0.9);
|
|
116
|
+
padding: 2px 4px;
|
|
117
|
+
border-radius: 2px;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
z-index: 1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Draggable Component */
|
|
123
|
+
.draggableComponent {
|
|
124
|
+
position: relative;
|
|
125
|
+
cursor: move;
|
|
126
|
+
transition: opacity 0.2s;
|
|
127
|
+
font-family: inherit;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.draggableComponent.root {
|
|
131
|
+
cursor: default;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.draggableComponent.dragging {
|
|
135
|
+
opacity: 0.5;
|
|
136
|
+
cursor: grabbing;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.draggableComponent.selected {
|
|
140
|
+
outline: 2px solid #3b82f6;
|
|
141
|
+
outline-offset: 2px;
|
|
142
|
+
position: relative;
|
|
143
|
+
z-index: 10;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.draggableComponent.hovered {
|
|
147
|
+
outline: 1px dashed #93c5fd;
|
|
148
|
+
outline-offset: 2px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.componentChildren {
|
|
152
|
+
position: relative;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.childWrapper {
|
|
156
|
+
position: relative;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Insertion zones for drag and drop */
|
|
160
|
+
.insertionZone {
|
|
161
|
+
min-height: 4px;
|
|
162
|
+
transition: all 0.2s;
|
|
163
|
+
position: relative;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.insertionZone.active {
|
|
167
|
+
min-height: 24px;
|
|
168
|
+
background: rgba(59, 130, 246, 0.1);
|
|
169
|
+
border: 2px dashed #3b82f6;
|
|
170
|
+
border-radius: 4px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* Drag ghost */
|
|
174
|
+
.dragGhost {
|
|
175
|
+
pointer-events: none;
|
|
176
|
+
opacity: 0.8;
|
|
177
|
+
transform: scale(1.05);
|
|
178
|
+
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.newComponentGhost {
|
|
182
|
+
padding: 12px 24px;
|
|
183
|
+
background: white;
|
|
184
|
+
border: 2px solid #3b82f6;
|
|
185
|
+
border-radius: 8px;
|
|
186
|
+
font-weight: 500;
|
|
187
|
+
color: #3b82f6;
|
|
188
|
+
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
|
|
189
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CanvasWithDnd - Canvas with drag and drop support
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface CanvasWithDndProps {
|
|
6
|
+
onReady?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const CanvasWithDnd: React.FC<CanvasWithDndProps>;
|
|
9
|
+
//# sourceMappingURL=CanvasWithDnd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanvasWithDnd.d.ts","sourceRoot":"","sources":["../../../../playground/components/Canvas/CanvasWithDnd.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAkD,MAAM,OAAO,CAAC;AAyBvE,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsQtD,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* CanvasWithDnd - Canvas with drag and drop support
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useRef, useCallback } from 'react';
|
|
6
|
+
import { DndContext, DragOverlay, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
7
|
+
import { sortableKeyboardCoordinates, } from '@dnd-kit/sortable';
|
|
8
|
+
import { usePlaygroundStore } from '../../store/playgroundStore';
|
|
9
|
+
import { DragDropManager } from '../../services/DragDropManager';
|
|
10
|
+
import { ComponentRenderer } from './ComponentRenderer';
|
|
11
|
+
import { DropZone } from '../DropZone/DropZone';
|
|
12
|
+
import { DraggableComponent } from './DraggableComponent';
|
|
13
|
+
import styles from './Canvas.module.css';
|
|
14
|
+
export const CanvasWithDnd = ({ onReady }) => {
|
|
15
|
+
const canvasRef = useRef(null);
|
|
16
|
+
const dragDropManagerRef = useRef(null);
|
|
17
|
+
const store = usePlaygroundStore();
|
|
18
|
+
const { components, rootId, selectedIds, hoveredId, canvasZoom, canvasOffset, showGrid, gridSize, mode, draggedItem, selectComponent, deselectAll, setHoveredComponent } = store;
|
|
19
|
+
// Initialize DragDropManager
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!dragDropManagerRef.current) {
|
|
22
|
+
dragDropManagerRef.current = new DragDropManager(store);
|
|
23
|
+
}
|
|
24
|
+
}, [store]);
|
|
25
|
+
// Configure drag sensors
|
|
26
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
|
27
|
+
activationConstraint: {
|
|
28
|
+
distance: 8,
|
|
29
|
+
},
|
|
30
|
+
}), useSensor(KeyboardSensor, {
|
|
31
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
32
|
+
}));
|
|
33
|
+
// Handle drag start
|
|
34
|
+
const handleDragStart = useCallback((event) => {
|
|
35
|
+
const { active } = event;
|
|
36
|
+
// Create dragged item based on what's being dragged
|
|
37
|
+
let draggedItem;
|
|
38
|
+
if (active.data.current?.type === 'component') {
|
|
39
|
+
// Dragging from palette
|
|
40
|
+
draggedItem = {
|
|
41
|
+
type: 'new-component',
|
|
42
|
+
componentType: active.data.current.componentType,
|
|
43
|
+
source: 'palette'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else if (active.data.current?.type === 'canvas-component') {
|
|
47
|
+
// Dragging existing component
|
|
48
|
+
const component = components.get(active.id);
|
|
49
|
+
if (component) {
|
|
50
|
+
draggedItem = {
|
|
51
|
+
id: component.id,
|
|
52
|
+
type: 'move-component',
|
|
53
|
+
component,
|
|
54
|
+
source: 'canvas'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
dragDropManagerRef.current?.startDrag(draggedItem);
|
|
65
|
+
}, [components]);
|
|
66
|
+
// Handle drag move
|
|
67
|
+
const handleDragMove = useCallback((event) => {
|
|
68
|
+
// Update drag position for drop zone detection
|
|
69
|
+
// This would be enhanced with actual mouse position tracking
|
|
70
|
+
}, []);
|
|
71
|
+
// Handle drag end
|
|
72
|
+
const handleDragEnd = useCallback((event) => {
|
|
73
|
+
const { active, over } = event;
|
|
74
|
+
if (over && dragDropManagerRef.current) {
|
|
75
|
+
// Perform the drop
|
|
76
|
+
const result = dragDropManagerRef.current.endDrag();
|
|
77
|
+
if (result?.success) {
|
|
78
|
+
// Select the dropped component
|
|
79
|
+
if (active.data.current?.type === 'component') {
|
|
80
|
+
// New component was created, select it
|
|
81
|
+
// We'd need to track the created component ID
|
|
82
|
+
}
|
|
83
|
+
else if (active.data.current?.type === 'canvas-component') {
|
|
84
|
+
// Existing component was moved, keep it selected
|
|
85
|
+
selectComponent(active.id);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Cancelled drop
|
|
91
|
+
dragDropManagerRef.current?.cancelDrag();
|
|
92
|
+
}
|
|
93
|
+
}, [selectComponent]);
|
|
94
|
+
// Handle drag cancel
|
|
95
|
+
const handleDragCancel = useCallback((event) => {
|
|
96
|
+
dragDropManagerRef.current?.cancelDrag();
|
|
97
|
+
}, []);
|
|
98
|
+
// Handle canvas click for deselection
|
|
99
|
+
const handleCanvasClick = useCallback((e) => {
|
|
100
|
+
if (e.target === e.currentTarget) {
|
|
101
|
+
deselectAll();
|
|
102
|
+
}
|
|
103
|
+
}, [deselectAll]);
|
|
104
|
+
// Handle keyboard shortcuts
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const handleKeyDown = (e) => {
|
|
107
|
+
// Delete selected components
|
|
108
|
+
if ((e.key === 'Delete' || e.key === 'Backspace') && selectedIds.size > 0) {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
selectedIds.forEach(id => {
|
|
111
|
+
if (id !== rootId) {
|
|
112
|
+
store.deleteComponent(id);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// Select all
|
|
117
|
+
if (e.metaKey && e.key === 'a') {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
store.selectAll();
|
|
120
|
+
}
|
|
121
|
+
// Deselect all
|
|
122
|
+
if (e.key === 'Escape') {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
deselectAll();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
128
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
129
|
+
}, [selectedIds, rootId, deselectAll, store]);
|
|
130
|
+
// Notify when ready
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
onReady?.();
|
|
133
|
+
}, [onReady]);
|
|
134
|
+
// Get root component
|
|
135
|
+
const rootComponent = components.get(rootId);
|
|
136
|
+
if (!rootComponent) {
|
|
137
|
+
return (_jsx("div", { className: styles.canvas, children: _jsxs("div", { className: styles.emptyState, children: [_jsx("p", { children: "No components to display" }), _jsx("p", { className: styles.hint, children: "Use the AI Assistant to generate a layout or drag components from the palette" })] }) }));
|
|
138
|
+
}
|
|
139
|
+
// Render dragged component overlay
|
|
140
|
+
const renderDragOverlay = () => {
|
|
141
|
+
if (!draggedItem)
|
|
142
|
+
return null;
|
|
143
|
+
if (draggedItem.type === 'move-component' && draggedItem.component) {
|
|
144
|
+
return (_jsx("div", { className: styles.dragGhost, children: _jsx(ComponentRenderer, { component: draggedItem.component, isSelected: false, isHovered: false }) }));
|
|
145
|
+
}
|
|
146
|
+
if (draggedItem.type === 'new-component') {
|
|
147
|
+
return (_jsx("div", { className: styles.dragGhost, children: _jsx("div", { className: styles.newComponentGhost, children: draggedItem.componentType }) }));
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
};
|
|
151
|
+
return (_jsxs(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragEnd: handleDragEnd, onDragCancel: handleDragCancel, children: [_jsx("div", { ref: canvasRef, className: styles.canvas, onClick: handleCanvasClick, "data-mode": mode, children: _jsxs("div", { className: styles.viewport, style: {
|
|
152
|
+
transform: `scale(${canvasZoom}) translate(${canvasOffset.x}px, ${canvasOffset.y}px)`,
|
|
153
|
+
transformOrigin: 'center center'
|
|
154
|
+
}, children: [showGrid && (_jsx("div", { className: styles.grid, style: {
|
|
155
|
+
backgroundSize: `${gridSize}px ${gridSize}px`
|
|
156
|
+
} })), _jsx("div", { className: styles.componentContainer, children: _jsx(DropZone, { id: "root-drop-zone", componentId: rootId, accepts: ['all'], showIndicator: mode === 'edit', children: _jsx(DraggableComponent, { component: rootComponent, isRoot: true, isSelected: selectedIds.has(rootId), isHovered: hoveredId === rootId, onSelect: (id) => selectComponent(id), onHover: (id) => setHoveredComponent(id) }) }) }), selectedIds.size > 0 && (_jsx("div", { className: styles.selectionOverlay }))] }) }), _jsx(DragOverlay, { children: renderDragOverlay() })] }));
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=CanvasWithDnd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanvasWithDnd.js","sourceRoot":"","sources":["../../../../playground/components/Canvas/CanvasWithDnd.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAW,MAAM,OAAO,CAAC;AACvE,OAAO,EACL,UAAU,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,SAAS,EACT,UAAU,EAKX,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAMzC,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACzE,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,kBAAkB,GAAG,MAAM,CAAyB,IAAI,CAAC,CAAC;IAEhE,MAAM,KAAK,GAAG,kBAAkB,EAAE,CAAC;IACnC,MAAM,EACJ,UAAU,EACV,MAAM,EACN,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,I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AAE,GACR,IACH,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComponentRenderer - Renders playground components recursively
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import type { PlaygroundComponent } from '../../types';
|
|
6
|
+
export interface ComponentRendererProps {
|
|
7
|
+
component: PlaygroundComponent;
|
|
8
|
+
isRoot?: boolean;
|
|
9
|
+
isSelected?: boolean;
|
|
10
|
+
isHovered?: boolean;
|
|
11
|
+
onSelect?: (id: string) => void;
|
|
12
|
+
onHover?: (id: string | null) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ComponentRenderer: React.FC<ComponentRendererProps>;
|
|
15
|
+
//# sourceMappingURL=ComponentRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentRenderer.d.ts","sourceRoot":"","sources":["../../../../playground/components/Canvas/ComponentRenderer.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAA+B,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACvC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAmS9D,CAAC"}
|