@dfosco/storyboard-core 4.2.0-beta.2 → 4.2.0-beta.21
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/commandpalette.config.json +109 -24
- package/dist/storyboard-ui.css +1 -1
- package/dist/storyboard-ui.js +17379 -28568
- package/dist/storyboard-ui.js.map +1 -1
- package/dist/tailwind.css +1 -1
- package/package.json +5 -2
- package/scaffold/agents/prompt-agent.agent.md +181 -0
- package/scaffold/agents/terminal-agent.agent.md +351 -0
- package/scaffold/codex/config.toml +246 -0
- package/scaffold/manifest.json +5 -0
- package/scaffold/skills/canvas/SKILL.md +5 -4
- package/scaffold/skills/ship/SKILL.md +1 -1
- package/scaffold/storyboard.config.json +14 -1
- package/scaffold/toolbar.config.json +1 -1
- package/src/ActionMenuButton.jsx +100 -0
- package/src/AutosyncMenuButton.css +67 -0
- package/src/AutosyncMenuButton.jsx +241 -0
- package/src/BranchSelect.jsx +29 -0
- package/src/BranchSelect.module.css +30 -0
- package/src/CanvasAgentsMenu.jsx +87 -0
- package/src/CanvasCreateMenu.jsx +609 -0
- package/src/CanvasSnap.css +27 -0
- package/src/CanvasSnap.jsx +51 -0
- package/src/CanvasUndoRedo.css +36 -0
- package/src/CanvasUndoRedo.jsx +62 -0
- package/src/CanvasZoomControl.css +53 -0
- package/src/CanvasZoomControl.jsx +49 -0
- package/src/CanvasZoomToFit.css +18 -0
- package/src/CanvasZoomToFit.jsx +26 -0
- package/src/CommandMenu.css +8 -0
- package/src/CommandMenu.jsx +286 -0
- package/src/CommandPalette.jsx +35 -0
- package/src/CommandPaletteTrigger.jsx +25 -0
- package/src/CommentsMenuButton.jsx +38 -0
- package/src/CoreUIBar.css +47 -0
- package/src/CoreUIBar.jsx +855 -0
- package/src/CreateMenuButton.jsx +116 -0
- package/src/HideChromeTrigger.jsx +40 -0
- package/src/InspectorPanel.css +109 -0
- package/src/InspectorPanel.jsx +629 -0
- package/src/PwaInstallBanner.css +42 -0
- package/src/PwaInstallBanner.jsx +124 -0
- package/src/SidePanel.jsx +260 -0
- package/src/ThemeMenuButton.jsx +136 -0
- package/src/autosync/server.js +202 -5
- package/src/autosync/server.test.js +112 -0
- package/src/canvas/__tests__/agent-integration.test.js +593 -0
- package/src/canvas/__tests__/helpers/browser.js +95 -0
- package/src/canvas/__tests__/helpers/canvas-api.js +129 -0
- package/src/canvas/__tests__/helpers/perf.js +118 -0
- package/src/canvas/__tests__/helpers/setup.js +176 -0
- package/src/canvas/__tests__/helpers/tmux.js +130 -0
- package/src/canvas/__tests__/helpers/transcript.js +129 -0
- package/src/canvas/__tests__/terminal-integration.test.js +175 -0
- package/src/canvas/hot-pool.js +757 -0
- package/src/canvas/materializer.js +31 -0
- package/src/canvas/materializer.test.js +56 -0
- package/src/canvas/selectedWidgets.js +65 -7
- package/src/canvas/server.js +1801 -22
- package/src/canvas/server.test.js +239 -0
- package/src/canvas/terminal-config.js +331 -0
- package/src/canvas/terminal-registry.js +38 -0
- package/src/canvas/terminal-server.js +1037 -29
- package/src/canvas/writeGuard.js +51 -3
- package/src/canvasConfig.js +67 -1
- package/src/canvasConfig.test.js +79 -1
- package/src/cli/agent.js +85 -0
- package/src/cli/branch.js +232 -0
- package/src/cli/canvasAdd.js +59 -12
- package/src/cli/canvasBatch.js +98 -0
- package/src/cli/canvasBounds.js +1 -1
- package/src/cli/canvasRead.js +1 -1
- package/src/cli/canvasUpdate.js +179 -0
- package/src/cli/create.js +38 -14
- package/src/cli/dev.js +157 -83
- package/src/cli/exit.js +23 -24
- package/src/cli/index.js +55 -2
- package/src/cli/proxy.js +96 -37
- package/src/cli/schemas.js +22 -4
- package/src/cli/server.js +148 -25
- package/src/cli/serverUrl.js +8 -3
- package/src/cli/sessions.js +131 -5
- package/src/cli/setup.js +109 -11
- package/src/cli/terminal-commands.js +16 -8
- package/src/cli/terminal-messaging.js +231 -0
- package/src/cli/terminal-welcome.js +365 -33
- package/src/commandActions.js +1 -0
- package/src/commandPaletteConfig.js +9 -0
- package/src/comments/auth.js +2 -1
- package/src/comments/ui/AuthModal.jsx +114 -0
- package/src/comments/ui/CommentWindow.jsx +329 -0
- package/src/comments/ui/CommentsDrawer.jsx +102 -0
- package/src/comments/ui/Composer.jsx +64 -0
- package/src/comments/ui/authModal.test.js +1 -1
- package/src/comments/ui/commentWindow.js +16 -17
- package/src/comments/ui/commentsDrawer.js +25 -26
- package/src/comments/ui/composer.js +23 -24
- package/src/comments/ui/index.js +2 -3
- package/src/configSchema.js +59 -1
- package/src/configStore.js +161 -0
- package/src/core-ui-colors.css +12 -0
- package/src/devtools.js +17 -19
- package/src/devtools.test.js +18 -9
- package/src/featureFlags.js +12 -5
- package/src/fuzzySearch.test.js +10 -0
- package/src/index.js +14 -2
- package/src/lib/components/ui/alert/alert-action.jsx +11 -0
- package/src/lib/components/ui/alert/alert-description.jsx +11 -0
- package/src/lib/components/ui/alert/alert-title.jsx +11 -0
- package/src/lib/components/ui/alert/alert.jsx +25 -0
- package/src/lib/components/ui/alert/index.js +15 -15
- package/src/lib/components/ui/avatar/avatar-badge.jsx +22 -0
- package/src/lib/components/ui/avatar/avatar-fallback.jsx +18 -0
- package/src/lib/components/ui/avatar/avatar-group-count.jsx +19 -0
- package/src/lib/components/ui/avatar/avatar-group.jsx +19 -0
- package/src/lib/components/ui/avatar/avatar-image.jsx +15 -0
- package/src/lib/components/ui/avatar/avatar.jsx +19 -0
- package/src/lib/components/ui/avatar/index.js +20 -20
- package/src/lib/components/ui/badge/badge.jsx +31 -0
- package/src/lib/components/ui/badge/index.js +2 -2
- package/src/lib/components/ui/button/button.jsx +100 -0
- package/src/lib/components/ui/button/index.js +9 -9
- package/src/lib/components/ui/card/card-action.jsx +11 -0
- package/src/lib/components/ui/card/card-content.jsx +11 -0
- package/src/lib/components/ui/card/card-description.jsx +11 -0
- package/src/lib/components/ui/card/card-footer.jsx +11 -0
- package/src/lib/components/ui/card/card-header.jsx +19 -0
- package/src/lib/components/ui/card/card-title.jsx +11 -0
- package/src/lib/components/ui/card/card.jsx +17 -0
- package/src/lib/components/ui/card/index.js +23 -23
- package/src/lib/components/ui/checkbox/checkbox.jsx +29 -0
- package/src/lib/components/ui/checkbox/index.js +5 -5
- package/src/lib/components/ui/collapsible/collapsible-content.jsx +7 -0
- package/src/lib/components/ui/collapsible/collapsible-trigger.jsx +7 -0
- package/src/lib/components/ui/collapsible/collapsible.jsx +7 -0
- package/src/lib/components/ui/collapsible/index.js +11 -11
- package/src/lib/components/ui/dialog/dialog-close.jsx +7 -0
- package/src/lib/components/ui/dialog/dialog-content.jsx +34 -0
- package/src/lib/components/ui/dialog/dialog-description.jsx +15 -0
- package/src/lib/components/ui/dialog/dialog-footer.jsx +23 -0
- package/src/lib/components/ui/dialog/dialog-header.jsx +11 -0
- package/src/lib/components/ui/dialog/dialog-overlay.jsx +15 -0
- package/src/lib/components/ui/dialog/dialog-portal.jsx +4 -0
- package/src/lib/components/ui/dialog/dialog-title.jsx +15 -0
- package/src/lib/components/ui/dialog/dialog-trigger.jsx +7 -0
- package/src/lib/components/ui/dialog/dialog.jsx +4 -0
- package/src/lib/components/ui/dialog/index.js +32 -32
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-group.jsx +8 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.jsx +30 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-content.jsx +22 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-group-heading.jsx +16 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-group.jsx +7 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-item.jsx +20 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-label.jsx +17 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-portal.jsx +4 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-radio-group.jsx +7 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-radio-item.jsx +29 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-separator.jsx +15 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-shortcut.jsx +16 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-sub-content.jsx +15 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-sub-trigger.jsx +23 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-sub.jsx +4 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-trigger.jsx +7 -0
- package/src/lib/components/ui/dropdown-menu/dropdown-menu.jsx +4 -0
- package/src/lib/components/ui/dropdown-menu/index.js +52 -52
- package/src/lib/components/ui/input/index.js +5 -5
- package/src/lib/components/ui/input/input.jsx +19 -0
- package/src/lib/components/ui/label/index.js +5 -5
- package/src/lib/components/ui/label/label.jsx +19 -0
- package/src/lib/components/ui/panel/index.js +21 -21
- package/src/lib/components/ui/panel/panel-body.jsx +11 -0
- package/src/lib/components/ui/panel/panel-close.jsx +16 -0
- package/src/lib/components/ui/panel/panel-content.jsx +29 -0
- package/src/lib/components/ui/panel/panel-footer.jsx +11 -0
- package/src/lib/components/ui/panel/panel-header.jsx +11 -0
- package/src/lib/components/ui/panel/panel-title.jsx +12 -0
- package/src/lib/components/ui/panel/panel.jsx +4 -0
- package/src/lib/components/ui/popover/index.js +26 -26
- package/src/lib/components/ui/popover/popover-close.jsx +7 -0
- package/src/lib/components/ui/popover/popover-content.jsx +22 -0
- package/src/lib/components/ui/popover/popover-description.jsx +11 -0
- package/src/lib/components/ui/popover/popover-header.jsx +11 -0
- package/src/lib/components/ui/popover/popover-portal.jsx +4 -0
- package/src/lib/components/ui/popover/popover-title.jsx +11 -0
- package/src/lib/components/ui/popover/popover-trigger.jsx +8 -0
- package/src/lib/components/ui/popover/popover.jsx +4 -0
- package/src/lib/components/ui/searchable-list.jsx +159 -0
- package/src/lib/components/ui/select/index.js +35 -35
- package/src/lib/components/ui/select/select-content.jsx +30 -0
- package/src/lib/components/ui/select/select-group-heading.jsx +17 -0
- package/src/lib/components/ui/select/select-group.jsx +15 -0
- package/src/lib/components/ui/select/select-item.jsx +26 -0
- package/src/lib/components/ui/select/select-label.jsx +11 -0
- package/src/lib/components/ui/select/select-portal.jsx +4 -0
- package/src/lib/components/ui/select/select-scroll-down-button.jsx +18 -0
- package/src/lib/components/ui/select/select-scroll-up-button.jsx +18 -0
- package/src/lib/components/ui/select/select-separator.jsx +15 -0
- package/src/lib/components/ui/select/select-trigger.jsx +25 -0
- package/src/lib/components/ui/select/select.jsx +4 -0
- package/src/lib/components/ui/separator/index.js +5 -5
- package/src/lib/components/ui/separator/separator.jsx +22 -0
- package/src/lib/components/ui/sheet/index.js +32 -32
- package/src/lib/components/ui/sheet/sheet-close.jsx +7 -0
- package/src/lib/components/ui/sheet/sheet-content.jsx +35 -0
- package/src/lib/components/ui/sheet/sheet-description.jsx +15 -0
- package/src/lib/components/ui/sheet/sheet-footer.jsx +11 -0
- package/src/lib/components/ui/sheet/sheet-header.jsx +11 -0
- package/src/lib/components/ui/sheet/sheet-overlay.jsx +15 -0
- package/src/lib/components/ui/sheet/sheet-portal.jsx +4 -0
- package/src/lib/components/ui/sheet/sheet-title.jsx +15 -0
- package/src/lib/components/ui/sheet/sheet-trigger.jsx +7 -0
- package/src/lib/components/ui/sheet/sheet.jsx +4 -0
- package/src/lib/components/ui/textarea/index.js +5 -5
- package/src/lib/components/ui/textarea/textarea.jsx +18 -0
- package/src/lib/components/ui/toggle/index.js +6 -9
- package/src/lib/components/ui/toggle/toggle.jsx +36 -0
- package/src/lib/components/ui/toggle-group/index.js +8 -8
- package/src/lib/components/ui/toggle-group/toggle-group-item.jsx +29 -0
- package/src/lib/components/ui/toggle-group/toggle-group.jsx +43 -0
- package/src/lib/components/ui/tooltip/index.js +3 -3
- package/src/lib/components/ui/tooltip/tooltip-content.jsx +21 -0
- package/src/lib/components/ui/tooltip/tooltip-trigger.jsx +23 -0
- package/src/lib/components/ui/tooltip/tooltip.jsx +11 -0
- package/src/lib/components/ui/trigger-button/index.js +3 -3
- package/src/lib/components/ui/trigger-button/trigger-button.css +38 -0
- package/src/lib/components/ui/trigger-button/trigger-button.jsx +63 -0
- package/src/logger/devLogger.js +238 -0
- package/src/logger/devLogger.test.js +193 -0
- package/src/modes.test.js +4 -4
- package/src/mountStoryboardCore.js +123 -27
- package/src/paletteProviders.js +3 -0
- package/src/paletteProviders.test.js +2 -2
- package/src/server/index.js +98 -36
- package/src/sidepanel.css +214 -0
- package/src/styles/tailwind.css +1 -1
- package/src/svelte-plugin-ui/__tests__/ModeSwitch.test.ts +8 -8
- package/src/svelte-plugin-ui/__tests__/ToolbarShell.test.ts +11 -10
- package/src/svelte-plugin-ui/components/Icon.css +11 -0
- package/src/svelte-plugin-ui/components/Icon.jsx +281 -0
- package/src/svelte-plugin-ui/components/ModeSwitch.css +90 -0
- package/src/svelte-plugin-ui/components/ModeSwitch.jsx +47 -0
- package/src/svelte-plugin-ui/components/ToolbarShell.css +80 -0
- package/src/svelte-plugin-ui/components/ToolbarShell.jsx +84 -0
- package/src/svelte-plugin-ui/components/Viewfinder.css +412 -0
- package/src/svelte-plugin-ui/components/Viewfinder.jsx +512 -0
- package/src/svelte-plugin-ui/mount.ts +12 -16
- package/src/toolRegistry.js +4 -4
- package/src/toolbarConfigStore.js +30 -0
- package/src/tools/handlers/autosync.js +1 -1
- package/src/tools/handlers/canvasAddWidget.js +1 -1
- package/src/tools/handlers/canvasAgents.js +19 -0
- package/src/tools/handlers/canvasToolbar.js +8 -8
- package/src/tools/handlers/commandPalette.js +9 -0
- package/src/tools/handlers/comments.js +1 -1
- package/src/tools/handlers/create.js +1 -1
- package/src/tools/handlers/devtools.js +16 -0
- package/src/tools/handlers/devtools.test.js +38 -0
- package/src/tools/handlers/flows.js +1 -1
- package/src/tools/handlers/hideChrome.js +9 -0
- package/src/tools/handlers/paletteTheme.js +35 -0
- package/src/tools/handlers/theme.js +1 -1
- package/src/tools/registry.js +4 -1
- package/src/tools/surfaces/commandList.js +3 -3
- package/src/tools/surfaces/mainToolbar.js +3 -3
- package/src/tools/surfaces/registry.js +4 -4
- package/src/ui/design-modes.ts +2 -2
- package/src/ui/viewfinder.ts +1 -1
- package/src/vite/server-plugin.js +242 -60
- package/src/workshop/features/createCanvas/CreateCanvasForm.jsx +260 -0
- package/src/workshop/features/createCanvas/index.js +1 -1
- package/src/workshop/features/createFlow/CreateFlowForm.jsx +334 -0
- package/src/workshop/features/createFlow/index.js +1 -1
- package/src/workshop/features/createPage/CreatePageForm.jsx +304 -0
- package/src/workshop/features/createPage/index.js +1 -1
- package/src/workshop/features/createPrototype/CreatePrototypeForm.jsx +289 -0
- package/src/workshop/features/createPrototype/index.js +1 -1
- package/src/workshop/features/createPrototype/server.js +98 -0
- package/src/workshop/features/createStory/CreateStoryForm.jsx +208 -0
- package/src/workshop/features/createStory/index.js +1 -1
- package/src/workshop/ui/WorkshopPanel.jsx +98 -0
- package/src/workshop/ui/mount.ts +1 -1
- package/src/worktree/port.js +48 -0
- package/src/worktree/serverRegistry.js +120 -0
- package/toolbar.config.json +93 -42
- package/widgets.config.json +580 -12
- package/src/ActionMenuButton.svelte +0 -119
- package/src/AutosyncMenuButton.svelte +0 -397
- package/src/CanvasCreateMenu.svelte +0 -295
- package/src/CanvasSnap.svelte +0 -87
- package/src/CanvasUndoRedo.svelte +0 -108
- package/src/CanvasZoomControl.svelte +0 -111
- package/src/CanvasZoomToFit.svelte +0 -52
- package/src/CommandMenu.svelte +0 -249
- package/src/CommandPalette.svelte +0 -33
- package/src/CommentsMenuButton.svelte +0 -53
- package/src/CoreUIBar.svelte +0 -847
- package/src/CreateMenuButton.svelte +0 -133
- package/src/DocPanel.svelte +0 -299
- package/src/InspectorPanel.svelte +0 -745
- package/src/PwaInstallBanner.svelte +0 -124
- package/src/SidePanel.svelte +0 -480
- package/src/ThemeMenuButton.svelte +0 -132
- package/src/comments/ui/AuthModal.svelte +0 -108
- package/src/comments/ui/CommentWindow.svelte +0 -333
- package/src/comments/ui/CommentsDrawer.svelte +0 -96
- package/src/comments/ui/Composer.svelte +0 -65
- package/src/lib/components/ui/alert/alert-action.svelte +0 -19
- package/src/lib/components/ui/alert/alert-description.svelte +0 -22
- package/src/lib/components/ui/alert/alert-title.svelte +0 -22
- package/src/lib/components/ui/alert/alert.svelte +0 -38
- package/src/lib/components/ui/avatar/avatar-badge.svelte +0 -25
- package/src/lib/components/ui/avatar/avatar-fallback.svelte +0 -20
- package/src/lib/components/ui/avatar/avatar-group-count.svelte +0 -22
- package/src/lib/components/ui/avatar/avatar-group.svelte +0 -22
- package/src/lib/components/ui/avatar/avatar-image.svelte +0 -17
- package/src/lib/components/ui/avatar/avatar.svelte +0 -24
- package/src/lib/components/ui/badge/badge.svelte +0 -44
- package/src/lib/components/ui/button/button.svelte +0 -108
- package/src/lib/components/ui/card/card-action.svelte +0 -21
- package/src/lib/components/ui/card/card-content.svelte +0 -19
- package/src/lib/components/ui/card/card-description.svelte +0 -19
- package/src/lib/components/ui/card/card-footer.svelte +0 -18
- package/src/lib/components/ui/card/card-header.svelte +0 -21
- package/src/lib/components/ui/card/card-title.svelte +0 -14
- package/src/lib/components/ui/card/card.svelte +0 -21
- package/src/lib/components/ui/checkbox/checkbox.svelte +0 -39
- package/src/lib/components/ui/collapsible/collapsible-content.svelte +0 -7
- package/src/lib/components/ui/collapsible/collapsible-trigger.svelte +0 -7
- package/src/lib/components/ui/collapsible/collapsible.svelte +0 -11
- package/src/lib/components/ui/dialog/dialog-close.svelte +0 -11
- package/src/lib/components/ui/dialog/dialog-content.svelte +0 -42
- package/src/lib/components/ui/dialog/dialog-description.svelte +0 -17
- package/src/lib/components/ui/dialog/dialog-footer.svelte +0 -29
- package/src/lib/components/ui/dialog/dialog-header.svelte +0 -19
- package/src/lib/components/ui/dialog/dialog-overlay.svelte +0 -17
- package/src/lib/components/ui/dialog/dialog-portal.svelte +0 -7
- package/src/lib/components/ui/dialog/dialog-title.svelte +0 -17
- package/src/lib/components/ui/dialog/dialog-trigger.svelte +0 -11
- package/src/lib/components/ui/dialog/dialog.svelte +0 -7
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte +0 -16
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +0 -40
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-content.svelte +0 -27
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +0 -18
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-group.svelte +0 -7
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-item.svelte +0 -24
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-label.svelte +0 -20
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-portal.svelte +0 -7
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +0 -16
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +0 -34
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-separator.svelte +0 -17
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +0 -19
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +0 -17
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +0 -27
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-sub.svelte +0 -7
- package/src/lib/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +0 -7
- package/src/lib/components/ui/dropdown-menu/dropdown-menu.svelte +0 -7
- package/src/lib/components/ui/input/input.svelte +0 -40
- package/src/lib/components/ui/label/label.svelte +0 -20
- package/src/lib/components/ui/panel/panel-body.svelte +0 -13
- package/src/lib/components/ui/panel/panel-close.svelte +0 -16
- package/src/lib/components/ui/panel/panel-content.svelte +0 -33
- package/src/lib/components/ui/panel/panel-footer.svelte +0 -13
- package/src/lib/components/ui/panel/panel-header.svelte +0 -16
- package/src/lib/components/ui/panel/panel-title.svelte +0 -14
- package/src/lib/components/ui/panel/panel.svelte +0 -15
- package/src/lib/components/ui/popover/popover-close.svelte +0 -7
- package/src/lib/components/ui/popover/popover-content.svelte +0 -27
- package/src/lib/components/ui/popover/popover-description.svelte +0 -19
- package/src/lib/components/ui/popover/popover-header.svelte +0 -19
- package/src/lib/components/ui/popover/popover-portal.svelte +0 -7
- package/src/lib/components/ui/popover/popover-title.svelte +0 -19
- package/src/lib/components/ui/popover/popover-trigger.svelte +0 -17
- package/src/lib/components/ui/popover/popover.svelte +0 -7
- package/src/lib/components/ui/select/select-content.svelte +0 -40
- package/src/lib/components/ui/select/select-group-heading.svelte +0 -19
- package/src/lib/components/ui/select/select-group.svelte +0 -17
- package/src/lib/components/ui/select/select-item.svelte +0 -38
- package/src/lib/components/ui/select/select-label.svelte +0 -18
- package/src/lib/components/ui/select/select-portal.svelte +0 -7
- package/src/lib/components/ui/select/select-scroll-down-button.svelte +0 -20
- package/src/lib/components/ui/select/select-scroll-up-button.svelte +0 -20
- package/src/lib/components/ui/select/select-separator.svelte +0 -17
- package/src/lib/components/ui/select/select-trigger.svelte +0 -27
- package/src/lib/components/ui/select/select.svelte +0 -11
- package/src/lib/components/ui/separator/separator.svelte +0 -23
- package/src/lib/components/ui/sheet/sheet-close.svelte +0 -7
- package/src/lib/components/ui/sheet/sheet-content.svelte +0 -43
- package/src/lib/components/ui/sheet/sheet-description.svelte +0 -17
- package/src/lib/components/ui/sheet/sheet-footer.svelte +0 -18
- package/src/lib/components/ui/sheet/sheet-header.svelte +0 -19
- package/src/lib/components/ui/sheet/sheet-overlay.svelte +0 -17
- package/src/lib/components/ui/sheet/sheet-portal.svelte +0 -7
- package/src/lib/components/ui/sheet/sheet-title.svelte +0 -17
- package/src/lib/components/ui/sheet/sheet-trigger.svelte +0 -7
- package/src/lib/components/ui/sheet/sheet.svelte +0 -7
- package/src/lib/components/ui/textarea/textarea.svelte +0 -21
- package/src/lib/components/ui/toggle/toggle.svelte +0 -45
- package/src/lib/components/ui/toggle-group/toggle-group-item.svelte +0 -35
- package/src/lib/components/ui/toggle-group/toggle-group.svelte +0 -63
- package/src/lib/components/ui/tooltip/tooltip-content.svelte +0 -24
- package/src/lib/components/ui/tooltip/tooltip-trigger.svelte +0 -27
- package/src/lib/components/ui/tooltip/tooltip.svelte +0 -9
- package/src/lib/components/ui/trigger-button/trigger-button.svelte +0 -106
- package/src/svelte-plugin-ui/components/Icon.svelte +0 -181
- package/src/svelte-plugin-ui/components/ModeSwitch.svelte +0 -121
- package/src/svelte-plugin-ui/components/ToolbarShell.svelte +0 -150
- package/src/svelte-plugin-ui/components/Viewfinder.svelte +0 -1001
- package/src/tools/handlers/docs.js +0 -11
- package/src/workshop/features/createCanvas/CreateCanvasForm.svelte +0 -139
- package/src/workshop/features/createFlow/CreateFlowForm.svelte +0 -314
- package/src/workshop/features/createPage/CreatePageForm.svelte +0 -249
- package/src/workshop/features/createPrototype/CreatePrototypeForm.svelte +0 -287
- package/src/workshop/features/createStory/CreateStoryForm.svelte +0 -161
- package/src/workshop/ui/WorkshopPanel.svelte +0 -97
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CanvasCreateMenu — CoreUIBar dropdown for adding widgets to the active canvas.
|
|
3
|
+
* Dispatches custom events to bridge to React canvas system.
|
|
4
|
+
* Only visible when a canvas page is active.
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useMemo, useEffect, useRef } from 'react'
|
|
7
|
+
import { TriggerButton } from './lib/components/ui/trigger-button/index.js'
|
|
8
|
+
import * as DropdownMenu from './lib/components/ui/dropdown-menu/index.js'
|
|
9
|
+
import { Button } from './lib/components/ui/button/index.js'
|
|
10
|
+
import { Input } from './lib/components/ui/input/index.js'
|
|
11
|
+
import { Label } from './lib/components/ui/label/index.js'
|
|
12
|
+
import { SearchableList } from './lib/components/ui/searchable-list.jsx'
|
|
13
|
+
import Icon from './svelte-plugin-ui/components/Icon.jsx'
|
|
14
|
+
import { getConfig } from './configStore.js'
|
|
15
|
+
import { buildPrototypeIndex } from './viewfinder.js'
|
|
16
|
+
|
|
17
|
+
const widgetTypes = [
|
|
18
|
+
{ type: 'sticky-note', label: 'Sticky Note' },
|
|
19
|
+
{ type: 'markdown', label: 'Markdown' },
|
|
20
|
+
{ type: 'prompt', label: 'Prompt' },
|
|
21
|
+
{ type: 'terminal', label: 'Terminal' },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
function formatName(name) {
|
|
25
|
+
return name
|
|
26
|
+
.replace(/[-_]/g, ' ')
|
|
27
|
+
.replace(/\b\w/g, (c) => c.toUpperCase())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function ChevronRight({ className, style }) {
|
|
31
|
+
return (
|
|
32
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.5" className={className} style={style}>
|
|
33
|
+
<path d="M4.5 2.5L7.5 6L4.5 9.5" />
|
|
34
|
+
</svg>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getApiUrl() {
|
|
39
|
+
const basePath = window.__STORYBOARD_BASE_PATH__ || '/'
|
|
40
|
+
return basePath.replace(/\/$/, '') + '/_storyboard/canvas'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default function CanvasCreateMenu({ config = {}, data, canvasName = '', zoom, tabindex }) {
|
|
44
|
+
const [menuOpen, setMenuOpen] = useState(false)
|
|
45
|
+
const [view, setView] = useState('menu')
|
|
46
|
+
const [stories, setStories] = useState([])
|
|
47
|
+
const [storiesLoaded, setStoriesLoaded] = useState(false)
|
|
48
|
+
const componentSearchRef = useRef(null)
|
|
49
|
+
const prototypeSearchRef = useRef(null)
|
|
50
|
+
const [expandedProtos, setExpandedProtos] = useState(new Set())
|
|
51
|
+
|
|
52
|
+
const showAgentsInMenu = useMemo(() => {
|
|
53
|
+
const canvasConfig = getConfig('canvas')
|
|
54
|
+
return canvasConfig?.showAgentsInAddMenu !== false
|
|
55
|
+
}, [])
|
|
56
|
+
|
|
57
|
+
// Read agent configs from canvas.agents
|
|
58
|
+
const agents = useMemo(() => {
|
|
59
|
+
if (!showAgentsInMenu) return []
|
|
60
|
+
const canvasConfig = getConfig('canvas')
|
|
61
|
+
const agentsConfig = canvasConfig?.agents
|
|
62
|
+
if (!agentsConfig || typeof agentsConfig !== 'object') return []
|
|
63
|
+
return Object.entries(agentsConfig).map(([id, cfg]) => ({
|
|
64
|
+
id,
|
|
65
|
+
label: cfg.label || id,
|
|
66
|
+
startupCommand: cfg.startupCommand || id,
|
|
67
|
+
defaultWidth: cfg.defaultWidth,
|
|
68
|
+
defaultHeight: cfg.defaultHeight,
|
|
69
|
+
}))
|
|
70
|
+
}, [])
|
|
71
|
+
|
|
72
|
+
// Build prototype list for the Prototype submenu
|
|
73
|
+
const prototypeItems = useMemo(() => {
|
|
74
|
+
try {
|
|
75
|
+
const idx = buildPrototypeIndex()
|
|
76
|
+
const allProtos = []
|
|
77
|
+
for (const folder of (idx.sorted?.title?.folders || idx.folders || [])) {
|
|
78
|
+
for (const proto of folder.prototypes || []) {
|
|
79
|
+
if (!proto.isExternal) allProtos.push(proto)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const proto of (idx.sorted?.title?.prototypes || idx.prototypes || [])) {
|
|
83
|
+
if (!proto.isExternal) allProtos.push(proto)
|
|
84
|
+
}
|
|
85
|
+
return allProtos.map((proto) => {
|
|
86
|
+
if (proto.hideFlows && proto.flows.length === 1) {
|
|
87
|
+
return { name: proto.name, dirName: proto.dirName, flows: [{ name: proto.name, route: proto.flows[0].route }], singleFlow: true }
|
|
88
|
+
} else if (proto.flows.length > 0) {
|
|
89
|
+
return { name: proto.name, dirName: proto.dirName, flows: proto.flows.map((f) => ({ name: f.meta?.title || formatName(f.name), route: f.route })), singleFlow: false }
|
|
90
|
+
} else {
|
|
91
|
+
return { name: proto.name, dirName: proto.dirName, flows: [{ name: proto.name, route: `/${proto.dirName}` }], singleFlow: true }
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
} catch {
|
|
95
|
+
return []
|
|
96
|
+
}
|
|
97
|
+
}, [])
|
|
98
|
+
|
|
99
|
+
// Create prototype form state
|
|
100
|
+
const [protoName, setProtoName] = useState('')
|
|
101
|
+
const [protoSubmitting, setProtoSubmitting] = useState(false)
|
|
102
|
+
const [protoError, setProtoError] = useState(null)
|
|
103
|
+
|
|
104
|
+
const protoKebab = useMemo(
|
|
105
|
+
() => protoName.replace(/[^a-zA-Z0-9\s_-]/g, '').trim().replace(/[\s_]+/g, '-').toLowerCase().replace(/-+/g, '-').replace(/^-|-$/g, ''),
|
|
106
|
+
[protoName]
|
|
107
|
+
)
|
|
108
|
+
const protoNameError = useMemo(
|
|
109
|
+
() => protoName.trim() && !protoKebab ? 'Name must contain at least one alphanumeric character' : null,
|
|
110
|
+
[protoName, protoKebab]
|
|
111
|
+
)
|
|
112
|
+
const protoRoutePreview = protoKebab ? `/${protoKebab}` : ''
|
|
113
|
+
const canSubmitProto = !!protoKebab && !protoNameError && !protoSubmitting
|
|
114
|
+
|
|
115
|
+
function resetProtoForm() {
|
|
116
|
+
setProtoName('')
|
|
117
|
+
setProtoError(null)
|
|
118
|
+
setProtoSubmitting(false)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Create form state
|
|
122
|
+
const [createName, setCreateName] = useState('')
|
|
123
|
+
const [createLocation, setCreateLocation] = useState('canvas')
|
|
124
|
+
const [createFormat, setCreateFormat] = useState('jsx')
|
|
125
|
+
const [submitting, setSubmitting] = useState(false)
|
|
126
|
+
const [createError, setCreateError] = useState(null)
|
|
127
|
+
const [notificationPath, setNotificationPath] = useState(null)
|
|
128
|
+
|
|
129
|
+
const kebabName = useMemo(
|
|
130
|
+
() => createName.replace(/[^a-zA-Z0-9\s_-]/g, '').trim().replace(/[\s_]+/g, '-').toLowerCase().replace(/-+/g, '-').replace(/^-|-$/g, ''),
|
|
131
|
+
[createName]
|
|
132
|
+
)
|
|
133
|
+
const nameError = useMemo(
|
|
134
|
+
() => createName.trim() && !kebabName ? 'Name must contain at least one alphanumeric character' : null,
|
|
135
|
+
[createName, kebabName]
|
|
136
|
+
)
|
|
137
|
+
const filePreview = useMemo(
|
|
138
|
+
() => kebabName ? `${kebabName}.story.${createFormat}` : '',
|
|
139
|
+
[kebabName, createFormat]
|
|
140
|
+
)
|
|
141
|
+
const canSubmit = !!kebabName && !nameError && !submitting
|
|
142
|
+
|
|
143
|
+
function resetCreateForm() {
|
|
144
|
+
setCreateName('')
|
|
145
|
+
setCreateLocation('canvas')
|
|
146
|
+
setCreateFormat('jsx')
|
|
147
|
+
setCreateError(null)
|
|
148
|
+
setSubmitting(false)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function loadStories() {
|
|
152
|
+
try {
|
|
153
|
+
const res = await fetch(getApiUrl() + '/stories')
|
|
154
|
+
if (res.ok) {
|
|
155
|
+
const d = await res.json()
|
|
156
|
+
setStories(d.stories || [])
|
|
157
|
+
}
|
|
158
|
+
} catch { /* ignore */ }
|
|
159
|
+
setStoriesLoaded(true)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Load stories when menu opens
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (menuOpen) loadStories()
|
|
165
|
+
}, [menuOpen])
|
|
166
|
+
|
|
167
|
+
// Focus first menu item when dropdown opens on menu view
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (menuOpen && view === 'menu') {
|
|
170
|
+
requestAnimationFrame(() => {
|
|
171
|
+
const item = document.querySelector('[data-bits-dropdown-menu-content] [data-bits-dropdown-menu-item]:not([data-disabled])')
|
|
172
|
+
item?.focus()
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
}, [menuOpen, view])
|
|
176
|
+
|
|
177
|
+
// Reset when menu closes on menu view
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (!menuOpen && view === 'menu') {
|
|
180
|
+
resetCreateForm()
|
|
181
|
+
resetProtoForm()
|
|
182
|
+
setExpandedProtos(new Set())
|
|
183
|
+
}
|
|
184
|
+
}, [menuOpen, view])
|
|
185
|
+
|
|
186
|
+
function addWidget(type, props) {
|
|
187
|
+
document.dispatchEvent(new CustomEvent('storyboard:canvas:add-widget', {
|
|
188
|
+
detail: { type, canvasName, props }
|
|
189
|
+
}))
|
|
190
|
+
setMenuOpen(false)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function addStoryWidget(storyId) {
|
|
194
|
+
document.dispatchEvent(new CustomEvent('storyboard:canvas:add-story-widget', {
|
|
195
|
+
detail: { storyId, canvasName }
|
|
196
|
+
}))
|
|
197
|
+
setMenuOpen(false)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function addPrototypeWidget(route) {
|
|
201
|
+
addWidget('prototype', { src: route })
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function showCreateProtoForm() {
|
|
205
|
+
resetProtoForm()
|
|
206
|
+
setView('create-prototype')
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function submitCreateProto() {
|
|
210
|
+
if (!canSubmitProto) return
|
|
211
|
+
setProtoSubmitting(true)
|
|
212
|
+
setProtoError(null)
|
|
213
|
+
try {
|
|
214
|
+
const basePath = window.__STORYBOARD_BASE_PATH__ || '/'
|
|
215
|
+
const apiUrl = basePath.replace(/\/$/, '') + '/_storyboard/workshop/prototypes'
|
|
216
|
+
const res = await fetch(apiUrl, {
|
|
217
|
+
method: 'POST',
|
|
218
|
+
headers: { 'Content-Type': 'application/json' },
|
|
219
|
+
body: JSON.stringify({ name: protoKebab }),
|
|
220
|
+
})
|
|
221
|
+
const d = await res.json()
|
|
222
|
+
if (!res.ok) { setProtoError(d.error || 'Failed to create prototype'); setProtoSubmitting(false); return }
|
|
223
|
+
|
|
224
|
+
if (d.route) {
|
|
225
|
+
addPrototypeWidget(d.route)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
setNotificationPath(d.path)
|
|
229
|
+
setView('notification-proto')
|
|
230
|
+
setMenuOpen(true)
|
|
231
|
+
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
if (viewRef.current === 'notification-proto') {
|
|
234
|
+
setMenuOpen(false)
|
|
235
|
+
setView('menu')
|
|
236
|
+
setNotificationPath(null)
|
|
237
|
+
}
|
|
238
|
+
}, 6000)
|
|
239
|
+
} catch (err) {
|
|
240
|
+
setProtoError(err.message || 'Network error')
|
|
241
|
+
} finally {
|
|
242
|
+
setProtoSubmitting(false)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function showCreateForm() {
|
|
247
|
+
resetCreateForm()
|
|
248
|
+
setView('create')
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const viewRef = useRef(view)
|
|
252
|
+
viewRef.current = view
|
|
253
|
+
|
|
254
|
+
async function submitCreate() {
|
|
255
|
+
if (!canSubmit) return
|
|
256
|
+
setSubmitting(true)
|
|
257
|
+
setCreateError(null)
|
|
258
|
+
try {
|
|
259
|
+
const bridgeState = window.__storyboardCanvasBridgeState
|
|
260
|
+
const activeCanvasId = bridgeState?.canvasId || bridgeState?.name || canvasName
|
|
261
|
+
|
|
262
|
+
const res = await fetch(getApiUrl() + '/create-story', {
|
|
263
|
+
method: 'POST',
|
|
264
|
+
headers: { 'Content-Type': 'application/json' },
|
|
265
|
+
body: JSON.stringify({
|
|
266
|
+
name: kebabName,
|
|
267
|
+
location: createLocation,
|
|
268
|
+
format: createFormat,
|
|
269
|
+
canvasName: createLocation === 'canvas' ? activeCanvasId : undefined,
|
|
270
|
+
}),
|
|
271
|
+
})
|
|
272
|
+
const d = await res.json()
|
|
273
|
+
if (!res.ok) { setCreateError(d.error || 'Failed to create component'); setSubmitting(false); return }
|
|
274
|
+
|
|
275
|
+
addStoryWidget(d.name)
|
|
276
|
+
|
|
277
|
+
setNotificationPath(d.path)
|
|
278
|
+
setView('notification')
|
|
279
|
+
setMenuOpen(true)
|
|
280
|
+
setStoriesLoaded(false)
|
|
281
|
+
|
|
282
|
+
setTimeout(() => {
|
|
283
|
+
if (viewRef.current === 'notification') {
|
|
284
|
+
setMenuOpen(false)
|
|
285
|
+
setView('menu')
|
|
286
|
+
setNotificationPath(null)
|
|
287
|
+
}
|
|
288
|
+
}, 6000)
|
|
289
|
+
} catch (err) {
|
|
290
|
+
setCreateError(err.message || 'Network error')
|
|
291
|
+
} finally {
|
|
292
|
+
setSubmitting(false)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function handleOpenChange(open) {
|
|
297
|
+
setMenuOpen(open)
|
|
298
|
+
if (!open) {
|
|
299
|
+
if (view !== 'menu') {
|
|
300
|
+
setView('menu')
|
|
301
|
+
setNotificationPath(null)
|
|
302
|
+
resetCreateForm()
|
|
303
|
+
resetProtoForm()
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<DropdownMenu.Root open={menuOpen} onOpenChange={handleOpenChange}>
|
|
310
|
+
<DropdownMenu.Trigger asChild>
|
|
311
|
+
<TriggerButton
|
|
312
|
+
active={menuOpen}
|
|
313
|
+
size="icon-xl"
|
|
314
|
+
aria-label={config.ariaLabel || 'Add widget'}
|
|
315
|
+
tabIndex={tabindex}
|
|
316
|
+
>
|
|
317
|
+
{config.icon ? (
|
|
318
|
+
<Icon name={config.icon} size={16} {...(config.meta || {})} />
|
|
319
|
+
) : '+'}
|
|
320
|
+
</TriggerButton>
|
|
321
|
+
</DropdownMenu.Trigger>
|
|
322
|
+
|
|
323
|
+
<DropdownMenu.Content
|
|
324
|
+
side="top"
|
|
325
|
+
align="start"
|
|
326
|
+
sideOffset={16}
|
|
327
|
+
className="min-w-[180px]"
|
|
328
|
+
style={config.menuWidth ? { width: config.menuWidth } : undefined}
|
|
329
|
+
onInteractOutside={(e) => { if (view === 'create' || view === 'create-prototype') e.preventDefault() }}
|
|
330
|
+
>
|
|
331
|
+
{view === 'menu' && (
|
|
332
|
+
<>
|
|
333
|
+
<DropdownMenu.Label>Add to canvas</DropdownMenu.Label>
|
|
334
|
+
{widgetTypes.map((wt) => (
|
|
335
|
+
<DropdownMenu.Item key={wt.type} onClick={() => addWidget(wt.type)}>
|
|
336
|
+
{wt.label}
|
|
337
|
+
</DropdownMenu.Item>
|
|
338
|
+
))}
|
|
339
|
+
|
|
340
|
+
<DropdownMenu.Sub>
|
|
341
|
+
<DropdownMenu.SubTrigger>
|
|
342
|
+
Prototype
|
|
343
|
+
</DropdownMenu.SubTrigger>
|
|
344
|
+
<DropdownMenu.SubContent
|
|
345
|
+
className="min-w-[260px]"
|
|
346
|
+
onOpenAutoFocus={(e) => {
|
|
347
|
+
e.preventDefault()
|
|
348
|
+
}}
|
|
349
|
+
>
|
|
350
|
+
<SearchableList
|
|
351
|
+
items={prototypeItems}
|
|
352
|
+
loading={false}
|
|
353
|
+
filterFn={(proto, q) =>
|
|
354
|
+
proto.name.toLowerCase().includes(q) ||
|
|
355
|
+
proto.flows.some((f) => f.name.toLowerCase().includes(q))
|
|
356
|
+
}
|
|
357
|
+
renderItem={(proto) => {
|
|
358
|
+
const hasMultipleFlows = !proto.singleFlow && proto.flows.length > 1
|
|
359
|
+
const isExpanded = expandedProtos.has(proto.dirName)
|
|
360
|
+
const isFiltering = prototypeSearchRef.current?.value?.trim().length > 0
|
|
361
|
+
const showFlows = hasMultipleFlows && (isExpanded || isFiltering)
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<div key={proto.dirName}>
|
|
365
|
+
<DropdownMenu.Item
|
|
366
|
+
onSelect={(e) => {
|
|
367
|
+
if (hasMultipleFlows) {
|
|
368
|
+
e.preventDefault()
|
|
369
|
+
setExpandedProtos((prev) => {
|
|
370
|
+
const next = new Set(prev)
|
|
371
|
+
if (next.has(proto.dirName)) next.delete(proto.dirName)
|
|
372
|
+
else next.add(proto.dirName)
|
|
373
|
+
return next
|
|
374
|
+
})
|
|
375
|
+
} else {
|
|
376
|
+
addPrototypeWidget(proto.flows[0]?.route || `/${proto.dirName}`)
|
|
377
|
+
}
|
|
378
|
+
}}
|
|
379
|
+
>
|
|
380
|
+
<span className="flex items-center justify-between w-full">
|
|
381
|
+
<span>{proto.name}</span>
|
|
382
|
+
{hasMultipleFlows && (
|
|
383
|
+
<ChevronRight style={{
|
|
384
|
+
marginLeft: 'auto',
|
|
385
|
+
transition: 'transform 0.15s',
|
|
386
|
+
transform: showFlows ? 'rotate(90deg)' : 'none',
|
|
387
|
+
}} />
|
|
388
|
+
)}
|
|
389
|
+
</span>
|
|
390
|
+
</DropdownMenu.Item>
|
|
391
|
+
{showFlows && proto.flows.map((flow) => (
|
|
392
|
+
<DropdownMenu.Item
|
|
393
|
+
key={flow.route}
|
|
394
|
+
onSelect={() => addPrototypeWidget(flow.route)}
|
|
395
|
+
className="text-muted-foreground text-xs"
|
|
396
|
+
>
|
|
397
|
+
{flow.name}
|
|
398
|
+
</DropdownMenu.Item>
|
|
399
|
+
))}
|
|
400
|
+
</div>
|
|
401
|
+
)
|
|
402
|
+
}}
|
|
403
|
+
placeholder="Filter prototypes…"
|
|
404
|
+
emptyMessage="No prototypes found"
|
|
405
|
+
listClassName="max-h-[300px]"
|
|
406
|
+
inputRef={prototypeSearchRef}
|
|
407
|
+
header={
|
|
408
|
+
<>
|
|
409
|
+
<button
|
|
410
|
+
className="relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground w-full text-left bg-transparent border-none"
|
|
411
|
+
onClick={(e) => { e.preventDefault(); e.stopPropagation(); showCreateProtoForm() }}
|
|
412
|
+
onPointerDown={(e) => e.stopPropagation()}
|
|
413
|
+
>
|
|
414
|
+
<span className="font-medium">Create new prototype…</span>
|
|
415
|
+
</button>
|
|
416
|
+
{prototypeItems.length > 0 && <DropdownMenu.Separator />}
|
|
417
|
+
</>
|
|
418
|
+
}
|
|
419
|
+
/>
|
|
420
|
+
</DropdownMenu.SubContent>
|
|
421
|
+
</DropdownMenu.Sub>
|
|
422
|
+
|
|
423
|
+
{agents.length > 0 && (
|
|
424
|
+
<>
|
|
425
|
+
<DropdownMenu.Separator />
|
|
426
|
+
<DropdownMenu.Label>
|
|
427
|
+
<span style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
|
|
428
|
+
<Icon name="agents" size={12} />
|
|
429
|
+
Agents
|
|
430
|
+
</span>
|
|
431
|
+
</DropdownMenu.Label>
|
|
432
|
+
{agents.map((agent) => (
|
|
433
|
+
<DropdownMenu.Item key={agent.id} onClick={() => addWidget('agent', {
|
|
434
|
+
agentId: agent.id,
|
|
435
|
+
startupCommand: agent.startupCommand,
|
|
436
|
+
...(agent.defaultWidth ? { width: agent.defaultWidth } : {}),
|
|
437
|
+
...(agent.defaultHeight ? { height: agent.defaultHeight } : {}),
|
|
438
|
+
})}>
|
|
439
|
+
{agent.label}
|
|
440
|
+
</DropdownMenu.Item>
|
|
441
|
+
))}
|
|
442
|
+
</>
|
|
443
|
+
)}
|
|
444
|
+
|
|
445
|
+
<DropdownMenu.Sub>
|
|
446
|
+
<DropdownMenu.SubTrigger>
|
|
447
|
+
Component
|
|
448
|
+
</DropdownMenu.SubTrigger>
|
|
449
|
+
<DropdownMenu.SubContent
|
|
450
|
+
className="min-w-[200px]"
|
|
451
|
+
onOpenAutoFocus={(e) => {
|
|
452
|
+
e.preventDefault()
|
|
453
|
+
}}
|
|
454
|
+
>
|
|
455
|
+
<SearchableList
|
|
456
|
+
items={stories}
|
|
457
|
+
loading={!storiesLoaded}
|
|
458
|
+
filterFn={(story, q) =>
|
|
459
|
+
story.name.toLowerCase().includes(q) ||
|
|
460
|
+
story.path.toLowerCase().includes(q)
|
|
461
|
+
}
|
|
462
|
+
renderItem={(story) => (
|
|
463
|
+
<DropdownMenu.Item key={story.name} onClick={() => addStoryWidget(story.name)}>
|
|
464
|
+
<span className="flex flex-col">
|
|
465
|
+
<span>{story.name}</span>
|
|
466
|
+
<span className="text-xs text-muted-foreground">{story.path}</span>
|
|
467
|
+
</span>
|
|
468
|
+
</DropdownMenu.Item>
|
|
469
|
+
)}
|
|
470
|
+
placeholder="Filter components…"
|
|
471
|
+
emptyMessage="No components found"
|
|
472
|
+
loadingMessage="Loading components…"
|
|
473
|
+
listClassName="max-h-[260px]"
|
|
474
|
+
inputRef={componentSearchRef}
|
|
475
|
+
header={
|
|
476
|
+
<>
|
|
477
|
+
<button
|
|
478
|
+
className="relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground w-full text-left bg-transparent border-none"
|
|
479
|
+
onClick={(e) => { e.preventDefault(); e.stopPropagation(); showCreateForm() }}
|
|
480
|
+
onPointerDown={(e) => e.stopPropagation()}
|
|
481
|
+
>
|
|
482
|
+
<span className="font-medium">Create new component…</span>
|
|
483
|
+
</button>
|
|
484
|
+
{stories.length > 0 && <DropdownMenu.Separator />}
|
|
485
|
+
</>
|
|
486
|
+
}
|
|
487
|
+
/>
|
|
488
|
+
</DropdownMenu.SubContent>
|
|
489
|
+
</DropdownMenu.Sub>
|
|
490
|
+
|
|
491
|
+
<DropdownMenu.Separator />
|
|
492
|
+
<div className="px-2 py-1.5 text-xs text-muted-foreground flex flex-row items-baseline">
|
|
493
|
+
<span className="inline-flex w-2 h-2 rounded-full mr-1.5" style={{ background: 'hsl(212, 92%, 45%)' }}></span>
|
|
494
|
+
Only available in dev environment
|
|
495
|
+
</div>
|
|
496
|
+
</>
|
|
497
|
+
)}
|
|
498
|
+
|
|
499
|
+
{view === 'create' && (
|
|
500
|
+
<div
|
|
501
|
+
className="p-3 space-y-3 min-w-[280px]"
|
|
502
|
+
onKeyDown={(e) => { if (e.key === 'Enter' && canSubmit) submitCreate(); if (e.key === 'Escape') setView('menu') }}
|
|
503
|
+
onClick={(e) => e.stopPropagation()}
|
|
504
|
+
onPointerDown={(e) => e.stopPropagation()}
|
|
505
|
+
>
|
|
506
|
+
<div className="flex items-center justify-between">
|
|
507
|
+
<span className="text-sm font-medium">Create component</span>
|
|
508
|
+
<button className="text-muted-foreground hover:text-foreground text-xs bg-transparent border-none cursor-pointer p-0.5" onClick={() => setView('menu')}>← Back</button>
|
|
509
|
+
</div>
|
|
510
|
+
|
|
511
|
+
<div className="space-y-1">
|
|
512
|
+
<Label htmlFor="sb-create-comp-name" className="text-xs">Name</Label>
|
|
513
|
+
<Input id="sb-create-comp-name" placeholder="e.g. user-card" autoComplete="off" spellCheck={false} value={createName} onChange={(e) => setCreateName(e.target.value)} className="h-8 text-sm" />
|
|
514
|
+
{nameError && <p className="text-xs text-destructive">{nameError}</p>}
|
|
515
|
+
{filePreview && <p className="text-xs text-muted-foreground">{filePreview}</p>}
|
|
516
|
+
</div>
|
|
517
|
+
|
|
518
|
+
<fieldset className="space-y-1">
|
|
519
|
+
<Label className="text-xs">Location</Label>
|
|
520
|
+
<div className="flex flex-col gap-1">
|
|
521
|
+
<label className="flex items-center gap-1.5 text-xs cursor-pointer">
|
|
522
|
+
<input type="radio" name="sb-create-location" value="canvas" checked={createLocation === 'canvas'} onChange={() => setCreateLocation('canvas')} className="accent-primary" />
|
|
523
|
+
This canvas directory
|
|
524
|
+
</label>
|
|
525
|
+
<label className="flex items-center gap-1.5 text-xs cursor-pointer">
|
|
526
|
+
<input type="radio" name="sb-create-location" value="components" checked={createLocation === 'components'} onChange={() => setCreateLocation('components')} className="accent-primary" />
|
|
527
|
+
<code className="text-xs">src/components/</code>
|
|
528
|
+
</label>
|
|
529
|
+
</div>
|
|
530
|
+
</fieldset>
|
|
531
|
+
|
|
532
|
+
<fieldset className="space-y-1">
|
|
533
|
+
<Label className="text-xs">Format</Label>
|
|
534
|
+
<div className="flex gap-3">
|
|
535
|
+
<label className="flex items-center gap-1.5 text-xs cursor-pointer">
|
|
536
|
+
<input type="radio" name="sb-create-format" value="jsx" checked={createFormat === 'jsx'} onChange={() => setCreateFormat('jsx')} className="accent-primary" />
|
|
537
|
+
JSX
|
|
538
|
+
</label>
|
|
539
|
+
<label className="flex items-center gap-1.5 text-xs cursor-pointer">
|
|
540
|
+
<input type="radio" name="sb-create-format" value="tsx" checked={createFormat === 'tsx'} onChange={() => setCreateFormat('tsx')} className="accent-primary" />
|
|
541
|
+
TSX
|
|
542
|
+
</label>
|
|
543
|
+
</div>
|
|
544
|
+
</fieldset>
|
|
545
|
+
|
|
546
|
+
{createError && <p className="text-xs text-destructive">{createError}</p>}
|
|
547
|
+
|
|
548
|
+
<div className="flex gap-2 justify-end pt-1">
|
|
549
|
+
<Button variant="outline" size="sm" onClick={() => setView('menu')}>Cancel</Button>
|
|
550
|
+
<Button size="sm" onClick={submitCreate} disabled={!canSubmit}>{submitting ? 'Creating…' : 'Create'}</Button>
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
)}
|
|
554
|
+
|
|
555
|
+
{view === 'notification' && (
|
|
556
|
+
<div className="p-3 min-w-[260px] space-y-1">
|
|
557
|
+
<p className="text-sm font-medium">✓ Component added to canvas</p>
|
|
558
|
+
{notificationPath && (
|
|
559
|
+
<>
|
|
560
|
+
<p className="text-xs text-muted-foreground">To edit your component, go to</p>
|
|
561
|
+
<code className="text-xs block bg-muted px-2 py-1 rounded">{notificationPath}</code>
|
|
562
|
+
</>
|
|
563
|
+
)}
|
|
564
|
+
</div>
|
|
565
|
+
)}
|
|
566
|
+
|
|
567
|
+
{view === 'create-prototype' && (
|
|
568
|
+
<div
|
|
569
|
+
className="p-3 space-y-3 min-w-[280px]"
|
|
570
|
+
onKeyDown={(e) => { if (e.key === 'Enter' && canSubmitProto) submitCreateProto(); if (e.key === 'Escape') setView('menu') }}
|
|
571
|
+
onClick={(e) => e.stopPropagation()}
|
|
572
|
+
onPointerDown={(e) => e.stopPropagation()}
|
|
573
|
+
>
|
|
574
|
+
<div className="flex items-center justify-between">
|
|
575
|
+
<span className="text-sm font-medium">Create prototype</span>
|
|
576
|
+
<button className="text-muted-foreground hover:text-foreground text-xs bg-transparent border-none cursor-pointer p-0.5" onClick={() => setView('menu')}>← Back</button>
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
<div className="space-y-1">
|
|
580
|
+
<Label htmlFor="sb-create-proto-name" className="text-xs">Name</Label>
|
|
581
|
+
<Input id="sb-create-proto-name" placeholder="e.g. my-prototype" autoComplete="off" spellCheck={false} value={protoName} onChange={(e) => setProtoName(e.target.value)} className="h-8 text-sm" />
|
|
582
|
+
{protoNameError && <p className="text-xs text-destructive">{protoNameError}</p>}
|
|
583
|
+
{protoRoutePreview && <p className="text-xs text-muted-foreground">Route: <code>{protoRoutePreview}</code></p>}
|
|
584
|
+
</div>
|
|
585
|
+
|
|
586
|
+
{protoError && <p className="text-xs text-destructive">{protoError}</p>}
|
|
587
|
+
|
|
588
|
+
<div className="flex gap-2 justify-end pt-1">
|
|
589
|
+
<Button variant="outline" size="sm" onClick={() => setView('menu')}>Cancel</Button>
|
|
590
|
+
<Button size="sm" onClick={submitCreateProto} disabled={!canSubmitProto}>{protoSubmitting ? 'Creating…' : 'Create'}</Button>
|
|
591
|
+
</div>
|
|
592
|
+
</div>
|
|
593
|
+
)}
|
|
594
|
+
|
|
595
|
+
{view === 'notification-proto' && (
|
|
596
|
+
<div className="p-3 min-w-[260px] space-y-1">
|
|
597
|
+
<p className="text-sm font-medium">✓ Prototype created</p>
|
|
598
|
+
{notificationPath && (
|
|
599
|
+
<>
|
|
600
|
+
<p className="text-xs text-muted-foreground">Created at</p>
|
|
601
|
+
<code className="text-xs block bg-muted px-2 py-1 rounded">{notificationPath}</code>
|
|
602
|
+
</>
|
|
603
|
+
)}
|
|
604
|
+
</div>
|
|
605
|
+
)}
|
|
606
|
+
</DropdownMenu.Content>
|
|
607
|
+
</DropdownMenu.Root>
|
|
608
|
+
)
|
|
609
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.canvas-snap-btn {
|
|
2
|
+
all: unset;
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
width: 38px;
|
|
8
|
+
height: 38px;
|
|
9
|
+
border-radius: 10px;
|
|
10
|
+
border: 2.5px solid var(--sb--trigger-border, var(--color-slate-400));
|
|
11
|
+
background: var(--sb--trigger-bg, var(--color-slate-100));
|
|
12
|
+
color: var(--sb--trigger-text, var(--color-slate-600));
|
|
13
|
+
transition: background 120ms;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.canvas-snap-btn:hover:not(:disabled) {
|
|
17
|
+
background: var(--sb--trigger-bg-hover, var(--color-slate-300));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.canvas-snap-btn-active {
|
|
21
|
+
background: var(--sb--trigger-bg-hover, var(--color-slate-300));
|
|
22
|
+
border-color: var(--sb--trigger-text, var(--color-slate-600));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.canvas-snap-btn-active:hover {
|
|
26
|
+
opacity: 0.85;
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CanvasSnap — standalone snap-to-grid toggle button.
|
|
3
|
+
*/
|
|
4
|
+
import { useState, useEffect } from 'react'
|
|
5
|
+
import './CanvasSnap.css'
|
|
6
|
+
import * as Tooltip from './lib/components/ui/tooltip/index.js'
|
|
7
|
+
import Icon from './svelte-plugin-ui/components/Icon.jsx'
|
|
8
|
+
|
|
9
|
+
export default function CanvasSnap({ config = {}, data, tabindex = -1 }) {
|
|
10
|
+
const [snapEnabled, setSnapEnabled] = useState(false)
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
function handleSnapState(e) {
|
|
14
|
+
setSnapEnabled(!!e.detail?.snapEnabled)
|
|
15
|
+
}
|
|
16
|
+
document.addEventListener('storyboard:canvas:snap-state', handleSnapState)
|
|
17
|
+
|
|
18
|
+
// Broadcast configured gridSize on mount
|
|
19
|
+
const gridSize = config.gridSize
|
|
20
|
+
if (gridSize) {
|
|
21
|
+
document.dispatchEvent(new CustomEvent('storyboard:canvas:grid-size', {
|
|
22
|
+
detail: { gridSize }
|
|
23
|
+
}))
|
|
24
|
+
}
|
|
25
|
+
// Request current snap state (may have dispatched before we mounted)
|
|
26
|
+
document.dispatchEvent(new CustomEvent('storyboard:canvas:snap-state-request'))
|
|
27
|
+
|
|
28
|
+
return () => {
|
|
29
|
+
document.removeEventListener('storyboard:canvas:snap-state', handleSnapState)
|
|
30
|
+
}
|
|
31
|
+
}, [config.gridSize])
|
|
32
|
+
|
|
33
|
+
if (!data) return null
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Tooltip.Root>
|
|
37
|
+
<Tooltip.Trigger>
|
|
38
|
+
<button
|
|
39
|
+
className={`canvas-snap-btn${snapEnabled ? ' canvas-snap-btn-active' : ''}`}
|
|
40
|
+
onClick={() => data.toggleSnap()}
|
|
41
|
+
aria-label={config.label || 'Snap to grid'}
|
|
42
|
+
aria-pressed={snapEnabled}
|
|
43
|
+
tabIndex={tabindex}
|
|
44
|
+
>
|
|
45
|
+
<Icon name={config.icon || 'iconoir/view-grid'} size={16} {...(config.meta || {})} />
|
|
46
|
+
</button>
|
|
47
|
+
</Tooltip.Trigger>
|
|
48
|
+
<Tooltip.Content side="top">{snapEnabled ? (config.labelOn || 'Snap to grid (on)') : (config.labelOff || 'Snap to grid (off)')}</Tooltip.Content>
|
|
49
|
+
</Tooltip.Root>
|
|
50
|
+
)
|
|
51
|
+
}
|