@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,304 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo, useCallback } from 'react'
|
|
2
|
+
import { Button } from '../../../lib/components/ui/button/index.js'
|
|
3
|
+
import { Input } from '../../../lib/components/ui/input/index.js'
|
|
4
|
+
import { Label } from '../../../lib/components/ui/label/index.js'
|
|
5
|
+
import * as Panel from '../../../lib/components/ui/panel/index.js'
|
|
6
|
+
import * as DropdownMenu from '../../../lib/components/ui/dropdown-menu/index.js'
|
|
7
|
+
import * as Alert from '../../../lib/components/ui/alert/index.js'
|
|
8
|
+
|
|
9
|
+
function getApiUrl() {
|
|
10
|
+
const basePath = window.__STORYBOARD_BASE_PATH__ || '/'
|
|
11
|
+
return basePath.replace(/\/$/, '') + '/_storyboard/workshop/pages'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function CreatePageForm({ onClose }) {
|
|
15
|
+
const [selectedPrototype, setSelectedPrototype] = useState('')
|
|
16
|
+
const [pagePath, setPagePath] = useState('')
|
|
17
|
+
const [template, setTemplate] = useState('')
|
|
18
|
+
const [prototypes, setPrototypes] = useState([])
|
|
19
|
+
const [partials, setPartials] = useState([])
|
|
20
|
+
const [loading, setLoading] = useState(true)
|
|
21
|
+
const [submitting, setSubmitting] = useState(false)
|
|
22
|
+
const [error, setError] = useState(null)
|
|
23
|
+
const [success, setSuccess] = useState(null)
|
|
24
|
+
const [templateMenuOpen, setTemplateMenuOpen] = useState(false)
|
|
25
|
+
|
|
26
|
+
const selectedProtoEntry = useMemo(
|
|
27
|
+
() => (selectedPrototype ? prototypes.find((p) => p.name === selectedPrototype) : null),
|
|
28
|
+
[selectedPrototype, prototypes]
|
|
29
|
+
)
|
|
30
|
+
const pagePrefix = selectedPrototype ? `/${selectedPrototype}/` : '/prototype-name/'
|
|
31
|
+
const pageSuffix = pagePath.startsWith(pagePrefix) ? pagePath.slice(pagePrefix.length) : pagePath
|
|
32
|
+
const canSubmit = !!selectedPrototype && !!pageSuffix.trim() && !submitting
|
|
33
|
+
|
|
34
|
+
const templateChoices = useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
selectedPrototype
|
|
37
|
+
? partials.filter((p) => {
|
|
38
|
+
if (p.scope === 'global') return true
|
|
39
|
+
return (
|
|
40
|
+
p.prototype === selectedPrototype &&
|
|
41
|
+
(p.folder || '') === (selectedProtoEntry?.folder || '')
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
: partials.filter((p) => p.scope === 'global'),
|
|
45
|
+
[selectedPrototype, partials, selectedProtoEntry]
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const globalTemplateChoices = useMemo(
|
|
49
|
+
() => templateChoices.filter((p) => p.scope === 'global'),
|
|
50
|
+
[templateChoices]
|
|
51
|
+
)
|
|
52
|
+
const localTemplateChoices = useMemo(
|
|
53
|
+
() => templateChoices.filter((p) => p.scope === 'prototype'),
|
|
54
|
+
[templateChoices]
|
|
55
|
+
)
|
|
56
|
+
const localTemplateHeading = selectedPrototype || ''
|
|
57
|
+
const globalTemplates = useMemo(
|
|
58
|
+
() => globalTemplateChoices.filter((p) => p.kind === 'template'),
|
|
59
|
+
[globalTemplateChoices]
|
|
60
|
+
)
|
|
61
|
+
const globalRecipes = useMemo(
|
|
62
|
+
() => globalTemplateChoices.filter((p) => p.kind === 'recipe'),
|
|
63
|
+
[globalTemplateChoices]
|
|
64
|
+
)
|
|
65
|
+
const localTemplates = useMemo(
|
|
66
|
+
() => localTemplateChoices.filter((p) => p.kind === 'template'),
|
|
67
|
+
[localTemplateChoices]
|
|
68
|
+
)
|
|
69
|
+
const localRecipes = useMemo(
|
|
70
|
+
() => localTemplateChoices.filter((p) => p.kind === 'recipe'),
|
|
71
|
+
[localTemplateChoices]
|
|
72
|
+
)
|
|
73
|
+
const templateLabel = template
|
|
74
|
+
? templateChoices.find((c) => c.id === template)?.name ?? template
|
|
75
|
+
: 'Blank page'
|
|
76
|
+
|
|
77
|
+
// Fetch prototypes and partials on mount
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
let cancelled = false
|
|
80
|
+
;(async () => {
|
|
81
|
+
try {
|
|
82
|
+
const res = await fetch(getApiUrl())
|
|
83
|
+
if (res.ok && !cancelled) {
|
|
84
|
+
const data = await res.json()
|
|
85
|
+
setPrototypes(data.prototypes || [])
|
|
86
|
+
setPartials(data.partials || [])
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
/* defaults */
|
|
90
|
+
} finally {
|
|
91
|
+
if (!cancelled) setLoading(false)
|
|
92
|
+
}
|
|
93
|
+
})()
|
|
94
|
+
return () => { cancelled = true }
|
|
95
|
+
}, [])
|
|
96
|
+
|
|
97
|
+
// When selectedPrototype changes, reset pagePath
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!selectedPrototype) {
|
|
100
|
+
setPagePath('')
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
const prefix = `/${selectedPrototype}/`
|
|
104
|
+
setPagePath((prev) => (!prev || !prev.startsWith(prefix)) ? `${prefix}new-page` : prev)
|
|
105
|
+
}, [selectedPrototype])
|
|
106
|
+
|
|
107
|
+
// When template no longer available, clear it
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (!template) return
|
|
110
|
+
if (!templateChoices.some((c) => c.id === template)) setTemplate('')
|
|
111
|
+
}, [template, templateChoices])
|
|
112
|
+
|
|
113
|
+
const submit = useCallback(async () => {
|
|
114
|
+
if (!canSubmit) return
|
|
115
|
+
setSubmitting(true)
|
|
116
|
+
setError(null)
|
|
117
|
+
setSuccess(null)
|
|
118
|
+
try {
|
|
119
|
+
const res = await fetch(getApiUrl(), {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: { 'Content-Type': 'application/json' },
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
prototype: selectedPrototype,
|
|
124
|
+
folder: selectedProtoEntry?.folder || undefined,
|
|
125
|
+
path: pagePath.trim(),
|
|
126
|
+
template: template || undefined,
|
|
127
|
+
}),
|
|
128
|
+
})
|
|
129
|
+
const data = await res.json()
|
|
130
|
+
if (!res.ok) {
|
|
131
|
+
setError(data.error || 'Failed to create page')
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
setSuccess(`Created ${data.path}`)
|
|
135
|
+
} catch (err) {
|
|
136
|
+
setError(err.message || 'Network error')
|
|
137
|
+
} finally {
|
|
138
|
+
setSubmitting(false)
|
|
139
|
+
}
|
|
140
|
+
}, [canSubmit, selectedPrototype, selectedProtoEntry, pagePath, template])
|
|
141
|
+
|
|
142
|
+
function handleKeydown(e) {
|
|
143
|
+
if (e.key === 'Enter' && canSubmit) submit()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<>
|
|
148
|
+
<Panel.Header>
|
|
149
|
+
<Panel.Title>Create page</Panel.Title>
|
|
150
|
+
<Panel.Close />
|
|
151
|
+
</Panel.Header>
|
|
152
|
+
|
|
153
|
+
<div className="p-4 pt-2 space-y-5" onKeyDown={handleKeydown}>
|
|
154
|
+
<div className="space-y-1">
|
|
155
|
+
<Label htmlFor="sb-page-prototype">Prototype</Label>
|
|
156
|
+
<select
|
|
157
|
+
className="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
158
|
+
id="sb-page-prototype"
|
|
159
|
+
value={selectedPrototype}
|
|
160
|
+
onChange={(e) => setSelectedPrototype(e.target.value)}
|
|
161
|
+
disabled={loading}
|
|
162
|
+
>
|
|
163
|
+
<option value="">Select prototype</option>
|
|
164
|
+
{prototypes.map((p) => (
|
|
165
|
+
<option key={p.name} value={p.name}>
|
|
166
|
+
{p.folder ? `${p.folder} / ${p.name}` : p.name}
|
|
167
|
+
</option>
|
|
168
|
+
))}
|
|
169
|
+
</select>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<div className="space-y-1">
|
|
173
|
+
<Label htmlFor="sb-page-path">Page path</Label>
|
|
174
|
+
<div className="flex items-center gap-2">
|
|
175
|
+
<span className="text-xs text-muted-foreground font-mono whitespace-nowrap">
|
|
176
|
+
{pagePrefix}
|
|
177
|
+
</span>
|
|
178
|
+
<Input
|
|
179
|
+
id="sb-page-path"
|
|
180
|
+
placeholder="new-page"
|
|
181
|
+
value={pageSuffix}
|
|
182
|
+
onChange={(e) => {
|
|
183
|
+
const suffix = e.target.value.replace(/^\/+/, '')
|
|
184
|
+
setPagePath(`${pagePrefix}${suffix}`)
|
|
185
|
+
}}
|
|
186
|
+
disabled={!selectedPrototype}
|
|
187
|
+
/>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
<div className="space-y-1">
|
|
192
|
+
<Label>Template / recipe</Label>
|
|
193
|
+
<DropdownMenu.Root open={templateMenuOpen} onOpenChange={setTemplateMenuOpen}>
|
|
194
|
+
<DropdownMenu.Trigger asChild>
|
|
195
|
+
<button
|
|
196
|
+
className="flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
197
|
+
disabled={!selectedPrototype}
|
|
198
|
+
>
|
|
199
|
+
<span className={template ? 'text-foreground' : 'text-muted-foreground'}>
|
|
200
|
+
{templateLabel}
|
|
201
|
+
</span>
|
|
202
|
+
<svg
|
|
203
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
204
|
+
width="12"
|
|
205
|
+
height="12"
|
|
206
|
+
viewBox="0 0 24 24"
|
|
207
|
+
fill="none"
|
|
208
|
+
stroke="currentColor"
|
|
209
|
+
strokeWidth="2"
|
|
210
|
+
strokeLinecap="round"
|
|
211
|
+
strokeLinejoin="round"
|
|
212
|
+
className="text-muted-foreground"
|
|
213
|
+
>
|
|
214
|
+
<path d="m6 9 6 6 6-6" />
|
|
215
|
+
</svg>
|
|
216
|
+
</button>
|
|
217
|
+
</DropdownMenu.Trigger>
|
|
218
|
+
<DropdownMenu.Content side="left" align="start" sideOffset={8} className="min-w-[220px]">
|
|
219
|
+
{template && (
|
|
220
|
+
<>
|
|
221
|
+
<DropdownMenu.Item onSelect={() => { setTemplate(''); setTemplateMenuOpen(false) }}>
|
|
222
|
+
<span className="text-muted-foreground">Blank page</span>
|
|
223
|
+
</DropdownMenu.Item>
|
|
224
|
+
<DropdownMenu.Separator />
|
|
225
|
+
</>
|
|
226
|
+
)}
|
|
227
|
+
|
|
228
|
+
{globalTemplates.length > 0 && (
|
|
229
|
+
<DropdownMenu.Group>
|
|
230
|
+
<DropdownMenu.GroupHeading>Templates</DropdownMenu.GroupHeading>
|
|
231
|
+
{globalTemplates.map((item) => (
|
|
232
|
+
<DropdownMenu.Item key={item.id} onSelect={() => { setTemplate(item.id); setTemplateMenuOpen(false) }}>
|
|
233
|
+
{item.name}
|
|
234
|
+
</DropdownMenu.Item>
|
|
235
|
+
))}
|
|
236
|
+
</DropdownMenu.Group>
|
|
237
|
+
)}
|
|
238
|
+
|
|
239
|
+
{localTemplates.length > 0 && (
|
|
240
|
+
<>
|
|
241
|
+
<DropdownMenu.Separator />
|
|
242
|
+
<DropdownMenu.Group>
|
|
243
|
+
<DropdownMenu.GroupHeading>{localTemplateHeading} / Templates</DropdownMenu.GroupHeading>
|
|
244
|
+
{localTemplates.map((item) => (
|
|
245
|
+
<DropdownMenu.Item key={item.id} onSelect={() => { setTemplate(item.id); setTemplateMenuOpen(false) }}>
|
|
246
|
+
{item.name}
|
|
247
|
+
</DropdownMenu.Item>
|
|
248
|
+
))}
|
|
249
|
+
</DropdownMenu.Group>
|
|
250
|
+
</>
|
|
251
|
+
)}
|
|
252
|
+
|
|
253
|
+
{globalRecipes.length > 0 && (
|
|
254
|
+
<>
|
|
255
|
+
<DropdownMenu.Separator />
|
|
256
|
+
<DropdownMenu.Group>
|
|
257
|
+
<DropdownMenu.GroupHeading>Recipes</DropdownMenu.GroupHeading>
|
|
258
|
+
{globalRecipes.map((item) => (
|
|
259
|
+
<DropdownMenu.Item key={item.id} onSelect={() => { setTemplate(item.id); setTemplateMenuOpen(false) }}>
|
|
260
|
+
{item.name}
|
|
261
|
+
</DropdownMenu.Item>
|
|
262
|
+
))}
|
|
263
|
+
</DropdownMenu.Group>
|
|
264
|
+
</>
|
|
265
|
+
)}
|
|
266
|
+
|
|
267
|
+
{localRecipes.length > 0 && (
|
|
268
|
+
<>
|
|
269
|
+
<DropdownMenu.Separator />
|
|
270
|
+
<DropdownMenu.Group>
|
|
271
|
+
<DropdownMenu.GroupHeading>{localTemplateHeading} / Recipes</DropdownMenu.GroupHeading>
|
|
272
|
+
{localRecipes.map((item) => (
|
|
273
|
+
<DropdownMenu.Item key={item.id} onSelect={() => { setTemplate(item.id); setTemplateMenuOpen(false) }}>
|
|
274
|
+
{item.name}
|
|
275
|
+
</DropdownMenu.Item>
|
|
276
|
+
))}
|
|
277
|
+
</DropdownMenu.Group>
|
|
278
|
+
</>
|
|
279
|
+
)}
|
|
280
|
+
</DropdownMenu.Content>
|
|
281
|
+
</DropdownMenu.Root>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
{error && (
|
|
285
|
+
<Alert.Root variant="destructive">
|
|
286
|
+
<Alert.Description>{error}</Alert.Description>
|
|
287
|
+
</Alert.Root>
|
|
288
|
+
)}
|
|
289
|
+
{success && (
|
|
290
|
+
<Alert.Root>
|
|
291
|
+
<Alert.Description className="text-success">{success}</Alert.Description>
|
|
292
|
+
</Alert.Root>
|
|
293
|
+
)}
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
<Panel.Footer>
|
|
297
|
+
<Button variant="outline" onClick={onClose}>Cancel</Button>
|
|
298
|
+
<Button onClick={submit} disabled={!canSubmit}>
|
|
299
|
+
{submitting ? 'Creating…' : 'Create page'}
|
|
300
|
+
</Button>
|
|
301
|
+
</Panel.Footer>
|
|
302
|
+
</>
|
|
303
|
+
)
|
|
304
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CreatePrototypeForm — workshop form for creating a new prototype.
|
|
3
|
+
* Uses Radix-style React components for all form elements.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useState, useEffect, useMemo, useCallback } from 'react'
|
|
7
|
+
import { Button } from '../../../lib/components/ui/button/index.js'
|
|
8
|
+
import { Input } from '../../../lib/components/ui/input/index.js'
|
|
9
|
+
import { Label } from '../../../lib/components/ui/label/index.js'
|
|
10
|
+
import { Checkbox } from '../../../lib/components/ui/checkbox/index.js'
|
|
11
|
+
import * as Panel from '../../../lib/components/ui/panel/index.js'
|
|
12
|
+
import * as DropdownMenu from '../../../lib/components/ui/dropdown-menu/index.js'
|
|
13
|
+
import * as Alert from '../../../lib/components/ui/alert/index.js'
|
|
14
|
+
|
|
15
|
+
function getApiUrl() {
|
|
16
|
+
const basePath = window.__STORYBOARD_BASE_PATH__ || '/'
|
|
17
|
+
return basePath.replace(/\/$/, '') + '/_storyboard/workshop/prototypes'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function CreatePrototypeForm({ onClose }) {
|
|
21
|
+
const [name, setName] = useState('')
|
|
22
|
+
const [title, setTitle] = useState('')
|
|
23
|
+
const [titleTouched, setTitleTouched] = useState(false)
|
|
24
|
+
const [folder, setFolder] = useState('')
|
|
25
|
+
const [partial, setPartial] = useState('')
|
|
26
|
+
const [author, setAuthor] = useState('')
|
|
27
|
+
const [description, setDescription] = useState('')
|
|
28
|
+
const [createFlow, setCreateFlow] = useState(false)
|
|
29
|
+
const [isExternal, setIsExternal] = useState(false)
|
|
30
|
+
const [externalUrl, setExternalUrl] = useState('')
|
|
31
|
+
|
|
32
|
+
const [folders, setFolders] = useState([])
|
|
33
|
+
const [partials, setPartials] = useState([])
|
|
34
|
+
const [loading, setLoading] = useState(true)
|
|
35
|
+
const [submitting, setSubmitting] = useState(false)
|
|
36
|
+
const [error, setError] = useState(null)
|
|
37
|
+
const [success, setSuccess] = useState(null)
|
|
38
|
+
const [templateMenuOpen, setTemplateMenuOpen] = useState(false)
|
|
39
|
+
|
|
40
|
+
// Derived values
|
|
41
|
+
const kebabName = useMemo(
|
|
42
|
+
() => name.replace(/[^a-zA-Z0-9\s_-]/g, '').trim().replace(/[\s_]+/g, '-').toLowerCase().replace(/-+/g, '-').replace(/^-|-$/g, ''),
|
|
43
|
+
[name]
|
|
44
|
+
)
|
|
45
|
+
const autoTitle = useMemo(
|
|
46
|
+
() => kebabName ? kebabName.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join('').replace(/([A-Z])/g, ' $1').trim() : '',
|
|
47
|
+
[kebabName]
|
|
48
|
+
)
|
|
49
|
+
const displayTitle = titleTouched ? title : autoTitle
|
|
50
|
+
const routePreview = kebabName ? `/${kebabName}` : ''
|
|
51
|
+
const nameError = useMemo(() => {
|
|
52
|
+
if (name.trim() && !kebabName) return 'Name must contain at least one alphanumeric character'
|
|
53
|
+
if (name.trim() && !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(kebabName)) return 'Name must be kebab-case'
|
|
54
|
+
return null
|
|
55
|
+
}, [name, kebabName])
|
|
56
|
+
const urlError = useMemo(() => {
|
|
57
|
+
if (!isExternal || !externalUrl.trim()) return null
|
|
58
|
+
try {
|
|
59
|
+
const parsed = new URL(externalUrl.trim())
|
|
60
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return 'Must use http: or https: protocol'
|
|
61
|
+
return null
|
|
62
|
+
} catch { return 'Must be a valid URL (e.g. https://example.com)' }
|
|
63
|
+
}, [isExternal, externalUrl])
|
|
64
|
+
const canSubmit = !!kebabName && !nameError && !submitting && (!isExternal || (!!externalUrl.trim() && !urlError))
|
|
65
|
+
|
|
66
|
+
const selectedFolderLabel = folder ? `${folder}.folder` : ''
|
|
67
|
+
const scopedPartials = useMemo(
|
|
68
|
+
() => partials.filter(p => p.scope === 'global' || (!folder ? false : p.folder === folder)),
|
|
69
|
+
[partials, folder]
|
|
70
|
+
)
|
|
71
|
+
const templateLabel = partial ? scopedPartials.find(p => p.id === partial)?.name ?? partial : 'No template'
|
|
72
|
+
const templates = useMemo(() => scopedPartials.filter(p => p.kind === 'template'), [scopedPartials])
|
|
73
|
+
const recipes = useMemo(() => scopedPartials.filter(p => p.kind === 'recipe'), [scopedPartials])
|
|
74
|
+
const globalTemplates = useMemo(() => templates.filter(p => p.scope === 'global'), [templates])
|
|
75
|
+
const globalRecipes = useMemo(() => recipes.filter(p => p.scope === 'global'), [recipes])
|
|
76
|
+
const localTemplates = useMemo(() => templates.filter(p => p.scope === 'prototype'), [templates])
|
|
77
|
+
const localRecipes = useMemo(() => recipes.filter(p => p.scope === 'prototype'), [recipes])
|
|
78
|
+
|
|
79
|
+
// Clear partial if no longer in scopedPartials
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (!partial) return
|
|
82
|
+
const stillAvailable = scopedPartials.some(p => p.id === partial)
|
|
83
|
+
if (!stillAvailable) setPartial('')
|
|
84
|
+
}, [scopedPartials, partial])
|
|
85
|
+
|
|
86
|
+
// Fetch folders and partials on mount
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
let cancelled = false
|
|
89
|
+
async function load() {
|
|
90
|
+
try {
|
|
91
|
+
const res = await fetch(getApiUrl())
|
|
92
|
+
if (res.ok && !cancelled) {
|
|
93
|
+
const data = await res.json()
|
|
94
|
+
setFolders(data.folders || [])
|
|
95
|
+
if (data.partials?.length) setPartials(data.partials)
|
|
96
|
+
}
|
|
97
|
+
} catch { /* defaults */ } finally { if (!cancelled) setLoading(false) }
|
|
98
|
+
}
|
|
99
|
+
load()
|
|
100
|
+
return () => { cancelled = true }
|
|
101
|
+
}, [])
|
|
102
|
+
|
|
103
|
+
function handleTitleInput(e) { setTitle(e.target.value); setTitleTouched(true) }
|
|
104
|
+
function handleTitleBlur() { if (!title.trim()) setTitleTouched(false) }
|
|
105
|
+
|
|
106
|
+
const submit = useCallback(async () => {
|
|
107
|
+
if (!canSubmit) return
|
|
108
|
+
setSubmitting(true); setError(null); setSuccess(null)
|
|
109
|
+
try {
|
|
110
|
+
const payload = { name: kebabName, title: displayTitle, folder: folder || undefined, author: author.trim() || undefined, description: description.trim() || undefined }
|
|
111
|
+
if (isExternal) {
|
|
112
|
+
payload.url = externalUrl.trim()
|
|
113
|
+
} else {
|
|
114
|
+
payload.recipe = partial || undefined
|
|
115
|
+
payload.createFlow = createFlow
|
|
116
|
+
}
|
|
117
|
+
const res = await fetch(getApiUrl(), {
|
|
118
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
119
|
+
body: JSON.stringify(payload),
|
|
120
|
+
})
|
|
121
|
+
const data = await res.json()
|
|
122
|
+
if (!res.ok) { setError(data.error || 'Failed to create prototype'); return }
|
|
123
|
+
setSuccess(`Created ${data.path}`)
|
|
124
|
+
if (data.isExternal) {
|
|
125
|
+
setTimeout(() => onClose?.(), 1500)
|
|
126
|
+
} else {
|
|
127
|
+
setTimeout(() => { const base = (window.__STORYBOARD_BASE_PATH__ || '/').replace(/\/$/, ''); window.location.href = base + data.route }, 1500)
|
|
128
|
+
}
|
|
129
|
+
} catch (err) { setError(err.message || 'Network error') } finally { setSubmitting(false) }
|
|
130
|
+
}, [canSubmit, kebabName, displayTitle, folder, author, description, isExternal, externalUrl, partial, createFlow, onClose])
|
|
131
|
+
|
|
132
|
+
function handleKeydown(e) { if (e.key === 'Enter' && canSubmit) submit() }
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
<Panel.Header>
|
|
137
|
+
<Panel.Title>Create prototype</Panel.Title>
|
|
138
|
+
<Panel.Close />
|
|
139
|
+
</Panel.Header>
|
|
140
|
+
|
|
141
|
+
<div className="p-4 pt-2 space-y-3" onKeyDown={handleKeydown}>
|
|
142
|
+
<div className="space-y-1">
|
|
143
|
+
<Label htmlFor="sb-proto-name">Name</Label>
|
|
144
|
+
<Input id="sb-proto-name" placeholder="e.g. my-prototype" autoComplete="off" spellCheck={false} value={name} onChange={e => setName(e.target.value)} />
|
|
145
|
+
{nameError && <p className="text-sm text-destructive">{nameError}</p>}
|
|
146
|
+
{routePreview && !isExternal && <p className="text-xs text-muted-foreground">Route: <code className="px-1 py-0.5 bg-muted rounded font-mono text-foreground text-xs">{routePreview}</code></p>}
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div className="flex items-center gap-2">
|
|
150
|
+
<Checkbox id="sb-proto-external" checked={isExternal} onCheckedChange={setIsExternal} />
|
|
151
|
+
<Label htmlFor="sb-proto-external" className="text-sm font-normal cursor-pointer">External prototype</Label>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
{isExternal && (
|
|
155
|
+
<div className="space-y-1">
|
|
156
|
+
<Label htmlFor="sb-proto-url">URL</Label>
|
|
157
|
+
<Input id="sb-proto-url" placeholder="https://example.com/prototype" autoComplete="off" spellCheck={false} value={externalUrl} onChange={e => setExternalUrl(e.target.value)} />
|
|
158
|
+
{urlError && <p className="text-sm text-destructive">{urlError}</p>}
|
|
159
|
+
</div>
|
|
160
|
+
)}
|
|
161
|
+
|
|
162
|
+
<div className="space-y-1">
|
|
163
|
+
<Label htmlFor="sb-proto-title">Title</Label>
|
|
164
|
+
<Input id="sb-proto-title" placeholder={autoTitle || 'Auto-derived from name'} value={displayTitle} onChange={handleTitleInput} onBlur={handleTitleBlur} />
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div className="grid grid-cols-2 gap-3">
|
|
168
|
+
<div className="space-y-1">
|
|
169
|
+
<Label htmlFor="sb-proto-folder">Folder</Label>
|
|
170
|
+
<select
|
|
171
|
+
className="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
172
|
+
id="sb-proto-folder"
|
|
173
|
+
value={folder}
|
|
174
|
+
onChange={e => setFolder(e.target.value)}
|
|
175
|
+
disabled={loading}
|
|
176
|
+
>
|
|
177
|
+
<option value="">None</option>
|
|
178
|
+
{folders.map(f => <option key={f} value={f}>{f}</option>)}
|
|
179
|
+
</select>
|
|
180
|
+
</div>
|
|
181
|
+
{!isExternal && (
|
|
182
|
+
<div className="space-y-1">
|
|
183
|
+
<Label>Template</Label>
|
|
184
|
+
<DropdownMenu.Root open={templateMenuOpen} onOpenChange={setTemplateMenuOpen}>
|
|
185
|
+
<DropdownMenu.Trigger asChild>
|
|
186
|
+
<button
|
|
187
|
+
className="flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
188
|
+
disabled={loading}
|
|
189
|
+
>
|
|
190
|
+
<span className={partial ? 'text-foreground' : 'text-muted-foreground'}>{templateLabel}</span>
|
|
191
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="text-muted-foreground"><path d="m6 9 6 6 6-6"/></svg>
|
|
192
|
+
</button>
|
|
193
|
+
</DropdownMenu.Trigger>
|
|
194
|
+
<DropdownMenu.Content side="left" align="start" sideOffset={8} className="min-w-[180px]">
|
|
195
|
+
{partial && (
|
|
196
|
+
<>
|
|
197
|
+
<DropdownMenu.Item onSelect={() => { setPartial(''); setTemplateMenuOpen(false) }}>
|
|
198
|
+
<span className="text-muted-foreground">Clear selection</span>
|
|
199
|
+
</DropdownMenu.Item>
|
|
200
|
+
<DropdownMenu.Separator />
|
|
201
|
+
</>
|
|
202
|
+
)}
|
|
203
|
+
|
|
204
|
+
{globalTemplates.length > 0 && (
|
|
205
|
+
<DropdownMenu.Group>
|
|
206
|
+
<DropdownMenu.GroupHeading>Templates</DropdownMenu.GroupHeading>
|
|
207
|
+
{globalTemplates.map(t => (
|
|
208
|
+
<DropdownMenu.Item key={t.id} onSelect={() => { setPartial(t.id); setTemplateMenuOpen(false) }}>
|
|
209
|
+
{t.name}
|
|
210
|
+
</DropdownMenu.Item>
|
|
211
|
+
))}
|
|
212
|
+
</DropdownMenu.Group>
|
|
213
|
+
)}
|
|
214
|
+
|
|
215
|
+
{localTemplates.length > 0 && (
|
|
216
|
+
<>
|
|
217
|
+
<DropdownMenu.Separator />
|
|
218
|
+
<DropdownMenu.Group>
|
|
219
|
+
<DropdownMenu.GroupHeading>{selectedFolderLabel || 'Prototype local'} / Templates</DropdownMenu.GroupHeading>
|
|
220
|
+
{localTemplates.map(t => (
|
|
221
|
+
<DropdownMenu.Item key={t.id} onSelect={() => { setPartial(t.id); setTemplateMenuOpen(false) }}>
|
|
222
|
+
{t.name}
|
|
223
|
+
</DropdownMenu.Item>
|
|
224
|
+
))}
|
|
225
|
+
</DropdownMenu.Group>
|
|
226
|
+
</>
|
|
227
|
+
)}
|
|
228
|
+
|
|
229
|
+
{globalRecipes.length > 0 && (
|
|
230
|
+
<>
|
|
231
|
+
<DropdownMenu.Separator />
|
|
232
|
+
<DropdownMenu.Group>
|
|
233
|
+
<DropdownMenu.GroupHeading>Recipes</DropdownMenu.GroupHeading>
|
|
234
|
+
{globalRecipes.map(r => (
|
|
235
|
+
<DropdownMenu.Item key={r.id} onSelect={() => { setPartial(r.id); setTemplateMenuOpen(false) }}>
|
|
236
|
+
{r.name}
|
|
237
|
+
</DropdownMenu.Item>
|
|
238
|
+
))}
|
|
239
|
+
</DropdownMenu.Group>
|
|
240
|
+
</>
|
|
241
|
+
)}
|
|
242
|
+
|
|
243
|
+
{localRecipes.length > 0 && (
|
|
244
|
+
<>
|
|
245
|
+
<DropdownMenu.Separator />
|
|
246
|
+
<DropdownMenu.Group>
|
|
247
|
+
<DropdownMenu.GroupHeading>{selectedFolderLabel || 'Prototype local'} / Recipes</DropdownMenu.GroupHeading>
|
|
248
|
+
{localRecipes.map(r => (
|
|
249
|
+
<DropdownMenu.Item key={r.id} onSelect={() => { setPartial(r.id); setTemplateMenuOpen(false) }}>
|
|
250
|
+
{r.name}
|
|
251
|
+
</DropdownMenu.Item>
|
|
252
|
+
))}
|
|
253
|
+
</DropdownMenu.Group>
|
|
254
|
+
</>
|
|
255
|
+
)}
|
|
256
|
+
</DropdownMenu.Content>
|
|
257
|
+
</DropdownMenu.Root>
|
|
258
|
+
</div>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div className="space-y-1">
|
|
263
|
+
<Label htmlFor="sb-proto-author">Author</Label>
|
|
264
|
+
<Input id="sb-proto-author" placeholder="GitHub handle(s), comma-separated" value={author} onChange={e => setAuthor(e.target.value)} />
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
<div className="space-y-1">
|
|
268
|
+
<Label htmlFor="sb-proto-desc">Description</Label>
|
|
269
|
+
<Input id="sb-proto-desc" placeholder="Optional description" value={description} onChange={e => setDescription(e.target.value)} />
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
{!isExternal && (
|
|
273
|
+
<div className="flex items-center gap-2">
|
|
274
|
+
<Checkbox id="sb-proto-flow" checked={createFlow} onCheckedChange={setCreateFlow} />
|
|
275
|
+
<Label htmlFor="sb-proto-flow" className="text-sm font-normal cursor-pointer">Create flow file</Label>
|
|
276
|
+
</div>
|
|
277
|
+
)}
|
|
278
|
+
|
|
279
|
+
{error && <Alert.Root variant="destructive"><Alert.Description>{error}</Alert.Description></Alert.Root>}
|
|
280
|
+
{success && <Alert.Root><Alert.Description className="text-success">{success}</Alert.Description></Alert.Root>}
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<Panel.Footer>
|
|
284
|
+
<Button variant="outline" onClick={onClose}>Cancel</Button>
|
|
285
|
+
<Button onClick={submit} disabled={!canSubmit}>{submitting ? 'Creating\u2026' : 'Create'}</Button>
|
|
286
|
+
</Panel.Footer>
|
|
287
|
+
</>
|
|
288
|
+
)
|
|
289
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - serverSetup: Called by the server plugin to register API routes
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import CreatePrototypeForm from './CreatePrototypeForm.
|
|
13
|
+
import CreatePrototypeForm from './CreatePrototypeForm.jsx'
|
|
14
14
|
|
|
15
15
|
export const name = 'createPrototype'
|
|
16
16
|
export const label = 'Create prototype'
|