mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-06 04:55:45 +08:00
refactor(command-palette): extract groups into declarative registry
This commit is contained in:
27
src/components/command-palette/registry/groups/files.tsx
Normal file
27
src/components/command-palette/registry/groups/files.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { FileText } from 'lucide-react';
|
||||
|
||||
import { useFilesSource } from '../../sources/useFilesSource';
|
||||
import type { GroupConfig } from '../types';
|
||||
|
||||
export const filesGroup: GroupConfig = {
|
||||
id: 'files',
|
||||
heading: 'Files',
|
||||
modes: ['mixed', 'files'],
|
||||
prefix: { char: '/', mode: 'files' },
|
||||
requiresProject: true,
|
||||
useItems: (ctx) => {
|
||||
const { items: files } = useFilesSource(ctx.projectId, ctx.enabled);
|
||||
return files.map((f) => ({
|
||||
key: `file-${f.path}`,
|
||||
value: f.path,
|
||||
onSelect: () => ctx.run(() => ctx.openFile(f.path)),
|
||||
node: (
|
||||
<>
|
||||
<FileText className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
|
||||
<span className="flex-1 truncate">{f.name}</span>
|
||||
<span className="truncate text-xs text-muted-foreground">{f.path}</span>
|
||||
</>
|
||||
),
|
||||
}));
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user