@tpitre/story-ui 2.7.1 → 2.8.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.
Files changed (289) hide show
  1. package/README.md +40 -9
  2. package/dist/cli/deploy.d.ts +1 -1
  3. package/dist/cli/deploy.d.ts.map +1 -1
  4. package/dist/cli/deploy.js +5 -115
  5. package/dist/cli/index.js +0 -0
  6. package/dist/cli/setup.js +3 -3
  7. package/package.json +1 -1
  8. package/dist/cli/index.js.map +0 -1
  9. package/dist/cli/setup.js.map +0 -1
  10. package/dist/cloudflare-edge/src/mcp-session.js +0 -462
  11. package/dist/cloudflare-edge/src/types.js +0 -4
  12. package/dist/cloudflare-edge/src/worker.js +0 -106
  13. package/dist/cloudflare-pages/vite.config.js +0 -14
  14. package/dist/index.d.ts +0 -13
  15. package/dist/index.d.ts.map +0 -1
  16. package/dist/index.js +0 -12
  17. package/dist/index.js.map +0 -1
  18. package/dist/mcp-server/index.js.map +0 -1
  19. package/dist/mcp-server/mcp-stdio-server.js.map +0 -1
  20. package/dist/mcp-server/routes/claude.js.map +0 -1
  21. package/dist/mcp-server/routes/components.js.map +0 -1
  22. package/dist/mcp-server/routes/generateStory.js.map +0 -1
  23. package/dist/mcp-server/routes/hybridStories.js.map +0 -1
  24. package/dist/mcp-server/routes/memoryStories.js.map +0 -1
  25. package/dist/mcp-server/routes/storySync.js.map +0 -1
  26. package/dist/mcp-server/routes/updateStory.js +0 -246
  27. package/dist/mcp-server/sessionManager.js.map +0 -1
  28. package/dist/playground/components/AIAssistant/AIAssistant.d.ts +0 -6
  29. package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +0 -1
  30. package/dist/playground/components/AIAssistant/AIAssistant.js +0 -109
  31. package/dist/playground/components/AIAssistant/AIAssistant.js.map +0 -1
  32. package/dist/playground/components/AIAssistant/AIAssistant.module.css +0 -166
  33. package/dist/playground/components/Canvas/Canvas.d.ts +0 -9
  34. package/dist/playground/components/Canvas/Canvas.d.ts.map +0 -1
  35. package/dist/playground/components/Canvas/Canvas.js +0 -58
  36. package/dist/playground/components/Canvas/Canvas.js.map +0 -1
  37. package/dist/playground/components/Canvas/Canvas.module.css +0 -189
  38. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +0 -9
  39. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +0 -1
  40. package/dist/playground/components/Canvas/CanvasWithDnd.js +0 -158
  41. package/dist/playground/components/Canvas/CanvasWithDnd.js.map +0 -1
  42. package/dist/playground/components/Canvas/ComponentRenderer.d.ts +0 -15
  43. package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +0 -1
  44. package/dist/playground/components/Canvas/ComponentRenderer.js +0 -177
  45. package/dist/playground/components/Canvas/ComponentRenderer.js.map +0 -1
  46. package/dist/playground/components/Canvas/DraggableComponent.d.ts +0 -15
  47. package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +0 -1
  48. package/dist/playground/components/Canvas/DraggableComponent.js +0 -49
  49. package/dist/playground/components/Canvas/DraggableComponent.js.map +0 -1
  50. package/dist/playground/components/Canvas/index.d.ts +0 -9
  51. package/dist/playground/components/Canvas/index.d.ts.map +0 -1
  52. package/dist/playground/components/Canvas/index.js +0 -5
  53. package/dist/playground/components/Canvas/index.js.map +0 -1
  54. package/dist/playground/components/CodeView/CodeView.d.ts +0 -12
  55. package/dist/playground/components/CodeView/CodeView.d.ts.map +0 -1
  56. package/dist/playground/components/CodeView/CodeView.js +0 -77
  57. package/dist/playground/components/CodeView/CodeView.js.map +0 -1
  58. package/dist/playground/components/CodeView/CodeView.module.css +0 -178
  59. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +0 -17
  60. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +0 -1
  61. package/dist/playground/components/ComponentPalette/ComponentPalette.js +0 -138
  62. package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +0 -1
  63. package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +0 -217
  64. package/dist/playground/components/ComponentPalette/index.d.ts +0 -3
  65. package/dist/playground/components/ComponentPalette/index.d.ts.map +0 -1
  66. package/dist/playground/components/ComponentPalette/index.js +0 -2
  67. package/dist/playground/components/ComponentPalette/index.js.map +0 -1
  68. package/dist/playground/components/DropZone/DropZone.d.ts +0 -17
  69. package/dist/playground/components/DropZone/DropZone.d.ts.map +0 -1
  70. package/dist/playground/components/DropZone/DropZone.js +0 -73
  71. package/dist/playground/components/DropZone/DropZone.js.map +0 -1
  72. package/dist/playground/components/DropZone/DropZone.module.css +0 -86
  73. package/dist/playground/components/ExportDialog/ExportDialog.d.ts +0 -10
  74. package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +0 -1
  75. package/dist/playground/components/ExportDialog/ExportDialog.js +0 -57
  76. package/dist/playground/components/ExportDialog/ExportDialog.js.map +0 -1
  77. package/dist/playground/components/ExportDialog/ExportDialog.module.css +0 -328
  78. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +0 -134
  79. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +0 -1
  80. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +0 -254
  81. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +0 -1
  82. package/dist/playground/components/LayoutHelpers/index.d.ts +0 -3
  83. package/dist/playground/components/LayoutHelpers/index.d.ts.map +0 -1
  84. package/dist/playground/components/LayoutHelpers/index.js +0 -2
  85. package/dist/playground/components/LayoutHelpers/index.js.map +0 -1
  86. package/dist/playground/components/Playground/Playground.d.ts +0 -10
  87. package/dist/playground/components/Playground/Playground.d.ts.map +0 -1
  88. package/dist/playground/components/Playground/Playground.js +0 -128
  89. package/dist/playground/components/Playground/Playground.js.map +0 -1
  90. package/dist/playground/components/Playground/Playground.module.css +0 -308
  91. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +0 -10
  92. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +0 -1
  93. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +0 -150
  94. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +0 -1
  95. package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +0 -155
  96. package/dist/playground/components/PropertiesPanel/index.d.ts +0 -3
  97. package/dist/playground/components/PropertiesPanel/index.d.ts.map +0 -1
  98. package/dist/playground/components/PropertiesPanel/index.js +0 -2
  99. package/dist/playground/components/PropertiesPanel/index.js.map +0 -1
  100. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +0 -12
  101. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +0 -1
  102. package/dist/playground/components/PropertyEditors/BooleanEditor.js +0 -14
  103. package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +0 -1
  104. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +0 -12
  105. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +0 -1
  106. package/dist/playground/components/PropertyEditors/ColorEditor.js +0 -62
  107. package/dist/playground/components/PropertyEditors/ColorEditor.js.map +0 -1
  108. package/dist/playground/components/PropertyEditors/IconEditor.d.ts +0 -12
  109. package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +0 -1
  110. package/dist/playground/components/PropertyEditors/IconEditor.js +0 -123
  111. package/dist/playground/components/PropertyEditors/IconEditor.js.map +0 -1
  112. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +0 -15
  113. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +0 -1
  114. package/dist/playground/components/PropertyEditors/NumberEditor.js +0 -46
  115. package/dist/playground/components/PropertyEditors/NumberEditor.js.map +0 -1
  116. package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +0 -432
  117. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +0 -19
  118. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +0 -1
  119. package/dist/playground/components/PropertyEditors/SelectEditor.js +0 -17
  120. package/dist/playground/components/PropertyEditors/SelectEditor.js.map +0 -1
  121. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +0 -19
  122. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +0 -1
  123. package/dist/playground/components/PropertyEditors/SpacingEditor.js +0 -162
  124. package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +0 -1
  125. package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +0 -214
  126. package/dist/playground/components/PropertyEditors/TextEditor.d.ts +0 -14
  127. package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +0 -1
  128. package/dist/playground/components/PropertyEditors/TextEditor.js +0 -38
  129. package/dist/playground/components/PropertyEditors/TextEditor.js.map +0 -1
  130. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +0 -23
  131. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +0 -1
  132. package/dist/playground/components/PropertyEditors/TokenEditor.js +0 -50
  133. package/dist/playground/components/PropertyEditors/TokenEditor.js.map +0 -1
  134. package/dist/playground/components/PropertyEditors/index.d.ts +0 -20
  135. package/dist/playground/components/PropertyEditors/index.d.ts.map +0 -1
  136. package/dist/playground/components/PropertyEditors/index.js +0 -12
  137. package/dist/playground/components/PropertyEditors/index.js.map +0 -1
  138. package/dist/playground/components/TreeView/TreeView.d.ts +0 -10
  139. package/dist/playground/components/TreeView/TreeView.d.ts.map +0 -1
  140. package/dist/playground/components/TreeView/TreeView.js +0 -146
  141. package/dist/playground/components/TreeView/TreeView.js.map +0 -1
  142. package/dist/playground/components/TreeView/TreeView.module.css +0 -214
  143. package/dist/playground/components/TreeView/index.d.ts +0 -3
  144. package/dist/playground/components/TreeView/index.d.ts.map +0 -1
  145. package/dist/playground/components/TreeView/index.js +0 -2
  146. package/dist/playground/components/TreeView/index.js.map +0 -1
  147. package/dist/playground/config/propertyDefinitions.d.ts +0 -73
  148. package/dist/playground/config/propertyDefinitions.d.ts.map +0 -1
  149. package/dist/playground/config/propertyDefinitions.js +0 -809
  150. package/dist/playground/config/propertyDefinitions.js.map +0 -1
  151. package/dist/playground/hooks/useKeyboardShortcuts.d.ts +0 -38
  152. package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +0 -1
  153. package/dist/playground/hooks/useKeyboardShortcuts.js +0 -191
  154. package/dist/playground/hooks/useKeyboardShortcuts.js.map +0 -1
  155. package/dist/playground/index.d.ts +0 -21
  156. package/dist/playground/index.d.ts.map +0 -1
  157. package/dist/playground/index.js +0 -23
  158. package/dist/playground/index.js.map +0 -1
  159. package/dist/playground/services/CodeGenerator.d.ts +0 -73
  160. package/dist/playground/services/CodeGenerator.d.ts.map +0 -1
  161. package/dist/playground/services/CodeGenerator.js +0 -359
  162. package/dist/playground/services/CodeGenerator.js.map +0 -1
  163. package/dist/playground/services/DragDropManager.d.ts +0 -95
  164. package/dist/playground/services/DragDropManager.d.ts.map +0 -1
  165. package/dist/playground/services/DragDropManager.js +0 -408
  166. package/dist/playground/services/DragDropManager.js.map +0 -1
  167. package/dist/playground/services/StoryParser.d.ts +0 -73
  168. package/dist/playground/services/StoryParser.d.ts.map +0 -1
  169. package/dist/playground/services/StoryParser.js +0 -419
  170. package/dist/playground/services/StoryParser.js.map +0 -1
  171. package/dist/playground/store/playgroundStore.d.ts +0 -86
  172. package/dist/playground/store/playgroundStore.d.ts.map +0 -1
  173. package/dist/playground/store/playgroundStore.js +0 -337
  174. package/dist/playground/store/playgroundStore.js.map +0 -1
  175. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +0 -13
  176. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +0 -1
  177. package/dist/playground/stories/PlaygroundDragDrop.stories.js +0 -227
  178. package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +0 -1
  179. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +0 -13
  180. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +0 -1
  181. package/dist/playground/stories/PlaygroundPhase4.stories.js +0 -334
  182. package/dist/playground/stories/PlaygroundPhase4.stories.js.map +0 -1
  183. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +0 -14
  184. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +0 -1
  185. package/dist/playground/stories/PlaygroundPhase5.stories.js +0 -512
  186. package/dist/playground/stories/PlaygroundPhase5.stories.js.map +0 -1
  187. package/dist/playground/stories/PlaygroundProperties.stories.d.ts +0 -13
  188. package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +0 -1
  189. package/dist/playground/stories/PlaygroundProperties.stories.js +0 -342
  190. package/dist/playground/stories/PlaygroundProperties.stories.js.map +0 -1
  191. package/dist/playground/types/index.d.ts +0 -251
  192. package/dist/playground/types/index.d.ts.map +0 -1
  193. package/dist/playground/types/index.js +0 -5
  194. package/dist/playground/types/index.js.map +0 -1
  195. package/dist/scripts/verify-framework-adapters.js +0 -105
  196. package/dist/story-generator/componentBlacklist.js.map +0 -1
  197. package/dist/story-generator/componentDiscovery.js.map +0 -1
  198. package/dist/story-generator/configLoader.js.map +0 -1
  199. package/dist/story-generator/considerationsLoader.js.map +0 -1
  200. package/dist/story-generator/documentation-sources.js.map +0 -1
  201. package/dist/story-generator/documentationLoader.js.map +0 -1
  202. package/dist/story-generator/dynamicPackageDiscovery.js.map +0 -1
  203. package/dist/story-generator/enhancedComponentDiscovery.js.map +0 -1
  204. package/dist/story-generator/generateStory.js.map +0 -1
  205. package/dist/story-generator/gitignoreManager.js.map +0 -1
  206. package/dist/story-generator/inMemoryStoryService.js.map +0 -1
  207. package/dist/story-generator/logger.js.map +0 -1
  208. package/dist/story-generator/postProcessStory.js.map +0 -1
  209. package/dist/story-generator/productionGitignoreManager.js.map +0 -1
  210. package/dist/story-generator/promptGenerator.js.map +0 -1
  211. package/dist/story-generator/providerPresets.d.ts +0 -54
  212. package/dist/story-generator/providerPresets.d.ts.map +0 -1
  213. package/dist/story-generator/providerPresets.js +0 -214
  214. package/dist/story-generator/storyHistory.js.map +0 -1
  215. package/dist/story-generator/storySync.js.map +0 -1
  216. package/dist/story-generator/storyTracker.js.map +0 -1
  217. package/dist/story-generator/storyValidator.js.map +0 -1
  218. package/dist/story-generator/test_validation.d.ts +0 -2
  219. package/dist/story-generator/test_validation.d.ts.map +0 -1
  220. package/dist/story-generator/test_validation.js +0 -51
  221. package/dist/story-generator/universalDesignSystemAdapter.js.map +0 -1
  222. package/dist/story-generator/urlRedirectService.js.map +0 -1
  223. package/dist/story-generator/validateStory.js.map +0 -1
  224. package/dist/story-ui.config.js.map +0 -1
  225. package/dist/story-ui.config.loader.d.ts +0 -36
  226. package/dist/story-ui.config.loader.d.ts.map +0 -1
  227. package/dist/story-ui.config.loader.js +0 -205
  228. package/dist/story-ui.config.loader.js.map +0 -1
  229. package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +0 -807
  230. package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +0 -37
  231. package/dist/temp/package/templates/StoryUI/index.js +0 -2
  232. package/dist/templates/StoryUI/StoryUIPanel.js.map +0 -1
  233. package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +0 -1
  234. package/dist/templates/StoryUI/index.js.map +0 -1
  235. package/dist/templates/StoryUI/manager.d.ts +0 -14
  236. package/dist/templates/StoryUI/manager.d.ts.map +0 -1
  237. package/dist/templates/production-app/src/App.d.ts +0 -10
  238. package/dist/templates/production-app/src/App.d.ts.map +0 -1
  239. package/dist/templates/production-app/src/App.js +0 -653
  240. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +0 -24
  241. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +0 -1
  242. package/dist/templates/production-app/src/LivePreviewRenderer.js +0 -199
  243. package/dist/templates/production-app/src/componentRegistry.d.ts +0 -20
  244. package/dist/templates/production-app/src/componentRegistry.d.ts.map +0 -1
  245. package/dist/templates/production-app/src/componentRegistry.js +0 -316
  246. package/dist/templates/production-app/src/main.d.ts +0 -9
  247. package/dist/templates/production-app/src/main.d.ts.map +0 -1
  248. package/dist/templates/production-app/src/main.js +0 -18
  249. package/dist/templates/production-app/vite.config.d.ts +0 -3
  250. package/dist/templates/production-app/vite.config.d.ts.map +0 -1
  251. package/dist/templates/production-app/vite.config.js +0 -71
  252. package/dist/test-storybooks/angular-material-storybook/src/main.js +0 -66
  253. package/dist/test-storybooks/chakra-storybook/vite.config.js +0 -6
  254. package/dist/test-storybooks/mantine-storybook/vite.config.js +0 -93
  255. package/dist/test-storybooks/web-components-shoelace/vite.config.js +0 -9
  256. package/dist/tsconfig.tsbuildinfo +0 -1
  257. package/dist/visual-builder/components/Canvas/Canvas.js +0 -70
  258. package/dist/visual-builder/components/Canvas/ComponentRenderer.js +0 -545
  259. package/dist/visual-builder/components/CodeExporter/CodeExporter.js +0 -25
  260. package/dist/visual-builder/components/CodeExporter/codeGenerator.js +0 -99
  261. package/dist/visual-builder/components/ComponentPalette/ComponentPalette.js +0 -8
  262. package/dist/visual-builder/components/ComponentPalette/ComponentPaletteItem.js +0 -51
  263. package/dist/visual-builder/components/EmbeddedVisualBuilder.js +0 -107
  264. package/dist/visual-builder/components/PropertyEditor/PropertyEditor.js +0 -16
  265. package/dist/visual-builder/components/PropertyEditor/PropertyForm.js +0 -88
  266. package/dist/visual-builder/components/PropertyEditor/SpacingControl.js +0 -145
  267. package/dist/visual-builder/components/PropertyEditor/SpacingEditor.js +0 -32
  268. package/dist/visual-builder/components/StoryManager/SaveOnlyManager.js +0 -94
  269. package/dist/visual-builder/components/StoryManager/StoryManager.js +0 -68
  270. package/dist/visual-builder/components/StoryManager/index.js +0 -1
  271. package/dist/visual-builder/components/VisualBuilder.js +0 -256
  272. package/dist/visual-builder/config/componentRegistry.js +0 -1758
  273. package/dist/visual-builder/decorators/VisualBuilderDecorator.js +0 -184
  274. package/dist/visual-builder/example-integration.js +0 -59
  275. package/dist/visual-builder/example.js +0 -23
  276. package/dist/visual-builder/hooks/useDragAndDrop.js +0 -137
  277. package/dist/visual-builder/hooks/useSelection.js +0 -27
  278. package/dist/visual-builder/index.js +0 -7
  279. package/dist/visual-builder/store/visualBuilderStore.js +0 -305
  280. package/dist/visual-builder/types/index.js +0 -1
  281. package/dist/visual-builder/utils/__tests__/storyFileUpdater.test.js +0 -145
  282. package/dist/visual-builder/utils/aiParser.js +0 -336
  283. package/dist/visual-builder/utils/componentTreeUtils.js +0 -111
  284. package/dist/visual-builder/utils/parserValidation.js +0 -122
  285. package/dist/visual-builder/utils/storyFileManager.js +0 -73
  286. package/dist/visual-builder/utils/storyFileUpdater.js +0 -326
  287. package/dist/visual-builder/utils/storyNameExtraction.test.js +0 -211
  288. package/dist/visual-builder/utils/storyPersistence.js +0 -180
  289. package/dist/visual-builder/utils/storyToBuilder.js +0 -813
@@ -1,408 +0,0 @@
1
- /**
2
- * DragDropManager - Manages drag and drop operations in the playground
3
- */
4
- export class DragDropManager {
5
- constructor(store) {
6
- this.activeDropZone = null;
7
- this.store = store;
8
- }
9
- /**
10
- * Start a drag operation
11
- */
12
- startDrag(item, event) {
13
- this.store.startDrag(item);
14
- // Store initial position if provided
15
- if (event) {
16
- item.initialPosition = {
17
- x: event.clientX,
18
- y: event.clientY
19
- };
20
- }
21
- // Calculate offset if dragging existing component
22
- if (item.type === 'move-component' && item.component && event) {
23
- const element = event.target;
24
- const rect = element.getBoundingClientRect();
25
- item.offset = {
26
- x: event.clientX - rect.left,
27
- y: event.clientY - rect.top
28
- };
29
- }
30
- }
31
- /**
32
- * Update drag position and find active drop zone
33
- */
34
- updateDrag(event) {
35
- // Get canvas element to account for zoom and offset
36
- const canvas = document.querySelector('[data-canvas]');
37
- let adjustedX = event.clientX;
38
- let adjustedY = event.clientY;
39
- // Account for canvas transformations if available
40
- if (canvas) {
41
- const canvasRect = canvas.getBoundingClientRect();
42
- const zoom = this.store.canvasZoom || 1;
43
- const offset = this.store.canvasOffset || { x: 0, y: 0 };
44
- // Adjust coordinates for canvas zoom and offset
45
- adjustedX = (event.clientX - canvasRect.left - offset.x) / zoom;
46
- adjustedY = (event.clientY - canvasRect.top - offset.y) / zoom;
47
- }
48
- const dropZone = this.getDropZoneAtPoint(adjustedX, adjustedY);
49
- if (dropZone !== this.activeDropZone) {
50
- // Update previous drop zone
51
- if (this.activeDropZone) {
52
- this.store.updateDropZone(this.activeDropZone.id, {
53
- isActive: false,
54
- isOver: false
55
- });
56
- }
57
- // Update new drop zone
58
- if (dropZone) {
59
- const draggedItem = this.store.draggedItem;
60
- const canDrop = draggedItem ? this.canDrop(draggedItem, dropZone) : false;
61
- this.store.updateDropZone(dropZone.id, {
62
- isActive: true,
63
- isOver: true,
64
- canDrop
65
- });
66
- }
67
- this.activeDropZone = dropZone;
68
- }
69
- }
70
- /**
71
- * End drag operation and perform drop if valid
72
- */
73
- endDrag(overId) {
74
- const draggedItem = this.store.draggedItem;
75
- if (!draggedItem) {
76
- return null;
77
- }
78
- let result = null;
79
- // Find drop zone by ID or get the active one
80
- if (overId) {
81
- const dropZone = this.store.dropZones.get(overId) || this.activeDropZone;
82
- if (dropZone && this.canDrop(draggedItem, dropZone)) {
83
- result = this.performDrop(draggedItem, dropZone);
84
- }
85
- }
86
- // Clean up
87
- this.cleanupDrag();
88
- return result;
89
- }
90
- /**
91
- * Cancel drag operation
92
- */
93
- cancelDrag() {
94
- this.cleanupDrag();
95
- }
96
- /**
97
- * Register a drop zone
98
- */
99
- registerDropZone(zone) {
100
- this.store.registerDropZone(zone);
101
- }
102
- /**
103
- * Unregister a drop zone
104
- */
105
- unregisterDropZone(id) {
106
- this.store.unregisterDropZone(id);
107
- }
108
- /**
109
- * Update drop zone properties
110
- */
111
- updateDropZone(id, updates) {
112
- this.store.updateDropZone(id, updates);
113
- }
114
- /**
115
- * Check if item can be dropped in zone
116
- */
117
- canDrop(item, zone) {
118
- // Check if zone accepts this type
119
- if (Array.isArray(zone.accepts)) {
120
- if (item.type === 'new-component' && item.componentType) {
121
- if (!zone.accepts.includes(item.componentType) && !zone.accepts.includes('all')) {
122
- return false;
123
- }
124
- }
125
- }
126
- else if (typeof zone.accepts === 'function') {
127
- if (!zone.accepts(item)) {
128
- return false;
129
- }
130
- }
131
- // Check max children limit
132
- if (zone.maxChildren !== undefined && zone.childCount !== undefined) {
133
- if (zone.childCount >= zone.maxChildren) {
134
- return false;
135
- }
136
- }
137
- // Prevent dropping component on itself or its children
138
- if (item.type === 'move-component' && item.component) {
139
- if (item.component.id === zone.componentId) {
140
- return false;
141
- }
142
- // Check if zone is a child of the dragged component
143
- if (this.isDescendant(zone.componentId, item.component.id)) {
144
- return false;
145
- }
146
- }
147
- return true;
148
- }
149
- /**
150
- * Validate drop operation
151
- */
152
- validateDrop(item, zone) {
153
- const canDrop = this.canDrop(item, zone);
154
- if (!canDrop) {
155
- // Provide specific reason
156
- if (zone.maxChildren && zone.childCount && zone.childCount >= zone.maxChildren) {
157
- return {
158
- canDrop: false,
159
- reason: `Maximum children (${zone.maxChildren}) reached`
160
- };
161
- }
162
- if (item.type === 'move-component' && item.component) {
163
- if (item.component.id === zone.componentId) {
164
- return {
165
- canDrop: false,
166
- reason: 'Cannot drop component on itself'
167
- };
168
- }
169
- if (this.isDescendant(zone.componentId, item.component.id)) {
170
- return {
171
- canDrop: false,
172
- reason: 'Cannot drop component on its descendant'
173
- };
174
- }
175
- }
176
- return {
177
- canDrop: false,
178
- reason: 'This component cannot be dropped here'
179
- };
180
- }
181
- return {
182
- canDrop: true,
183
- targetZone: zone
184
- };
185
- }
186
- /**
187
- * Get drop zone at screen coordinates
188
- */
189
- getDropZoneAtPoint(x, y) {
190
- // Update drop zone rectangles if needed
191
- this.updateDropZoneRects();
192
- // Find zones that contain the point
193
- const candidates = [];
194
- for (const zone of this.store.dropZones.values()) {
195
- if (zone.rect && this.pointInRect(x, y, zone.rect)) {
196
- candidates.push(zone);
197
- }
198
- }
199
- // Return the most specific (smallest) zone
200
- if (candidates.length > 0) {
201
- return candidates.reduce((smallest, zone) => {
202
- if (!smallest.rect || !zone.rect)
203
- return smallest;
204
- const smallestArea = smallest.rect.width * smallest.rect.height;
205
- const zoneArea = zone.rect.width * zone.rect.height;
206
- return zoneArea < smallestArea ? zone : smallest;
207
- });
208
- }
209
- return null;
210
- }
211
- /**
212
- * Get all active drop zones
213
- */
214
- getActiveDropZones() {
215
- return Array.from(this.store.dropZones.values()).filter(zone => zone.isActive);
216
- }
217
- /**
218
- * Get nearest drop zone to coordinates
219
- */
220
- getNearestDropZone(x, y) {
221
- let nearest = null;
222
- let minDistance = Infinity;
223
- for (const zone of this.store.dropZones.values()) {
224
- if (!zone.rect)
225
- continue;
226
- const centerX = zone.rect.left + zone.rect.width / 2;
227
- const centerY = zone.rect.top + zone.rect.height / 2;
228
- const distance = Math.sqrt((x - centerX) ** 2 + (y - centerY) ** 2);
229
- if (distance < minDistance) {
230
- minDistance = distance;
231
- nearest = zone;
232
- }
233
- }
234
- return nearest;
235
- }
236
- /**
237
- * Get insertion index for drop position
238
- */
239
- getInsertionIndex(zone, y) {
240
- const parent = this.store.components.get(zone.componentId);
241
- if (!parent || !parent.children)
242
- return 0;
243
- // Find the child element positions
244
- const childElements = Array.from(document.querySelectorAll(`[data-component-id="${zone.componentId}"] > [data-component-id]`));
245
- // Account for canvas transformations
246
- const canvas = document.querySelector('[data-canvas]');
247
- let adjustedY = y;
248
- if (canvas) {
249
- const canvasRect = canvas.getBoundingClientRect();
250
- const zoom = this.store.canvasZoom || 1;
251
- const offset = this.store.canvasOffset || { x: 0, y: 0 };
252
- // Convert screen coordinates to canvas coordinates
253
- adjustedY = (y - canvasRect.top - offset.y) / zoom;
254
- }
255
- // Find insertion point based on adjusted y position
256
- for (let i = 0; i < childElements.length; i++) {
257
- const rect = childElements[i].getBoundingClientRect();
258
- let midY = rect.top + rect.height / 2;
259
- // Adjust midY for canvas transformations
260
- if (canvas) {
261
- const canvasRect = canvas.getBoundingClientRect();
262
- const zoom = this.store.canvasZoom || 1;
263
- const offset = this.store.canvasOffset || { x: 0, y: 0 };
264
- midY = (rect.top - canvasRect.top - offset.y) / zoom + rect.height / (2 * zoom);
265
- }
266
- if (adjustedY < midY) {
267
- return i;
268
- }
269
- }
270
- return parent.children.length;
271
- }
272
- /**
273
- * Perform the drop operation
274
- */
275
- performDrop(item, zone) {
276
- const result = {
277
- dropZone: zone,
278
- parentId: zone.componentId,
279
- index: zone.insertIndex ?? 0,
280
- success: false
281
- };
282
- try {
283
- if (item.type === 'new-component' && item.componentType) {
284
- // Create new component
285
- const newComponent = {
286
- id: this.generateComponentId(item.componentType),
287
- type: item.componentType,
288
- displayName: item.componentType,
289
- props: this.getDefaultProps(item.componentType),
290
- parentId: zone.componentId,
291
- children: []
292
- };
293
- // Use the zone's insert index if specified
294
- result.index = zone.insertIndex ?? this.getInsertionIndex(zone, 0);
295
- this.store.addComponent(newComponent);
296
- result.success = true;
297
- result.componentId = newComponent.id;
298
- }
299
- else if (item.type === 'move-component' && item.component) {
300
- // Move existing component
301
- result.index = zone.insertIndex ?? this.getInsertionIndex(zone, 0);
302
- this.store.moveComponent(item.component.id, zone.componentId, result.index);
303
- result.success = true;
304
- result.componentId = item.component.id;
305
- }
306
- }
307
- catch (error) {
308
- console.error('Drop operation failed:', error);
309
- result.error = error instanceof Error ? error.message : 'Drop operation failed';
310
- }
311
- return result;
312
- }
313
- /**
314
- * Get default props for component type
315
- */
316
- getDefaultProps(componentType) {
317
- const defaults = {
318
- Button: { children: 'Button', type: 'primary' },
319
- Input: { placeholder: 'Enter text...' },
320
- Card: { title: 'Card Title' },
321
- Text: { children: 'Sample text' },
322
- Title: { children: 'Title', level: 1 },
323
- Box: { padding: 16 },
324
- Stack: { spacing: 8 },
325
- // Add more defaults as needed
326
- };
327
- return defaults[componentType] || {};
328
- }
329
- /**
330
- * Clean up after drag operation
331
- */
332
- cleanupDrag() {
333
- // Clear active drop zone
334
- if (this.activeDropZone) {
335
- this.store.updateDropZone(this.activeDropZone.id, {
336
- isActive: false,
337
- isOver: false,
338
- canDrop: false
339
- });
340
- this.activeDropZone = null;
341
- }
342
- // Clear all drop zone states
343
- for (const zone of this.store.dropZones.values()) {
344
- this.store.updateDropZone(zone.id, {
345
- isActive: false,
346
- isOver: false,
347
- canDrop: false
348
- });
349
- }
350
- // End drag in store
351
- this.store.endDrag();
352
- }
353
- /**
354
- * Update drop zone DOM rectangles
355
- */
356
- updateDropZoneRects() {
357
- const canvas = document.querySelector('[data-canvas]');
358
- const zoom = this.store.canvasZoom || 1;
359
- const offset = this.store.canvasOffset || { x: 0, y: 0 };
360
- for (const zone of this.store.dropZones.values()) {
361
- const element = document.querySelector(`[data-drop-zone-id="${zone.id}"]`);
362
- if (element) {
363
- const rect = element.getBoundingClientRect();
364
- let computed;
365
- // Adjust rectangle for canvas transformations
366
- if (canvas) {
367
- const canvasRect = canvas.getBoundingClientRect();
368
- computed = new DOMRect((rect.left - canvasRect.left - offset.x) / zoom, (rect.top - canvasRect.top - offset.y) / zoom, rect.width / zoom, rect.height / zoom);
369
- }
370
- else {
371
- computed = rect;
372
- }
373
- this.store.updateDropZone(zone.id, { rect: computed });
374
- }
375
- }
376
- }
377
- /**
378
- * Check if point is inside rectangle
379
- */
380
- pointInRect(x, y, rect) {
381
- return x >= rect.left &&
382
- x <= rect.right &&
383
- y >= rect.top &&
384
- y <= rect.bottom;
385
- }
386
- /**
387
- * Check if one component is a descendant of another
388
- */
389
- isDescendant(possibleDescendantId, ancestorId) {
390
- const component = this.store.components.get(possibleDescendantId);
391
- if (!component)
392
- return false;
393
- if (component.parentId === ancestorId) {
394
- return true;
395
- }
396
- if (component.parentId) {
397
- return this.isDescendant(component.parentId, ancestorId);
398
- }
399
- return false;
400
- }
401
- /**
402
- * Generate unique component ID
403
- */
404
- generateComponentId(type) {
405
- return `${type.toLowerCase()}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
406
- }
407
- }
408
- //# sourceMappingURL=DragDropManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DragDropManager.js","sourceRoot":"","sources":["../../../playground/services/DragDropManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,MAAM,OAAO,eAAe;IAI1B,YAAY,KAAU;QAFd,mBAAc,GAAoB,IAAI,CAAC;QAG7C,IAAI,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QAAQ,EAAE,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,CAAS,EAAE,CAAS,EAAE,IAAa;QACrD,OAAO,CAAC,IAAI,IAAI,CAAC,IAAI;YACd,CAAC,IAAI,IAAI,CAAC,KAAK;YACf,CAAC,IAAI,IAAI,CAAC,GAAG;YACb,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,oBAA4B,EAAE,UAAkB;QACnE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClE,IAAI,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAE7B,IAAI,SAAS,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,IAAY;QACtC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAC1F,CAAC;CACF"}
@@ -1,73 +0,0 @@
1
- /**
2
- * StoryParser - Parses AI-generated story code into playground components
3
- */
4
- import type { PlaygroundComponent } from '../types';
5
- export interface ParseResult {
6
- success: boolean;
7
- components: PlaygroundComponent[];
8
- imports: ImportStatement[];
9
- error?: string;
10
- warnings?: string[];
11
- }
12
- export interface ImportStatement {
13
- source: string;
14
- specifiers: string[];
15
- isDefault?: boolean;
16
- isNamespace?: boolean;
17
- }
18
- export declare class StoryParser {
19
- private componentIdCounter;
20
- /**
21
- * Parse story code into playground components
22
- */
23
- parseStoryToComponents(code: string): Promise<ParseResult>;
24
- /**
25
- * Extract the story component from the code
26
- */
27
- private extractStoryComponent;
28
- /**
29
- * Extract import statements from code
30
- */
31
- private extractImports;
32
- /**
33
- * Parse JSX string into component objects
34
- */
35
- private parseJSX;
36
- /**
37
- * Parse JSX props string
38
- */
39
- private parseProps;
40
- /**
41
- * Parse inline style string
42
- */
43
- private parseInlineStyles;
44
- /**
45
- * Parse children content
46
- */
47
- private parseChildren;
48
- /**
49
- * Parse children content and return components
50
- */
51
- private parseChildrenAsComponents;
52
- /**
53
- * Evaluate simple JavaScript expressions
54
- */
55
- private evaluateExpression;
56
- /**
57
- * Build component tree from flat list
58
- */
59
- private buildComponentTree;
60
- /**
61
- * Generate unique component ID
62
- */
63
- private generateId;
64
- /**
65
- * Validate parsed components
66
- */
67
- validateComponents(components: PlaygroundComponent[]): {
68
- valid: boolean;
69
- errors: string[];
70
- warnings: string[];
71
- };
72
- }
73
- //# sourceMappingURL=StoryParser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StoryParser.d.ts","sourceRoot":"","sources":["../../../playground/services/StoryParser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,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