mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-14 02:12:04 +08:00
# Features - File drag and drop upload: Support uploading files and folders via drag and drop - Binary file handling: Detect binary files and display a friendly message instead of trying to edit them - Folder download: Download folders as ZIP files (using JSZip library) - Context menu integration: Full right-click context menu for file operations (rename, delete, copy path, download, new file/folder)
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import { useCallback, useState } from 'react';
|
|
|
|
type UseExpandedDirectoriesResult = {
|
|
expandedDirs: Set<string>;
|
|
toggleDirectory: (path: string) => void;
|
|
expandDirectories: (paths: string[]) => void;
|
|
collapseAll: () => void;
|
|
};
|
|
|
|
export function useExpandedDirectories(): UseExpandedDirectoriesResult {
|
|
const [expandedDirs, setExpandedDirs] = useState<Set<string>>(() => new Set());
|
|
|
|
const toggleDirectory = useCallback((path: string) => {
|
|
setExpandedDirs((previous) => {
|
|
const next = new Set(previous);
|
|
|
|
if (next.has(path)) {
|
|
next.delete(path);
|
|
} else {
|
|
next.add(path);
|
|
}
|
|
|
|
return next;
|
|
});
|
|
}, []);
|
|
|
|
const expandDirectories = useCallback((paths: string[]) => {
|
|
if (paths.length === 0) {
|
|
return;
|
|
}
|
|
|
|
setExpandedDirs((previous) => {
|
|
const next = new Set(previous);
|
|
paths.forEach((path) => next.add(path));
|
|
return next;
|
|
});
|
|
}, []);
|
|
|
|
const collapseAll = useCallback(() => {
|
|
setExpandedDirs(new Set());
|
|
}, []);
|
|
|
|
return {
|
|
expandedDirs,
|
|
toggleDirectory,
|
|
expandDirectories,
|
|
collapseAll,
|
|
};
|
|
}
|
|
|