@tpitre/story-ui 3.3.0 → 3.4.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.d.ts +18 -0
- package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/hybridStories.js +216 -0
- package/dist/mcp-server/routes/hybridStories.js.map +1 -0
- package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
- package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/memoryStories.js +158 -0
- package/dist/mcp-server/routes/memoryStories.js.map +1 -0
- package/dist/mcp-server/routes/storySync.d.ts +26 -0
- package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
- package/dist/mcp-server/routes/storySync.js +147 -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.d.ts +50 -0
- package/dist/mcp-server/sessionManager.d.ts.map +1 -0
- package/dist/mcp-server/sessionManager.js +125 -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.d.ts +89 -0
- package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
- package/dist/story-generator/inMemoryStoryService.js +128 -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/postgresStoryService.d.ts +56 -0
- package/dist/story-generator/postgresStoryService.d.ts.map +1 -0
- package/dist/story-generator/postgresStoryService.js +240 -0
- package/dist/story-generator/productionGitignoreManager.d.ts +91 -0
- package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
- package/dist/story-generator/productionGitignoreManager.js +340 -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/storyServiceFactory.d.ts +22 -0
- package/dist/story-generator/storyServiceFactory.d.ts.map +1 -0
- package/dist/story-generator/storyServiceFactory.js +97 -0
- package/dist/story-generator/storyServiceInterface.d.ts +85 -0
- package/dist/story-generator/storyServiceInterface.d.ts.map +1 -0
- package/dist/story-generator/storyServiceInterface.js +5 -0
- package/dist/story-generator/storySync.d.ts +68 -0
- package/dist/story-generator/storySync.d.ts.map +1 -0
- package/dist/story-generator/storySync.js +201 -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/package.json +1 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zustand store for Playground state management
|
|
3
|
+
*/
|
|
4
|
+
import { create } from 'zustand';
|
|
5
|
+
import { devtools } from 'zustand/middleware';
|
|
6
|
+
import { immer } from 'zustand/middleware/immer';
|
|
7
|
+
import { enableMapSet } from 'immer';
|
|
8
|
+
// Enable MapSet plugin for Immer to support Map and Set objects
|
|
9
|
+
enableMapSet();
|
|
10
|
+
const initialState = {
|
|
11
|
+
// Component State
|
|
12
|
+
components: new Map([
|
|
13
|
+
['root', {
|
|
14
|
+
id: 'root',
|
|
15
|
+
type: 'Container',
|
|
16
|
+
displayName: 'Root Container',
|
|
17
|
+
props: {},
|
|
18
|
+
children: [],
|
|
19
|
+
style: {
|
|
20
|
+
width: '100%',
|
|
21
|
+
minHeight: '100vh',
|
|
22
|
+
padding: '20px'
|
|
23
|
+
}
|
|
24
|
+
}]
|
|
25
|
+
]),
|
|
26
|
+
rootId: 'root',
|
|
27
|
+
// Selection State
|
|
28
|
+
selectedIds: new Set(),
|
|
29
|
+
hoveredId: null,
|
|
30
|
+
focusedId: null,
|
|
31
|
+
// Drag State
|
|
32
|
+
draggedItem: null,
|
|
33
|
+
dropZones: new Map(),
|
|
34
|
+
dragState: 'idle',
|
|
35
|
+
// UI State
|
|
36
|
+
mode: 'edit',
|
|
37
|
+
sidebarTab: 'ai',
|
|
38
|
+
propertiesPanelOpen: true,
|
|
39
|
+
canvasZoom: 1,
|
|
40
|
+
canvasOffset: { x: 0, y: 0 },
|
|
41
|
+
showGrid: true,
|
|
42
|
+
snapToGrid: true,
|
|
43
|
+
gridSize: 8,
|
|
44
|
+
// History
|
|
45
|
+
history: [],
|
|
46
|
+
historyIndex: -1,
|
|
47
|
+
maxHistorySize: 50,
|
|
48
|
+
// AI Integration
|
|
49
|
+
generatedStoryCode: null,
|
|
50
|
+
isParsingStory: false,
|
|
51
|
+
parseError: null,
|
|
52
|
+
// Component Registry
|
|
53
|
+
availableComponents: [],
|
|
54
|
+
loadingComponents: new Set(),
|
|
55
|
+
failedComponents: new Map()
|
|
56
|
+
};
|
|
57
|
+
export const usePlaygroundStore = create()(devtools(immer((set, get) => ({
|
|
58
|
+
...initialState,
|
|
59
|
+
// Component Actions
|
|
60
|
+
addComponent: (component) => set((state) => {
|
|
61
|
+
state.components.set(component.id, component);
|
|
62
|
+
// Add to parent's children if specified
|
|
63
|
+
if (component.parentId) {
|
|
64
|
+
const parent = state.components.get(component.parentId);
|
|
65
|
+
if (parent) {
|
|
66
|
+
if (!parent.children)
|
|
67
|
+
parent.children = [];
|
|
68
|
+
parent.children.push(component.id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Save snapshot after adding
|
|
72
|
+
get().saveSnapshot('Add component');
|
|
73
|
+
}),
|
|
74
|
+
updateComponent: (id, updates) => {
|
|
75
|
+
set((state) => {
|
|
76
|
+
const component = state.components.get(id);
|
|
77
|
+
if (component) {
|
|
78
|
+
Object.assign(component, updates);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Only save snapshot for significant changes, not every keystroke
|
|
82
|
+
const significantChanges = ['style', 'props', 'textContent', 'hidden'];
|
|
83
|
+
if (Object.keys(updates).some(key => significantChanges.includes(key))) {
|
|
84
|
+
// Debounce snapshot saving to avoid too many snapshots
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
get().saveSnapshot('Update component');
|
|
87
|
+
}, 500);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
deleteComponent: (id) => set((state) => {
|
|
91
|
+
const component = state.components.get(id);
|
|
92
|
+
if (!component || id === state.rootId)
|
|
93
|
+
return;
|
|
94
|
+
// Remove from parent's children
|
|
95
|
+
if (component.parentId) {
|
|
96
|
+
const parent = state.components.get(component.parentId);
|
|
97
|
+
if (parent && parent.children) {
|
|
98
|
+
parent.children = parent.children.filter(childId => childId !== id);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Delete component and all its children recursively
|
|
102
|
+
const deleteRecursive = (compId) => {
|
|
103
|
+
const comp = state.components.get(compId);
|
|
104
|
+
if (comp?.children) {
|
|
105
|
+
comp.children.forEach(childId => deleteRecursive(childId));
|
|
106
|
+
}
|
|
107
|
+
state.components.delete(compId);
|
|
108
|
+
};
|
|
109
|
+
deleteRecursive(id);
|
|
110
|
+
state.selectedIds.delete(id);
|
|
111
|
+
// Save snapshot after deletion
|
|
112
|
+
get().saveSnapshot('Delete component');
|
|
113
|
+
}),
|
|
114
|
+
moveComponent: (id, newParentId, index) => set((state) => {
|
|
115
|
+
const component = state.components.get(id);
|
|
116
|
+
const newParent = state.components.get(newParentId);
|
|
117
|
+
if (!component || !newParent)
|
|
118
|
+
return;
|
|
119
|
+
// Remove from old parent
|
|
120
|
+
if (component.parentId) {
|
|
121
|
+
const oldParent = state.components.get(component.parentId);
|
|
122
|
+
if (oldParent?.children) {
|
|
123
|
+
oldParent.children = oldParent.children.filter(childId => childId !== id);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Add to new parent
|
|
127
|
+
if (!newParent.children)
|
|
128
|
+
newParent.children = [];
|
|
129
|
+
newParent.children.splice(index, 0, id);
|
|
130
|
+
component.parentId = newParentId;
|
|
131
|
+
// Save snapshot after move
|
|
132
|
+
get().saveSnapshot('Move component');
|
|
133
|
+
}),
|
|
134
|
+
duplicateComponent: (id) => {
|
|
135
|
+
const state = get();
|
|
136
|
+
const component = state.components.get(id);
|
|
137
|
+
if (!component)
|
|
138
|
+
return '';
|
|
139
|
+
const duplicateRecursive = (comp, newParentId) => {
|
|
140
|
+
const newId = `${comp.type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
141
|
+
const duplicate = {
|
|
142
|
+
...comp,
|
|
143
|
+
id: newId,
|
|
144
|
+
parentId: newParentId ?? comp.parentId,
|
|
145
|
+
children: comp.children?.map(childId => {
|
|
146
|
+
const childComp = state.components.get(childId);
|
|
147
|
+
if (childComp) {
|
|
148
|
+
const duplicatedChild = duplicateRecursive(childComp, newId);
|
|
149
|
+
state.components.set(duplicatedChild.id, duplicatedChild);
|
|
150
|
+
return duplicatedChild.id;
|
|
151
|
+
}
|
|
152
|
+
return childId;
|
|
153
|
+
})
|
|
154
|
+
};
|
|
155
|
+
return duplicate;
|
|
156
|
+
};
|
|
157
|
+
const duplicate = duplicateRecursive(component, component.parentId);
|
|
158
|
+
state.addComponent(duplicate);
|
|
159
|
+
return duplicate.id;
|
|
160
|
+
},
|
|
161
|
+
clearComponents: () => set((state) => {
|
|
162
|
+
state.components.clear();
|
|
163
|
+
state.selectedIds.clear();
|
|
164
|
+
state.hoveredId = null;
|
|
165
|
+
state.focusedId = null;
|
|
166
|
+
// Save snapshot after clearing
|
|
167
|
+
get().saveSnapshot('Clear components');
|
|
168
|
+
}),
|
|
169
|
+
// Selection Actions
|
|
170
|
+
selectComponent: (id, multi = false) => set((state) => {
|
|
171
|
+
if (multi) {
|
|
172
|
+
if (state.selectedIds.has(id)) {
|
|
173
|
+
state.selectedIds.delete(id);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
state.selectedIds.add(id);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
state.selectedIds.clear();
|
|
181
|
+
state.selectedIds.add(id);
|
|
182
|
+
}
|
|
183
|
+
state.focusedId = id;
|
|
184
|
+
// Open properties panel when selecting a component
|
|
185
|
+
if (!state.propertiesPanelOpen && state.selectedIds.size > 0) {
|
|
186
|
+
state.propertiesPanelOpen = true;
|
|
187
|
+
}
|
|
188
|
+
}),
|
|
189
|
+
deselectComponent: (id) => set((state) => {
|
|
190
|
+
state.selectedIds.delete(id);
|
|
191
|
+
if (state.focusedId === id) {
|
|
192
|
+
state.focusedId = null;
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
selectAll: () => set((state) => {
|
|
196
|
+
state.components.forEach((_, id) => {
|
|
197
|
+
if (id !== state.rootId) {
|
|
198
|
+
state.selectedIds.add(id);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}),
|
|
202
|
+
deselectAll: () => set((state) => {
|
|
203
|
+
state.selectedIds.clear();
|
|
204
|
+
state.focusedId = null;
|
|
205
|
+
}),
|
|
206
|
+
setHoveredComponent: (id) => set((state) => {
|
|
207
|
+
state.hoveredId = id;
|
|
208
|
+
}),
|
|
209
|
+
// Drag Actions
|
|
210
|
+
startDrag: (item) => set((state) => {
|
|
211
|
+
state.draggedItem = item;
|
|
212
|
+
state.dragState = 'dragging';
|
|
213
|
+
}),
|
|
214
|
+
updateDrag: (updates) => set((state) => {
|
|
215
|
+
if (state.draggedItem) {
|
|
216
|
+
Object.assign(state.draggedItem, updates);
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
endDrag: () => set((state) => {
|
|
220
|
+
state.draggedItem = null;
|
|
221
|
+
state.dragState = 'idle';
|
|
222
|
+
}),
|
|
223
|
+
registerDropZone: (zone) => set((state) => {
|
|
224
|
+
state.dropZones.set(zone.id, zone);
|
|
225
|
+
}),
|
|
226
|
+
unregisterDropZone: (id) => set((state) => {
|
|
227
|
+
state.dropZones.delete(id);
|
|
228
|
+
}),
|
|
229
|
+
updateDropZone: (id, updates) => set((state) => {
|
|
230
|
+
const zone = state.dropZones.get(id);
|
|
231
|
+
if (zone) {
|
|
232
|
+
Object.assign(zone, updates);
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
235
|
+
// UI Actions
|
|
236
|
+
setMode: (mode) => set({ mode }),
|
|
237
|
+
setSidebarTab: (tab) => set({ sidebarTab: tab }),
|
|
238
|
+
togglePropertiesPanel: () => set((state) => {
|
|
239
|
+
state.propertiesPanelOpen = !state.propertiesPanelOpen;
|
|
240
|
+
}),
|
|
241
|
+
setCanvasZoom: (zoom) => set((state) => {
|
|
242
|
+
state.canvasZoom = Math.min(Math.max(zoom, 0.25), 4);
|
|
243
|
+
}),
|
|
244
|
+
panCanvas: (dx, dy) => set((state) => {
|
|
245
|
+
state.canvasOffset.x += dx;
|
|
246
|
+
state.canvasOffset.y += dy;
|
|
247
|
+
}),
|
|
248
|
+
resetCanvas: () => set((state) => {
|
|
249
|
+
state.canvasZoom = 1;
|
|
250
|
+
state.canvasOffset = { x: 0, y: 0 };
|
|
251
|
+
}),
|
|
252
|
+
toggleGrid: () => set((state) => {
|
|
253
|
+
state.showGrid = !state.showGrid;
|
|
254
|
+
}),
|
|
255
|
+
toggleSnapToGrid: () => set((state) => {
|
|
256
|
+
state.snapToGrid = !state.snapToGrid;
|
|
257
|
+
}),
|
|
258
|
+
setGridSize: (size) => set({ gridSize: size }),
|
|
259
|
+
// History Actions
|
|
260
|
+
undo: () => set((state) => {
|
|
261
|
+
if (state.historyIndex > 0) {
|
|
262
|
+
state.historyIndex--;
|
|
263
|
+
const snapshot = state.history[state.historyIndex];
|
|
264
|
+
state.components = new Map(snapshot.components);
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
redo: () => set((state) => {
|
|
268
|
+
if (state.historyIndex < state.history.length - 1) {
|
|
269
|
+
state.historyIndex++;
|
|
270
|
+
const snapshot = state.history[state.historyIndex];
|
|
271
|
+
state.components = new Map(snapshot.components);
|
|
272
|
+
}
|
|
273
|
+
}),
|
|
274
|
+
saveSnapshot: (description) => set((state) => {
|
|
275
|
+
const snapshot = {
|
|
276
|
+
components: new Map(state.components),
|
|
277
|
+
timestamp: Date.now(),
|
|
278
|
+
description
|
|
279
|
+
};
|
|
280
|
+
// Remove any history after current index
|
|
281
|
+
state.history = state.history.slice(0, state.historyIndex + 1);
|
|
282
|
+
// Add new snapshot
|
|
283
|
+
state.history.push(snapshot);
|
|
284
|
+
// Limit history size
|
|
285
|
+
if (state.history.length > state.maxHistorySize) {
|
|
286
|
+
state.history.shift();
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
state.historyIndex++;
|
|
290
|
+
}
|
|
291
|
+
}),
|
|
292
|
+
clearHistory: () => set((state) => {
|
|
293
|
+
state.history = [];
|
|
294
|
+
state.historyIndex = -1;
|
|
295
|
+
}),
|
|
296
|
+
// AI Actions
|
|
297
|
+
setGeneratedStoryCode: (code) => set({ generatedStoryCode: code }),
|
|
298
|
+
setIsParsingStory: (parsing) => set({ isParsingStory: parsing }),
|
|
299
|
+
setParseError: (error) => set({ parseError: error }),
|
|
300
|
+
loadComponentsFromStory: (components) => set((state) => {
|
|
301
|
+
// Clear existing components except root
|
|
302
|
+
state.components.clear();
|
|
303
|
+
state.components.set('root', initialState.components.get('root'));
|
|
304
|
+
// Add new components
|
|
305
|
+
components.forEach(component => {
|
|
306
|
+
state.components.set(component.id, component);
|
|
307
|
+
});
|
|
308
|
+
// Update root's children
|
|
309
|
+
const root = state.components.get('root');
|
|
310
|
+
if (root) {
|
|
311
|
+
root.children = components.filter(c => !c.parentId || c.parentId === 'root').map(c => c.id);
|
|
312
|
+
}
|
|
313
|
+
// Clear selection
|
|
314
|
+
state.selectedIds.clear();
|
|
315
|
+
// Save snapshot
|
|
316
|
+
get().saveSnapshot('Load from AI generation');
|
|
317
|
+
}),
|
|
318
|
+
// Component Registry Actions
|
|
319
|
+
setAvailableComponents: (components) => set({ availableComponents: components }),
|
|
320
|
+
addLoadingComponent: (name) => set((state) => {
|
|
321
|
+
state.loadingComponents.add(name);
|
|
322
|
+
}),
|
|
323
|
+
removeLoadingComponent: (name) => set((state) => {
|
|
324
|
+
state.loadingComponents.delete(name);
|
|
325
|
+
}),
|
|
326
|
+
setComponentError: (name, error) => set((state) => {
|
|
327
|
+
state.failedComponents.set(name, error);
|
|
328
|
+
}),
|
|
329
|
+
// Utility Actions
|
|
330
|
+
reset: () => set(initialState),
|
|
331
|
+
loadFromSnapshot: (snapshot) => set((state) => {
|
|
332
|
+
state.components = new Map(snapshot.components);
|
|
333
|
+
state.selectedIds.clear();
|
|
334
|
+
get().saveSnapshot('Load from snapshot');
|
|
335
|
+
})
|
|
336
|
+
})), { name: 'playground-store' }));
|
|
337
|
+
//# sourceMappingURL=playgroundStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playgroundStore.js","sourceRoot":"","sources":["../../../playground/store/playgroundStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,gEAAgE;AAChE,YAAY,EAAE,CAAC;AA8Gf,MAAM,YAAY,GAAoB;IACpC,kBAAkB;IAClB,UAAU,EAAE,IAAI,GAAG,CAAC;QAClB,CAAC,MAAM,EAAE;gBACP,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,gBAAgB;gBAC7B,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE,EAAE;gBACZ,KAAK,EAAE;oBACL,KAAK,EAAE,MAAM;oBACb,SAAS,EAAE,OAAO;oBAClB,OAAO,EA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IACpC,CAAC,CAAC;IACF,sBAAsB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9C,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC;IACF,iBAAiB,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,kBAAkB;IAClB,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC;IAE9B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5C,KAAK,CAAC,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChD,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC1B,GAAG,EAAE,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC3C,CAAC,CAAC;CACH,CAAC,CAAC,EACH,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAC7B,CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storybook stories for testing Playground drag & drop functionality
|
|
3
|
+
*/
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { Playground } from '../components/Playground/Playground';
|
|
6
|
+
declare const meta: Meta<typeof Playground>;
|
|
7
|
+
export default meta;
|
|
8
|
+
type Story = StoryObj<typeof Playground>;
|
|
9
|
+
export declare const BasicDragDrop: Story;
|
|
10
|
+
export declare const EmptyCanvas: Story;
|
|
11
|
+
export declare const WithAIAssistant: Story;
|
|
12
|
+
export declare const NestedComponents: Story;
|
|
13
|
+
//# sourceMappingURL=PlaygroundDragDrop.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundDragDrop.stories.d.ts","sourceRoot":"","sources":["../../../playground/stories/PlaygroundDragDrop.stories.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGjE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAMjC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;AA+FzC,eAAO,MAAM,aAAa,EAAE,KAgB3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAkBzB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAkB7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAsF9B,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Storybook stories for testing Playground drag & drop functionality
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Playground } from '../components/Playground/Playground';
|
|
7
|
+
import { usePlaygroundStore } from '../store/playgroundStore';
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'StoryUI/Playground/DragDrop',
|
|
10
|
+
component: Playground,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'fullscreen',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
// Helper to initialize the store with test data
|
|
17
|
+
const initializeWithTestData = () => {
|
|
18
|
+
const store = usePlaygroundStore.getState();
|
|
19
|
+
// Clear existing components
|
|
20
|
+
store.components.clear();
|
|
21
|
+
// Add root container
|
|
22
|
+
store.addComponent({
|
|
23
|
+
id: 'root',
|
|
24
|
+
type: 'Container',
|
|
25
|
+
displayName: 'Root Container',
|
|
26
|
+
props: {
|
|
27
|
+
style: {
|
|
28
|
+
padding: '20px',
|
|
29
|
+
minHeight: '100vh',
|
|
30
|
+
background: '#f5f5f5'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
children: []
|
|
34
|
+
});
|
|
35
|
+
// Add a few test components
|
|
36
|
+
store.addComponent({
|
|
37
|
+
id: 'card1',
|
|
38
|
+
type: 'Card',
|
|
39
|
+
displayName: 'Sample Card',
|
|
40
|
+
parentId: 'root',
|
|
41
|
+
props: {
|
|
42
|
+
style: {
|
|
43
|
+
padding: '16px',
|
|
44
|
+
background: 'white',
|
|
45
|
+
borderRadius: '8px',
|
|
46
|
+
marginBottom: '16px',
|
|
47
|
+
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
children: []
|
|
51
|
+
});
|
|
52
|
+
store.addComponent({
|
|
53
|
+
id: 'text1',
|
|
54
|
+
type: 'Text',
|
|
55
|
+
displayName: 'Sample Text',
|
|
56
|
+
parentId: 'card1',
|
|
57
|
+
textContent: 'This is a draggable text component',
|
|
58
|
+
props: {
|
|
59
|
+
style: {
|
|
60
|
+
fontSize: '16px',
|
|
61
|
+
color: '#333'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
store.addComponent({
|
|
66
|
+
id: 'button1',
|
|
67
|
+
type: 'Button',
|
|
68
|
+
displayName: 'Sample Button',
|
|
69
|
+
parentId: 'root',
|
|
70
|
+
textContent: 'Click Me',
|
|
71
|
+
props: {
|
|
72
|
+
style: {
|
|
73
|
+
padding: '8px 16px',
|
|
74
|
+
background: '#3b82f6',
|
|
75
|
+
color: 'white',
|
|
76
|
+
border: 'none',
|
|
77
|
+
borderRadius: '6px',
|
|
78
|
+
cursor: 'pointer'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
// Update root children
|
|
83
|
+
const root = store.components.get('root');
|
|
84
|
+
if (root) {
|
|
85
|
+
root.children = ['card1', 'button1'];
|
|
86
|
+
store.components.set('root', root);
|
|
87
|
+
}
|
|
88
|
+
// Update card children
|
|
89
|
+
const card = store.components.get('card1');
|
|
90
|
+
if (card) {
|
|
91
|
+
card.children = ['text1'];
|
|
92
|
+
store.components.set('card1', card);
|
|
93
|
+
}
|
|
94
|
+
// Set mode to edit
|
|
95
|
+
store.setMode('edit');
|
|
96
|
+
// Open component palette
|
|
97
|
+
store.setSidebarTab('components');
|
|
98
|
+
};
|
|
99
|
+
export const BasicDragDrop = {
|
|
100
|
+
render: () => {
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
initializeWithTestData();
|
|
103
|
+
}, []);
|
|
104
|
+
return _jsx(Playground, { initialMode: "edit" });
|
|
105
|
+
},
|
|
106
|
+
name: 'Basic Drag & Drop',
|
|
107
|
+
parameters: {
|
|
108
|
+
docs: {
|
|
109
|
+
description: {
|
|
110
|
+
story: 'Test drag & drop functionality with pre-populated components. Try dragging components from the palette or rearranging existing components.'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export const EmptyCanvas = {
|
|
116
|
+
render: () => {
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
const store = usePlaygroundStore.getState();
|
|
119
|
+
store.setMode('edit');
|
|
120
|
+
store.setSidebarTab('components');
|
|
121
|
+
}, []);
|
|
122
|
+
return _jsx(Playground, { initialMode: "edit" });
|
|
123
|
+
},
|
|
124
|
+
name: 'Empty Canvas',
|
|
125
|
+
parameters: {
|
|
126
|
+
docs: {
|
|
127
|
+
description: {
|
|
128
|
+
story: 'Start with an empty canvas. Drag components from the palette to build your layout.'
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
export const WithAIAssistant = {
|
|
134
|
+
render: () => {
|
|
135
|
+
React.useEffect(() => {
|
|
136
|
+
const store = usePlaygroundStore.getState();
|
|
137
|
+
store.setMode('edit');
|
|
138
|
+
store.setSidebarTab('ai');
|
|
139
|
+
}, []);
|
|
140
|
+
return _jsx(Playground, { initialMode: "edit" });
|
|
141
|
+
},
|
|
142
|
+
name: 'With AI Assistant',
|
|
143
|
+
parameters: {
|
|
144
|
+
docs: {
|
|
145
|
+
description: {
|
|
146
|
+
story: 'Use the AI Assistant to generate a layout, then drag & drop to refine it.'
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
export const NestedComponents = {
|
|
152
|
+
render: () => {
|
|
153
|
+
React.useEffect(() => {
|
|
154
|
+
const store = usePlaygroundStore.getState();
|
|
155
|
+
// Clear and create nested structure
|
|
156
|
+
store.components.clear();
|
|
157
|
+
// Root
|
|
158
|
+
store.addComponent({
|
|
159
|
+
id: 'root',
|
|
160
|
+
type: 'Container',
|
|
161
|
+
displayName: 'Root',
|
|
162
|
+
props: { style: { padding: '20px', minHeight: '100vh' } },
|
|
163
|
+
children: []
|
|
164
|
+
});
|
|
165
|
+
// Main container
|
|
166
|
+
store.addComponent({
|
|
167
|
+
id: 'main',
|
|
168
|
+
type: 'Box',
|
|
169
|
+
displayName: 'Main Container',
|
|
170
|
+
parentId: 'root',
|
|
171
|
+
props: { style: { padding: '20px', background: '#fff' } },
|
|
172
|
+
children: []
|
|
173
|
+
});
|
|
174
|
+
// Nested containers
|
|
175
|
+
store.addComponent({
|
|
176
|
+
id: 'row1',
|
|
177
|
+
type: 'HStack',
|
|
178
|
+
displayName: 'Row 1',
|
|
179
|
+
parentId: 'main',
|
|
180
|
+
props: { style: { gap: '16px', marginBottom: '16px' } },
|
|
181
|
+
children: []
|
|
182
|
+
});
|
|
183
|
+
store.addComponent({
|
|
184
|
+
id: 'col1',
|
|
185
|
+
type: 'Box',
|
|
186
|
+
displayName: 'Column 1',
|
|
187
|
+
parentId: 'row1',
|
|
188
|
+
props: { style: { flex: 1, padding: '12px', background: '#f0f0f0' } },
|
|
189
|
+
children: []
|
|
190
|
+
});
|
|
191
|
+
store.addComponent({
|
|
192
|
+
id: 'col2',
|
|
193
|
+
type: 'Box',
|
|
194
|
+
displayName: 'Column 2',
|
|
195
|
+
parentId: 'row1',
|
|
196
|
+
props: { style: { flex: 1, padding: '12px', background: '#f0f0f0' } },
|
|
197
|
+
children: []
|
|
198
|
+
});
|
|
199
|
+
// Build tree structure
|
|
200
|
+
const root = store.components.get('root');
|
|
201
|
+
const main = store.components.get('main');
|
|
202
|
+
const row1 = store.components.get('row1');
|
|
203
|
+
const col1 = store.components.get('col1');
|
|
204
|
+
const col2 = store.components.get('col2');
|
|
205
|
+
if (root && main && row1 && col1 && col2) {
|
|
206
|
+
row1.children = ['col1', 'col2'];
|
|
207
|
+
main.children = ['row1'];
|
|
208
|
+
root.children = ['main'];
|
|
209
|
+
store.components.set('row1', row1);
|
|
210
|
+
store.components.set('main', main);
|
|
211
|
+
store.components.set('root', root);
|
|
212
|
+
}
|
|
213
|
+
store.setMode('edit');
|
|
214
|
+
store.setSidebarTab('components');
|
|
215
|
+
}, []);
|
|
216
|
+
return _jsx(Playground, { initialMode: "edit" });
|
|
217
|
+
},
|
|
218
|
+
name: 'Nested Components',
|
|
219
|
+
parameters: {
|
|
220
|
+
docs: {
|
|
221
|
+
description: {
|
|
222
|
+
story: 'Test drag & drop with deeply nested component structures.'
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
//# sourceMappingURL=PlaygroundDragDrop.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundDragDrop.stories.js","sourceRoot":"","sources":["../../../playground/stories/PlaygroundDragDrop.stories.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,kBA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CAAC;gBACnC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACrC,CAAC;YAED,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtB,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,KAAC,UAAU,IAAC,WAAW,EAAC,MAAM,GAAG,CAAC;IAC3C,CAAC;IACD,IAAI,EAAE,mBAAmB;IACzB,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,KAAK,EAAE,2DAA2D;aACnE;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storybook stories for testing Phase 4 features
|
|
3
|
+
*/
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { Playground } from '../components/Playground/Playground';
|
|
6
|
+
declare const meta: Meta<typeof Playground>;
|
|
7
|
+
export default meta;
|
|
8
|
+
type Story = StoryObj<typeof Playground>;
|
|
9
|
+
export declare const ComponentSearch: Story;
|
|
10
|
+
export declare const LayoutHelpers: Story;
|
|
11
|
+
export declare const TreeView: Story;
|
|
12
|
+
export declare const CompletePhase4: Story;
|
|
13
|
+
//# sourceMappingURL=PlaygroundPhase4.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundPhase4.stories.d.ts","sourceRoot":"","sources":["../../../playground/stories/PlaygroundPhase4.stories.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGjE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAMjC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;AA8QzC,eAAO,MAAM,eAAe,EAAE,KAkB7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAkB3B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAkBtB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAuB5B,CAAC"}
|