@assistkick/create 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/create.js +0 -0
- package/package.json +9 -7
- package/templates/assistkick-product-system/.env.example +1 -0
- package/templates/assistkick-product-system/local.db +0 -0
- package/templates/assistkick-product-system/package.json +4 -2
- package/templates/assistkick-product-system/packages/backend/package.json +2 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/agents.ts +165 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/files.test.ts +358 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/files.ts +356 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/git.ts +96 -1
- package/templates/assistkick-product-system/packages/backend/src/routes/graph.ts +1 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/kanban.ts +43 -4
- package/templates/assistkick-product-system/packages/backend/src/routes/pipeline.ts +200 -84
- package/templates/assistkick-product-system/packages/backend/src/routes/projects.ts +6 -3
- package/templates/assistkick-product-system/packages/backend/src/routes/terminal.ts +53 -17
- package/templates/assistkick-product-system/packages/backend/src/routes/video.ts +218 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/workflow_groups.ts +119 -0
- package/templates/assistkick-product-system/packages/backend/src/routes/workflows.ts +154 -0
- package/templates/assistkick-product-system/packages/backend/src/server.ts +81 -9
- package/templates/assistkick-product-system/packages/backend/src/services/agent_service.test.ts +489 -0
- package/templates/assistkick-product-system/packages/backend/src/services/agent_service.ts +416 -0
- package/templates/assistkick-product-system/packages/backend/src/services/bundle_service.test.ts +189 -0
- package/templates/assistkick-product-system/packages/backend/src/services/bundle_service.ts +182 -0
- package/templates/assistkick-product-system/packages/backend/src/services/init.ts +28 -78
- package/templates/assistkick-product-system/packages/backend/src/services/project_service.test.ts +16 -0
- package/templates/assistkick-product-system/packages/backend/src/services/project_service.ts +73 -2
- package/templates/assistkick-product-system/packages/backend/src/services/project_workspace_service.test.ts +4 -4
- package/templates/assistkick-product-system/packages/backend/src/services/project_workspace_service.ts +87 -11
- package/templates/assistkick-product-system/packages/backend/src/services/pty_session_manager.test.ts +210 -69
- package/templates/assistkick-product-system/packages/backend/src/services/pty_session_manager.ts +210 -215
- package/templates/assistkick-product-system/packages/backend/src/services/ssh_key_service.test.ts +162 -0
- package/templates/assistkick-product-system/packages/backend/src/services/ssh_key_service.ts +148 -0
- package/templates/assistkick-product-system/packages/backend/src/services/terminal_ws_handler.ts +11 -5
- package/templates/assistkick-product-system/packages/backend/src/services/tts_service.test.ts +64 -0
- package/templates/assistkick-product-system/packages/backend/src/services/tts_service.ts +134 -0
- package/templates/assistkick-product-system/packages/backend/src/services/video_render_service.test.ts +256 -0
- package/templates/assistkick-product-system/packages/backend/src/services/video_render_service.ts +258 -0
- package/templates/assistkick-product-system/packages/backend/src/services/workflow_group_service.ts +106 -0
- package/templates/assistkick-product-system/packages/backend/src/services/workflow_service.test.ts +275 -0
- package/templates/assistkick-product-system/packages/backend/src/services/workflow_service.ts +222 -0
- package/templates/assistkick-product-system/packages/frontend/package-lock.json +3455 -0
- package/templates/assistkick-product-system/packages/frontend/package.json +6 -0
- package/templates/assistkick-product-system/packages/frontend/src/App.tsx +8 -0
- package/templates/assistkick-product-system/packages/frontend/src/api/client.ts +456 -16
- package/templates/assistkick-product-system/packages/frontend/src/api/client_files.test.ts +172 -0
- package/templates/assistkick-product-system/packages/frontend/src/api/client_video.test.ts +238 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/AgentsView.tsx +307 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/CoherenceView.tsx +82 -66
- package/templates/assistkick-product-system/packages/frontend/src/components/CompositionPlaceholder.tsx +97 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/DesignSystemView.tsx +20 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/EditorTabBar.tsx +57 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/FileTree.tsx +313 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/FileTreeContextMenu.tsx +61 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/FileTreeInlineInput.tsx +73 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/FilesView.tsx +404 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/GitRepoModal.tsx +187 -56
- package/templates/assistkick-product-system/packages/frontend/src/components/GraphLegend.tsx +71 -73
- package/templates/assistkick-product-system/packages/frontend/src/components/GraphSettings.tsx +8 -8
- package/templates/assistkick-product-system/packages/frontend/src/components/GraphView.tsx +1 -1
- package/templates/assistkick-product-system/packages/frontend/src/components/InviteUserDialog.tsx +15 -11
- package/templates/assistkick-product-system/packages/frontend/src/components/KanbanView.tsx +202 -171
- package/templates/assistkick-product-system/packages/frontend/src/components/LoginPage.tsx +14 -14
- package/templates/assistkick-product-system/packages/frontend/src/components/ProjectSelector.tsx +54 -33
- package/templates/assistkick-product-system/packages/frontend/src/components/QaIssueSheet.tsx +32 -49
- package/templates/assistkick-product-system/packages/frontend/src/components/SidePanel.tsx +43 -48
- package/templates/assistkick-product-system/packages/frontend/src/components/TerminalView.tsx +121 -52
- package/templates/assistkick-product-system/packages/frontend/src/components/Toolbar.tsx +20 -14
- package/templates/assistkick-product-system/packages/frontend/src/components/UsersView.tsx +52 -52
- package/templates/assistkick-product-system/packages/frontend/src/components/VideoGallery.tsx +313 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/VideographyView.tsx +250 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/WorkflowsView.tsx +474 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/AccentBorderList.tsx +53 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/Button.tsx +87 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/ButtonGroup.tsx +29 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/ButtonShowcase.tsx +221 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/CardGlass.tsx +141 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/CompletionRing.tsx +30 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/ContentCard.tsx +34 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/IconButton.tsx +74 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/KanbanCard.tsx +103 -87
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/KanbanCardShowcase.tsx +9 -188
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/Kbd.tsx +11 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/KindBadge.tsx +21 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/NavBarSidekick.tsx +81 -37
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/SidePanelShowcase.tsx +370 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/SideSheet.tsx +64 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/ds/StatusDot.tsx +18 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/CheckCardPositionNode.tsx +36 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/CheckCycleCountNode.tsx +60 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/EndNode.tsx +42 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/GroupNode.tsx +189 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/NodePalette.tsx +123 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/RunAgentNode.tsx +51 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/SetCardMetadataNode.tsx +53 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/StartNode.tsx +18 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/TransitionCardNode.tsx +59 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/WorkflowCanvas.tsx +335 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/WorkflowMonitorModal.tsx +634 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/autoLayout.ts +103 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/edgeColors.ts +35 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/monitor_nodes.tsx +208 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/workflow_types.test.ts +119 -0
- package/templates/assistkick-product-system/packages/frontend/src/components/workflow/workflow_types.ts +107 -0
- package/templates/assistkick-product-system/packages/frontend/src/constants/graph.ts +13 -11
- package/templates/assistkick-product-system/packages/frontend/src/hooks/useAutoSave.ts +75 -0
- package/templates/assistkick-product-system/packages/frontend/src/hooks/useToast.tsx +16 -3
- package/templates/assistkick-product-system/packages/frontend/src/pages/accept_invitation_page.tsx +30 -27
- package/templates/assistkick-product-system/packages/frontend/src/pages/forgot_password_page.tsx +18 -15
- package/templates/assistkick-product-system/packages/frontend/src/pages/register_page.tsx +21 -18
- package/templates/assistkick-product-system/packages/frontend/src/pages/reset_password_page.tsx +28 -25
- package/templates/assistkick-product-system/packages/frontend/src/routes/AgentsRoute.tsx +6 -0
- package/templates/assistkick-product-system/packages/frontend/src/routes/CoherenceRoute.tsx +1 -1
- package/templates/assistkick-product-system/packages/frontend/src/routes/DashboardLayout.tsx +2 -2
- package/templates/assistkick-product-system/packages/frontend/src/routes/FilesRoute.tsx +13 -0
- package/templates/assistkick-product-system/packages/frontend/src/routes/GraphRoute.tsx +2 -2
- package/templates/assistkick-product-system/packages/frontend/src/routes/VideographyRoute.tsx +13 -0
- package/templates/assistkick-product-system/packages/frontend/src/routes/WorkflowsRoute.tsx +6 -0
- package/templates/assistkick-product-system/packages/frontend/src/stores/useProjectStore.ts +6 -3
- package/templates/assistkick-product-system/packages/frontend/src/stores/useSidePanelStore.ts +4 -4
- package/templates/assistkick-product-system/packages/frontend/src/styles/index.css +275 -3535
- package/templates/assistkick-product-system/packages/frontend/src/utils/auto_save_service.test.ts +167 -0
- package/templates/assistkick-product-system/packages/frontend/src/utils/auto_save_service.ts +101 -0
- package/templates/assistkick-product-system/packages/frontend/src/utils/composition_matcher.test.ts +42 -0
- package/templates/assistkick-product-system/packages/frontend/src/utils/composition_matcher.ts +17 -0
- package/templates/assistkick-product-system/packages/frontend/src/utils/file_utils.test.ts +145 -0
- package/templates/assistkick-product-system/packages/frontend/src/utils/file_utils.ts +42 -0
- package/templates/assistkick-product-system/packages/frontend/src/utils/task_status.test.ts +4 -10
- package/templates/assistkick-product-system/packages/frontend/src/utils/task_status.ts +19 -1
- package/templates/assistkick-product-system/packages/frontend/vite.config.ts +5 -0
- package/templates/assistkick-product-system/packages/shared/db/local.db +0 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0004_tidy_matthew_murdock.sql +9 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0005_mysterious_falcon.sql +692 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0006_next_venom.sql +9 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0007_deep_barracuda.sql +39 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0008_puzzling_hannibal_king.sql +1 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0009_amused_beast.sql +8 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0010_spotty_moira_mactaggert.sql +9 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0011_goofy_snowbird.sql +3 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0011_supreme_doctor_octopus.sql +3 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/0013_reflective_prowler.sql +15 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0004_snapshot.json +921 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0005_snapshot.json +1042 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0006_snapshot.json +1101 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0007_snapshot.json +1336 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0008_snapshot.json +1275 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0009_snapshot.json +1327 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0010_snapshot.json +1393 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0011_snapshot.json +1436 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/0013_snapshot.json +1538 -0
- package/templates/assistkick-product-system/packages/shared/db/migrations/meta/_journal.json +70 -0
- package/templates/assistkick-product-system/packages/shared/db/schema.ts +113 -0
- package/templates/assistkick-product-system/packages/shared/lib/claude-service.ts +32 -7
- package/templates/assistkick-product-system/packages/shared/lib/constants.ts +9 -0
- package/templates/assistkick-product-system/packages/shared/lib/git_workflow.ts +12 -4
- package/templates/assistkick-product-system/packages/shared/lib/graph.ts +5 -0
- package/templates/assistkick-product-system/packages/shared/lib/workflow_engine.test.ts +1753 -0
- package/templates/assistkick-product-system/packages/shared/lib/workflow_engine.ts +1281 -0
- package/templates/assistkick-product-system/packages/shared/lib/workflow_orchestrator.ts +211 -0
- package/templates/assistkick-product-system/packages/shared/tools/add_node.test.ts +43 -0
- package/templates/assistkick-product-system/packages/shared/tools/add_node.ts +13 -2
- package/templates/assistkick-product-system/packages/shared/tools/get_kanban.ts +1 -1
- package/templates/assistkick-product-system/packages/shared/tools/migrate_epics.test.ts +226 -0
- package/templates/assistkick-product-system/packages/shared/tools/migrate_epics.ts +251 -0
- package/templates/assistkick-product-system/packages/shared/tools/update_node.ts +2 -2
- package/templates/assistkick-product-system/packages/shared/utils/hello_workflow.test.ts +10 -0
- package/templates/assistkick-product-system/packages/shared/utils/hello_workflow.ts +6 -0
- package/templates/assistkick-product-system/packages/video/Root.tsx +85 -0
- package/templates/assistkick-product-system/packages/video/components/email_scene.tsx +231 -0
- package/templates/assistkick-product-system/packages/video/components/outro_scene.tsx +153 -0
- package/templates/assistkick-product-system/packages/video/components/part_divider.tsx +90 -0
- package/templates/assistkick-product-system/packages/video/components/scene.tsx +226 -0
- package/templates/assistkick-product-system/packages/video/components/theme.ts +22 -0
- package/templates/assistkick-product-system/packages/video/components/title_scene.tsx +169 -0
- package/templates/assistkick-product-system/packages/video/components/video_split_layout.tsx +84 -0
- package/templates/assistkick-product-system/packages/video/compositions/.gitkeep +0 -0
- package/templates/assistkick-product-system/packages/video/index.ts +4 -0
- package/templates/assistkick-product-system/packages/video/package.json +28 -0
- package/templates/assistkick-product-system/packages/video/remotion.config.ts +11 -0
- package/templates/assistkick-product-system/packages/video/scripts/process_script.test.ts +326 -0
- package/templates/assistkick-product-system/packages/video/scripts/process_script.ts +630 -0
- package/templates/assistkick-product-system/packages/video/style.css +1 -0
- package/templates/assistkick-product-system/packages/video/tsconfig.json +18 -0
- package/templates/assistkick-product-system/tests/graph_legend.test.ts +2 -1
- package/templates/assistkick-product-system/tests/video_render_service.test.ts +179 -0
- package/templates/assistkick-product-system/tests/web_terminal.test.ts +219 -455
- package/templates/assistkick-product-system/tests/workflow_integration.test.ts +341 -0
- package/templates/skills/assistkick-developer/SKILL.md +3 -0
- package/templates/skills/assistkick-developer/references/react_development_guidelines.md +225 -0
- package/templates/skills/product-system/graph.json +1890 -0
- package/templates/skills/product-system/kanban.json +304 -0
- package/templates/skills/product-system/nodes/comp_001.md +56 -0
- package/templates/skills/product-system/nodes/comp_002.md +57 -0
- package/templates/skills/product-system/nodes/data_001.md +51 -0
- package/templates/skills/product-system/nodes/data_002.md +40 -0
- package/templates/skills/product-system/nodes/data_004.md +38 -0
- package/templates/skills/product-system/nodes/dec_001.md +34 -0
- package/templates/skills/product-system/nodes/dec_016.md +32 -0
- package/templates/skills/product-system/nodes/feat_008.md +30 -0
- package/templates/skills/video-composition-agent/SKILL.md +232 -0
- package/templates/skills/video-script-writer/SKILL.md +136 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AbsoluteFill, useCurrentFrame, useVideoConfig, interpolate } from 'remotion';
|
|
3
|
+
|
|
4
|
+
interface CompositionPlaceholderProps {
|
|
5
|
+
compositionId: string;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A placeholder composition component rendered by the Remotion Player
|
|
12
|
+
* when the actual composition bundle hasn't been loaded yet.
|
|
13
|
+
*
|
|
14
|
+
* Shows the composition ID, dimensions, and a simple animated progress bar
|
|
15
|
+
* to verify the player timeline and scrubbing work correctly.
|
|
16
|
+
*/
|
|
17
|
+
export const CompositionPlaceholder: React.FC<CompositionPlaceholderProps> = ({
|
|
18
|
+
compositionId,
|
|
19
|
+
width,
|
|
20
|
+
height,
|
|
21
|
+
}) => {
|
|
22
|
+
const frame = useCurrentFrame();
|
|
23
|
+
const { fps, durationInFrames } = useVideoConfig();
|
|
24
|
+
const progress = frame / durationInFrames;
|
|
25
|
+
const seconds = (frame / fps).toFixed(1);
|
|
26
|
+
|
|
27
|
+
const opacity = interpolate(frame, [0, 15], [0, 1], {
|
|
28
|
+
extrapolateRight: 'clamp',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<AbsoluteFill
|
|
33
|
+
style={{
|
|
34
|
+
backgroundColor: '#0e100e',
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
fontFamily: 'system-ui, sans-serif',
|
|
40
|
+
color: '#bbdedd',
|
|
41
|
+
opacity,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
style={{
|
|
46
|
+
fontSize: 14,
|
|
47
|
+
letterSpacing: '0.1em',
|
|
48
|
+
textTransform: 'uppercase',
|
|
49
|
+
marginBottom: 16,
|
|
50
|
+
color: '#6b7280',
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
Composition Preview
|
|
54
|
+
</div>
|
|
55
|
+
<div
|
|
56
|
+
style={{
|
|
57
|
+
fontSize: 28,
|
|
58
|
+
fontWeight: 600,
|
|
59
|
+
marginBottom: 8,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{compositionId}
|
|
63
|
+
</div>
|
|
64
|
+
<div
|
|
65
|
+
style={{
|
|
66
|
+
fontSize: 13,
|
|
67
|
+
color: '#6b7280',
|
|
68
|
+
marginBottom: 32,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{width}x{height} · {fps}fps · {seconds}s / {(durationInFrames / fps).toFixed(1)}s
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
{/* Progress bar */}
|
|
75
|
+
<div
|
|
76
|
+
style={{
|
|
77
|
+
width: '60%',
|
|
78
|
+
maxWidth: 400,
|
|
79
|
+
height: 4,
|
|
80
|
+
borderRadius: 2,
|
|
81
|
+
backgroundColor: '#1f2937',
|
|
82
|
+
overflow: 'hidden',
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<div
|
|
86
|
+
style={{
|
|
87
|
+
width: `${progress * 100}%`,
|
|
88
|
+
height: '100%',
|
|
89
|
+
borderRadius: 2,
|
|
90
|
+
backgroundColor: '#bbdedd',
|
|
91
|
+
transition: 'none',
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
</AbsoluteFill>
|
|
96
|
+
);
|
|
97
|
+
};
|
package/templates/assistkick-product-system/packages/frontend/src/components/DesignSystemView.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import { Columns3, Clock, FileText, Search, Settings } from 'lucide-react';
|
|
|
3
3
|
import { NavBarSidekick } from './ds/NavBarSidekick';
|
|
4
4
|
import type { NavItem as SidekickNavItem } from './ds/NavBarSidekick';
|
|
5
5
|
import { KanbanCardShowcase } from './ds/KanbanCardShowcase';
|
|
6
|
+
import { ButtonShowcase } from './ds/ButtonShowcase';
|
|
7
|
+
import { SidePanelShowcase } from './ds/SidePanelShowcase';
|
|
6
8
|
|
|
7
9
|
interface DesignSystemViewProps {
|
|
8
10
|
visible: boolean;
|
|
@@ -222,6 +224,15 @@ export function DesignSystemView({ visible }: DesignSystemViewProps) {
|
|
|
222
224
|
</div>
|
|
223
225
|
</Section>
|
|
224
226
|
|
|
227
|
+
{/* ── Side Panel ── */}
|
|
228
|
+
<Section title="Side Panel" defaultOpen>
|
|
229
|
+
<p className="mb-5 text-[13px] text-content-muted">
|
|
230
|
+
Card stack layout for the node detail side panel. Collapsible sections for description,
|
|
231
|
+
acceptance criteria, open questions, resolved questions, notes, work summaries, and relationships.
|
|
232
|
+
</p>
|
|
233
|
+
<SidePanelShowcase />
|
|
234
|
+
</Section>
|
|
235
|
+
|
|
225
236
|
{/* ── Kanban Card ── */}
|
|
226
237
|
<Section title="Kanban Card" defaultOpen>
|
|
227
238
|
<p className="mb-5 text-[13px] text-content-muted">
|
|
@@ -231,6 +242,15 @@ export function DesignSystemView({ visible }: DesignSystemViewProps) {
|
|
|
231
242
|
<KanbanCardShowcase />
|
|
232
243
|
</Section>
|
|
233
244
|
|
|
245
|
+
{/* ── Buttons ── */}
|
|
246
|
+
<Section title="Buttons" defaultOpen>
|
|
247
|
+
<p className="mb-5 text-[13px] text-content-muted">
|
|
248
|
+
Four button variants: Primary (accent fill with glow), Secondary (outline that fills on hover),
|
|
249
|
+
Ghost (subtle border), and Danger (dashed error border). Three sizes, icon-only, and grouped layouts.
|
|
250
|
+
</p>
|
|
251
|
+
<ButtonShowcase />
|
|
252
|
+
</Section>
|
|
253
|
+
|
|
234
254
|
{/* ── Colors ── */}
|
|
235
255
|
<Section title="Color Palette">
|
|
236
256
|
<p className="mb-5 text-[13px] text-content-muted">
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
export interface EditorTab {
|
|
5
|
+
path: string;
|
|
6
|
+
name: string;
|
|
7
|
+
language: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface EditorTabBarProps {
|
|
11
|
+
tabs: EditorTab[];
|
|
12
|
+
activeTabPath: string | null;
|
|
13
|
+
dirtyPaths: Set<string>;
|
|
14
|
+
onSelectTab: (path: string) => void;
|
|
15
|
+
onCloseTab: (path: string) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const EditorTabBar = ({ tabs, activeTabPath, dirtyPaths, onSelectTab, onCloseTab }: EditorTabBarProps) => {
|
|
19
|
+
const handleMiddleClick = useCallback((e: React.MouseEvent, path: string) => {
|
|
20
|
+
if (e.button === 1) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
onCloseTab(path);
|
|
23
|
+
}
|
|
24
|
+
}, [onCloseTab]);
|
|
25
|
+
|
|
26
|
+
const handleCloseClick = useCallback((e: React.MouseEvent, path: string) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
onCloseTab(path);
|
|
29
|
+
}, [onCloseTab]);
|
|
30
|
+
|
|
31
|
+
if (tabs.length === 0) return null;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="editor-tab-bar">
|
|
35
|
+
{tabs.map((tab) => (
|
|
36
|
+
<button
|
|
37
|
+
key={tab.path}
|
|
38
|
+
className={`editor-tab ${tab.path === activeTabPath ? 'editor-tab--active' : ''}`}
|
|
39
|
+
onClick={() => onSelectTab(tab.path)}
|
|
40
|
+
onMouseDown={(e) => handleMiddleClick(e, tab.path)}
|
|
41
|
+
title={tab.path}
|
|
42
|
+
>
|
|
43
|
+
{dirtyPaths.has(tab.path) && <span className="editor-tab__dirty">●</span>}
|
|
44
|
+
<span className="editor-tab__name">{tab.name}</span>
|
|
45
|
+
<span
|
|
46
|
+
className="editor-tab__close"
|
|
47
|
+
onClick={(e) => handleCloseClick(e, tab.path)}
|
|
48
|
+
role="button"
|
|
49
|
+
tabIndex={-1}
|
|
50
|
+
>
|
|
51
|
+
<X size={12} strokeWidth={2} />
|
|
52
|
+
</span>
|
|
53
|
+
</button>
|
|
54
|
+
))}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import React, { useState, useCallback, useRef } from 'react';
|
|
2
|
+
import { ChevronRight, ChevronDown, File, Folder, FolderOpen } from 'lucide-react';
|
|
3
|
+
import { FileTreeContextMenu } from './FileTreeContextMenu';
|
|
4
|
+
import { FileTreeInlineInput } from './FileTreeInlineInput';
|
|
5
|
+
import { getParentPath } from '../utils/file_utils';
|
|
6
|
+
import type { ContextMenuItem } from './FileTreeContextMenu';
|
|
7
|
+
|
|
8
|
+
export interface TreeEntry {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
type: 'file' | 'directory';
|
|
12
|
+
children?: TreeEntry[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface InlineInputState {
|
|
16
|
+
parentPath: string;
|
|
17
|
+
type: 'file' | 'directory';
|
|
18
|
+
mode: 'create' | 'rename';
|
|
19
|
+
initialValue: string;
|
|
20
|
+
targetPath?: string;
|
|
21
|
+
depth: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ContextMenuState {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
items: ContextMenuItem[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FileTreeCallbacks {
|
|
31
|
+
onFileSelect: (path: string, name: string) => void;
|
|
32
|
+
onCreateFile: (parentPath: string, name: string, type: 'file' | 'directory') => void;
|
|
33
|
+
onRename: (oldPath: string, newName: string) => void;
|
|
34
|
+
onDelete: (path: string, type: 'file' | 'directory') => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface FileTreeProps {
|
|
38
|
+
tree: TreeEntry[];
|
|
39
|
+
callbacks: FileTreeCallbacks;
|
|
40
|
+
selectedPath: string | null;
|
|
41
|
+
expandedPaths: Set<string>;
|
|
42
|
+
onToggleExpand: (path: string) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface FileTreeNodeProps {
|
|
46
|
+
entry: TreeEntry;
|
|
47
|
+
depth: number;
|
|
48
|
+
callbacks: FileTreeCallbacks;
|
|
49
|
+
selectedPath: string | null;
|
|
50
|
+
expandedPaths: Set<string>;
|
|
51
|
+
onToggleExpand: (path: string) => void;
|
|
52
|
+
inlineInput: InlineInputState | null;
|
|
53
|
+
onSetInlineInput: (state: InlineInputState | null) => void;
|
|
54
|
+
onContextMenu: (e: React.MouseEvent, entry: TreeEntry, depth: number) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ICON_SIZE = 14;
|
|
58
|
+
|
|
59
|
+
const FileTreeNode = ({
|
|
60
|
+
entry, depth, callbacks, selectedPath,
|
|
61
|
+
expandedPaths, onToggleExpand,
|
|
62
|
+
inlineInput, onSetInlineInput, onContextMenu,
|
|
63
|
+
}: FileTreeNodeProps) => {
|
|
64
|
+
const expanded = expandedPaths.has(entry.path);
|
|
65
|
+
|
|
66
|
+
const handleClick = useCallback(() => {
|
|
67
|
+
if (entry.type === 'directory') {
|
|
68
|
+
onToggleExpand(entry.path);
|
|
69
|
+
} else {
|
|
70
|
+
callbacks.onFileSelect(entry.path, entry.name);
|
|
71
|
+
}
|
|
72
|
+
}, [entry, callbacks, onToggleExpand]);
|
|
73
|
+
|
|
74
|
+
const handleContextMenu = useCallback((e: React.MouseEvent) => {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
onContextMenu(e, entry, depth);
|
|
78
|
+
}, [entry, depth, onContextMenu]);
|
|
79
|
+
|
|
80
|
+
const isSelected = entry.type === 'file' && entry.path === selectedPath;
|
|
81
|
+
const isRenaming = inlineInput?.mode === 'rename' && inlineInput.targetPath === entry.path;
|
|
82
|
+
|
|
83
|
+
// Show inline input for rename
|
|
84
|
+
if (isRenaming) {
|
|
85
|
+
return (
|
|
86
|
+
<FileTreeInlineInput
|
|
87
|
+
depth={depth}
|
|
88
|
+
initialValue={inlineInput!.initialValue}
|
|
89
|
+
type={entry.type}
|
|
90
|
+
onSubmit={(newName) => {
|
|
91
|
+
callbacks.onRename(entry.path, newName);
|
|
92
|
+
onSetInlineInput(null);
|
|
93
|
+
}}
|
|
94
|
+
onCancel={() => onSetInlineInput(null)}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Check if there's a create-input targeting this directory
|
|
100
|
+
const showCreateInput = inlineInput?.mode === 'create' && inlineInput.parentPath === entry.path;
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<>
|
|
104
|
+
<button
|
|
105
|
+
className={`file-tree-node ${isSelected ? 'file-tree-node--selected' : ''}`}
|
|
106
|
+
style={{ paddingLeft: `${depth * 16 + 8}px` }}
|
|
107
|
+
onClick={handleClick}
|
|
108
|
+
onContextMenu={handleContextMenu}
|
|
109
|
+
title={entry.path}
|
|
110
|
+
>
|
|
111
|
+
{entry.type === 'directory' ? (
|
|
112
|
+
<>
|
|
113
|
+
<span className="file-tree-node__chevron">
|
|
114
|
+
{expanded ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
|
|
115
|
+
</span>
|
|
116
|
+
{expanded
|
|
117
|
+
? <FolderOpen size={ICON_SIZE} className="file-tree-node__icon file-tree-node__icon--folder" />
|
|
118
|
+
: <Folder size={ICON_SIZE} className="file-tree-node__icon file-tree-node__icon--folder" />
|
|
119
|
+
}
|
|
120
|
+
</>
|
|
121
|
+
) : (
|
|
122
|
+
<>
|
|
123
|
+
<span className="file-tree-node__chevron file-tree-node__chevron--hidden" />
|
|
124
|
+
<File size={ICON_SIZE} className="file-tree-node__icon" />
|
|
125
|
+
</>
|
|
126
|
+
)}
|
|
127
|
+
<span className="file-tree-node__name">{entry.name}</span>
|
|
128
|
+
</button>
|
|
129
|
+
{entry.type === 'directory' && expanded && (
|
|
130
|
+
<>
|
|
131
|
+
{showCreateInput && (
|
|
132
|
+
<FileTreeInlineInput
|
|
133
|
+
depth={depth + 1}
|
|
134
|
+
initialValue=""
|
|
135
|
+
type={inlineInput!.type}
|
|
136
|
+
onSubmit={(name) => {
|
|
137
|
+
callbacks.onCreateFile(entry.path, name, inlineInput!.type);
|
|
138
|
+
onSetInlineInput(null);
|
|
139
|
+
}}
|
|
140
|
+
onCancel={() => onSetInlineInput(null)}
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
{entry.children?.map((child) => (
|
|
144
|
+
<FileTreeNode
|
|
145
|
+
key={child.path}
|
|
146
|
+
entry={child}
|
|
147
|
+
depth={depth + 1}
|
|
148
|
+
callbacks={callbacks}
|
|
149
|
+
selectedPath={selectedPath}
|
|
150
|
+
expandedPaths={expandedPaths}
|
|
151
|
+
onToggleExpand={onToggleExpand}
|
|
152
|
+
inlineInput={inlineInput}
|
|
153
|
+
onSetInlineInput={onSetInlineInput}
|
|
154
|
+
onContextMenu={onContextMenu}
|
|
155
|
+
/>
|
|
156
|
+
))}
|
|
157
|
+
</>
|
|
158
|
+
)}
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const FileTree = ({ tree, callbacks, selectedPath, expandedPaths, onToggleExpand }: FileTreeProps) => {
|
|
164
|
+
const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null);
|
|
165
|
+
const [inlineInput, setInlineInput] = useState<InlineInputState | null>(null);
|
|
166
|
+
const treeRef = useRef<HTMLDivElement>(null);
|
|
167
|
+
|
|
168
|
+
const handleContextMenu = useCallback((e: React.MouseEvent, entry: TreeEntry, depth: number) => {
|
|
169
|
+
const items: ContextMenuItem[] = [];
|
|
170
|
+
|
|
171
|
+
if (entry.type === 'directory') {
|
|
172
|
+
items.push({
|
|
173
|
+
label: 'New File',
|
|
174
|
+
action: () => {
|
|
175
|
+
// Ensure directory is expanded
|
|
176
|
+
if (!expandedPaths.has(entry.path)) {
|
|
177
|
+
onToggleExpand(entry.path);
|
|
178
|
+
}
|
|
179
|
+
setInlineInput({
|
|
180
|
+
parentPath: entry.path,
|
|
181
|
+
type: 'file',
|
|
182
|
+
mode: 'create',
|
|
183
|
+
initialValue: '',
|
|
184
|
+
depth: depth + 1,
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
items.push({
|
|
189
|
+
label: 'New Folder',
|
|
190
|
+
action: () => {
|
|
191
|
+
if (!expandedPaths.has(entry.path)) {
|
|
192
|
+
onToggleExpand(entry.path);
|
|
193
|
+
}
|
|
194
|
+
setInlineInput({
|
|
195
|
+
parentPath: entry.path,
|
|
196
|
+
type: 'directory',
|
|
197
|
+
mode: 'create',
|
|
198
|
+
initialValue: '',
|
|
199
|
+
depth: depth + 1,
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
items.push({
|
|
206
|
+
label: 'Rename',
|
|
207
|
+
action: () => {
|
|
208
|
+
setInlineInput({
|
|
209
|
+
parentPath: entry.type === 'directory' ? entry.path : getParentPath(entry.path),
|
|
210
|
+
type: entry.type,
|
|
211
|
+
mode: 'rename',
|
|
212
|
+
initialValue: entry.name,
|
|
213
|
+
targetPath: entry.path,
|
|
214
|
+
depth,
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
items.push({
|
|
220
|
+
label: 'Delete',
|
|
221
|
+
action: () => {
|
|
222
|
+
const confirmMsg = entry.type === 'directory'
|
|
223
|
+
? `Delete folder "${entry.name}" and all its contents?`
|
|
224
|
+
: `Delete "${entry.name}"?`;
|
|
225
|
+
if (window.confirm(confirmMsg)) {
|
|
226
|
+
callbacks.onDelete(entry.path, entry.type);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
setContextMenu({ x: e.clientX, y: e.clientY, items });
|
|
232
|
+
}, [callbacks, expandedPaths, onToggleExpand]);
|
|
233
|
+
|
|
234
|
+
const handleRootContextMenu = useCallback((e: React.MouseEvent) => {
|
|
235
|
+
// Only trigger if clicking on the empty area (not on a tree node)
|
|
236
|
+
if ((e.target as HTMLElement).closest('.file-tree-node')) return;
|
|
237
|
+
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
setContextMenu({
|
|
240
|
+
x: e.clientX,
|
|
241
|
+
y: e.clientY,
|
|
242
|
+
items: [
|
|
243
|
+
{
|
|
244
|
+
label: 'New File',
|
|
245
|
+
action: () => {
|
|
246
|
+
setInlineInput({
|
|
247
|
+
parentPath: '',
|
|
248
|
+
type: 'file',
|
|
249
|
+
mode: 'create',
|
|
250
|
+
initialValue: '',
|
|
251
|
+
depth: 0,
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
label: 'New Folder',
|
|
257
|
+
action: () => {
|
|
258
|
+
setInlineInput({
|
|
259
|
+
parentPath: '',
|
|
260
|
+
type: 'directory',
|
|
261
|
+
mode: 'create',
|
|
262
|
+
initialValue: '',
|
|
263
|
+
depth: 0,
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
});
|
|
269
|
+
}, []);
|
|
270
|
+
|
|
271
|
+
// Check if there's a root-level create input (parentPath === '')
|
|
272
|
+
const showRootCreateInput = inlineInput?.mode === 'create' && inlineInput.parentPath === '';
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<div className="file-tree" ref={treeRef} onContextMenu={handleRootContextMenu}>
|
|
276
|
+
{showRootCreateInput && (
|
|
277
|
+
<FileTreeInlineInput
|
|
278
|
+
depth={0}
|
|
279
|
+
initialValue=""
|
|
280
|
+
type={inlineInput!.type}
|
|
281
|
+
onSubmit={(name) => {
|
|
282
|
+
callbacks.onCreateFile('', name, inlineInput!.type);
|
|
283
|
+
setInlineInput(null);
|
|
284
|
+
}}
|
|
285
|
+
onCancel={() => setInlineInput(null)}
|
|
286
|
+
/>
|
|
287
|
+
)}
|
|
288
|
+
{tree.map((entry) => (
|
|
289
|
+
<FileTreeNode
|
|
290
|
+
key={entry.path}
|
|
291
|
+
entry={entry}
|
|
292
|
+
depth={0}
|
|
293
|
+
callbacks={callbacks}
|
|
294
|
+
selectedPath={selectedPath}
|
|
295
|
+
expandedPaths={expandedPaths}
|
|
296
|
+
onToggleExpand={onToggleExpand}
|
|
297
|
+
inlineInput={inlineInput}
|
|
298
|
+
onSetInlineInput={setInlineInput}
|
|
299
|
+
onContextMenu={handleContextMenu}
|
|
300
|
+
/>
|
|
301
|
+
))}
|
|
302
|
+
{contextMenu && (
|
|
303
|
+
<FileTreeContextMenu
|
|
304
|
+
x={contextMenu.x}
|
|
305
|
+
y={contextMenu.y}
|
|
306
|
+
items={contextMenu.items}
|
|
307
|
+
onClose={() => setContextMenu(null)}
|
|
308
|
+
/>
|
|
309
|
+
)}
|
|
310
|
+
</div>
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
|
package/templates/assistkick-product-system/packages/frontend/src/components/FileTreeContextMenu.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ContextMenuItem {
|
|
4
|
+
label: string;
|
|
5
|
+
action: () => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface FileTreeContextMenuProps {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
items: ContextMenuItem[];
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const FileTreeContextMenu = ({ x, y, items, onClose }: FileTreeContextMenuProps) => {
|
|
16
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
17
|
+
|
|
18
|
+
const handleClickOutside = useCallback((e: MouseEvent) => {
|
|
19
|
+
if (menuRef.current && !menuRef.current.contains(e.target as Node)) {
|
|
20
|
+
onClose();
|
|
21
|
+
}
|
|
22
|
+
}, [onClose]);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
26
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
27
|
+
}, [handleClickOutside]);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const handleEscape = (e: KeyboardEvent) => {
|
|
31
|
+
if (e.key === 'Escape') onClose();
|
|
32
|
+
};
|
|
33
|
+
document.addEventListener('keydown', handleEscape);
|
|
34
|
+
return () => document.removeEventListener('keydown', handleEscape);
|
|
35
|
+
}, [onClose]);
|
|
36
|
+
|
|
37
|
+
// Adjust position to stay within viewport
|
|
38
|
+
const style: React.CSSProperties = {
|
|
39
|
+
position: 'fixed',
|
|
40
|
+
left: x,
|
|
41
|
+
top: y,
|
|
42
|
+
zIndex: 1000,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className="file-tree-context-menu" ref={menuRef} style={style}>
|
|
47
|
+
{items.map((item) => (
|
|
48
|
+
<button
|
|
49
|
+
key={item.label}
|
|
50
|
+
className="file-tree-context-menu__item"
|
|
51
|
+
onClick={() => {
|
|
52
|
+
item.action();
|
|
53
|
+
onClose();
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
{item.label}
|
|
57
|
+
</button>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
package/templates/assistkick-product-system/packages/frontend/src/components/FileTreeInlineInput.tsx
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import { File, Folder } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
const ICON_SIZE = 14;
|
|
5
|
+
|
|
6
|
+
interface FileTreeInlineInputProps {
|
|
7
|
+
depth: number;
|
|
8
|
+
initialValue: string;
|
|
9
|
+
type: 'file' | 'directory';
|
|
10
|
+
onSubmit: (value: string) => void;
|
|
11
|
+
onCancel: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const FileTreeInlineInput = ({ depth, initialValue, type, onSubmit, onCancel }: FileTreeInlineInputProps) => {
|
|
15
|
+
const [value, setValue] = useState(initialValue);
|
|
16
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (inputRef.current) {
|
|
20
|
+
inputRef.current.focus();
|
|
21
|
+
if (initialValue) {
|
|
22
|
+
// For rename: select the name part without extension
|
|
23
|
+
const dotIdx = initialValue.lastIndexOf('.');
|
|
24
|
+
if (dotIdx > 0 && type === 'file') {
|
|
25
|
+
inputRef.current.setSelectionRange(0, dotIdx);
|
|
26
|
+
} else {
|
|
27
|
+
inputRef.current.select();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [initialValue, type]);
|
|
32
|
+
|
|
33
|
+
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
|
34
|
+
if (e.key === 'Enter') {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
const trimmed = value.trim();
|
|
37
|
+
if (trimmed) {
|
|
38
|
+
onSubmit(trimmed);
|
|
39
|
+
} else {
|
|
40
|
+
onCancel();
|
|
41
|
+
}
|
|
42
|
+
} else if (e.key === 'Escape') {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
onCancel();
|
|
45
|
+
}
|
|
46
|
+
}, [value, onSubmit, onCancel]);
|
|
47
|
+
|
|
48
|
+
const handleBlur = useCallback(() => {
|
|
49
|
+
onCancel();
|
|
50
|
+
}, [onCancel]);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
className="file-tree-inline-input"
|
|
55
|
+
style={{ paddingLeft: `${depth * 16 + 8}px` }}
|
|
56
|
+
>
|
|
57
|
+
<span className="file-tree-node__chevron file-tree-node__chevron--hidden" />
|
|
58
|
+
{type === 'directory'
|
|
59
|
+
? <Folder size={ICON_SIZE} className="file-tree-node__icon file-tree-node__icon--folder" />
|
|
60
|
+
: <File size={ICON_SIZE} className="file-tree-node__icon" />
|
|
61
|
+
}
|
|
62
|
+
<input
|
|
63
|
+
ref={inputRef}
|
|
64
|
+
className="file-tree-inline-input__field"
|
|
65
|
+
value={value}
|
|
66
|
+
onChange={(e) => setValue(e.target.value)}
|
|
67
|
+
onKeyDown={handleKeyDown}
|
|
68
|
+
onBlur={handleBlur}
|
|
69
|
+
spellCheck={false}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|