import { FileTreeIcons, RemappedIcon } from "../iconConfig.js"; import { ContextMenuAnchorRect, GitStatusEntry } from "../publicTypes.js"; import { FileTreeDensity } from "./density.js"; import { FileTreePreparedInput } from "../preparedInput.js"; //#region src/model/publicTypes.d.ts /** * Public tree identity is path-first so render and model callers never depend * on the underlying path-store numeric IDs. */ type FileTreePublicId = string; interface FileTreeSortEntry { basename: string; depth: number; isDirectory: boolean; path: FileTreePublicId; segments: readonly string[]; } type FileTreeSortComparator = (left: FileTreeSortEntry, right: FileTreeSortEntry) => number; type FileTreeInitialExpansion = 'closed' | 'open' | number; interface FileTreeRemoveOptions { recursive?: boolean; } type FileTreeCollisionStrategy = 'error' | 'replace' | 'skip'; interface FileTreeMoveOptions { collision?: FileTreeCollisionStrategy; } type FileTreeBatchOperation = { path: FileTreePublicId; type: 'add'; } | ({ path: FileTreePublicId; type: 'remove'; } & FileTreeRemoveOptions) | ({ from: FileTreePublicId; to: FileTreePublicId; type: 'move'; } & FileTreeMoveOptions); interface FileTreeGitStatusPatch { remove?: readonly FileTreePublicId[]; set?: readonly GitStatusEntry[]; } interface FileTreeStoreOptions { flattenEmptyDirectories?: boolean; initialExpansion?: FileTreeInitialExpansion; initialExpandedPaths?: readonly FileTreePublicId[]; presorted?: boolean; sort?: 'default' | FileTreeSortComparator; } type FileTreeInputOptions = { paths: readonly FileTreePublicId[]; preparedInput?: FileTreePreparedInput; } | { paths?: readonly FileTreePublicId[]; preparedInput: FileTreePreparedInput; }; type FileTreeControllerBehaviorOptions = FileTreeStoreOptions & { dragAndDrop?: boolean | FileTreeDragAndDropConfig; fileTreeSearchMode?: FileTreeSearchMode; initialSearchQuery?: string | null; initialSelectedPaths?: readonly FileTreePublicId[]; onSearchChange?: FileTreeSearchChangeListener; renaming?: boolean | FileTreeRenamingConfig; }; type FileTreeControllerOptions = FileTreeControllerBehaviorOptions & FileTreeInputOptions; interface FileTreeVisibleSegment { isTerminal: boolean; name: string; path: FileTreePublicId; } interface FileTreeVisibleRow { ancestorPaths: readonly FileTreePublicId[]; depth: number; flattenedSegments?: readonly FileTreeVisibleSegment[]; hasChildren: boolean; index: number; isFocused: boolean; isSelected: boolean; isExpanded: boolean; isFlattened: boolean; kind: 'directory' | 'file'; level: number; name: string; path: FileTreePublicId; posInSet: number; setSize: number; } interface FileTreeItemHandleBase { deselect(): void; focus(): void; getPath(): FileTreePublicId; isFocused(): boolean; isDirectory(): boolean; isSelected(): boolean; select(): void; toggleSelect(): void; } interface FileTreeDirectoryHandle extends FileTreeItemHandleBase { collapse(): void; expand(): void; isDirectory(): true; isExpanded(): boolean; toggle(): void; } interface FileTreeFileHandle extends FileTreeItemHandleBase { isDirectory(): false; } type FileTreeItemHandle = FileTreeDirectoryHandle | FileTreeFileHandle; interface FileTreeRenderOptions { initialVisibleRowCount?: number; itemHeight?: number; overscan?: number; stickyFolders?: boolean; } type FileTreeScrollOffset = 'top' | 'center' | 'nearest'; interface FileTreeScrollToPathOptions { focus?: boolean; offset?: FileTreeScrollOffset; } type FileTreeSearchMode = 'expand-matches' | 'collapse-non-matches' | 'hide-non-matches'; type FileTreeSearchBlurBehavior = 'close' | 'retain'; type FileTreeSearchChangeListener = (value: string | null) => void; interface FileTreeSearchSessionHandle { closeSearch(): void; focusNextSearchMatch(): void; focusPreviousSearchMatch(): void; getSearchMatchingPaths(): readonly FileTreePublicId[]; getSearchValue(): string; isSearchOpen(): boolean; openSearch(initialValue?: string): void; setSearch(value: string | null): void; } interface FileTreeDropTarget { directoryPath: FileTreePublicId | null; flattenedSegmentPath: FileTreePublicId | null; hoveredPath: FileTreePublicId | null; kind: 'directory' | 'root'; } interface FileTreeDropContext { draggedPaths: readonly FileTreePublicId[]; target: FileTreeDropTarget; } interface FileTreeDropResult extends FileTreeDropContext { operation: 'batch' | 'move'; } interface FileTreeDragAndDropConfig { canDrag?: (paths: readonly FileTreePublicId[]) => boolean; canDrop?: (event: FileTreeDropContext) => boolean; onDropComplete?: (event: FileTreeDropResult) => void; onDropError?: (error: string, event: FileTreeDropContext) => void; openOnDropDelay?: number; } interface FileTreeRenamingItem { isFolder: boolean; path: FileTreePublicId; } interface FileTreeRenameEvent { destinationPath: FileTreePublicId; isFolder: boolean; sourcePath: FileTreePublicId; } interface FileTreeRenamingConfig { canRename?: (item: FileTreeRenamingItem) => boolean; onError?: (error: string) => void; onRename?: (event: FileTreeRenameEvent) => void; } type FileTreeOptionSurface = FileTreeRenderOptions & { composition?: FileTreeCompositionOptions; density?: FileTreeDensity; gitStatus?: readonly GitStatusEntry[]; id?: string; icons?: FileTreeIcons; onSelectionChange?: FileTreeSelectionChangeListener; renderRowDecoration?: FileTreeRowDecorationRenderer; search?: boolean; searchFakeFocus?: boolean; searchBlurBehavior?: FileTreeSearchBlurBehavior; unsafeCSS?: string; }; type FileTreeOptions = FileTreeControllerOptions & FileTreeOptionSurface; interface FileTreeRenderProps { containerWrapper?: HTMLElement; fileTreeContainer?: HTMLElement; } interface FileTreeHydrationProps { fileTreeContainer: HTMLElement; } interface FileTreeSsrPayload { domOuterStart: string; id: string; outerEnd: string; outerStart: string; shadowHtml: string; } interface FileTreeMutationEventInvalidation { canonicalChanged: boolean; projectionChanged: boolean; visibleCountDelta: number | null; } interface FileTreeAddEvent extends FileTreeMutationEventInvalidation { operation: 'add'; path: FileTreePublicId; } interface FileTreeRemoveEvent extends FileTreeMutationEventInvalidation { operation: 'remove'; path: FileTreePublicId; recursive: boolean; } interface FileTreeMoveEvent extends FileTreeMutationEventInvalidation { from: FileTreePublicId; operation: 'move'; to: FileTreePublicId; } interface FileTreeResetEvent extends FileTreeMutationEventInvalidation { operation: 'reset'; pathCountAfter: number; pathCountBefore: number; usedPreparedInput: boolean; } type FileTreeMutationSemanticEvent = FileTreeAddEvent | FileTreeRemoveEvent | FileTreeMoveEvent | FileTreeResetEvent; interface FileTreeBatchEvent extends FileTreeMutationEventInvalidation { events: readonly FileTreeMutationSemanticEvent[]; operation: 'batch'; } type FileTreeMutationEvent = FileTreeMutationSemanticEvent | FileTreeBatchEvent; type FileTreeMutationEventType = FileTreeMutationEvent['operation']; type FileTreeMutationEventForType = TType extends '*' ? FileTreeMutationEvent : Extract; interface FileTreeResetBehaviorOptions { initialExpandedPaths?: readonly FileTreePublicId[]; } type FileTreeResetOptions = FileTreeResetBehaviorOptions & { preparedInput?: FileTreePreparedInput; }; type FileTreeResetPreparedOptions = FileTreeResetBehaviorOptions & { preparedInput: FileTreePreparedInput; }; interface FileTreeMutationHandle { add(path: FileTreePublicId): void; batch(operations: readonly FileTreeBatchOperation[]): void; move(fromPath: FileTreePublicId, toPath: FileTreePublicId, options?: FileTreeMoveOptions): void; onMutation(type: TType, handler: (event: FileTreeMutationEventForType) => void): () => void; remove(path: FileTreePublicId, options?: FileTreeRemoveOptions): void; resetPaths(paths: readonly FileTreePublicId[], options?: FileTreeResetOptions): void; resetPaths(options: FileTreeResetPreparedOptions): void; } type FileTreeListener = () => void; type FileTreeSelectionChangeListener = (selectedPaths: readonly FileTreePublicId[]) => void; interface FileTreeContextMenuItem { kind: 'directory' | 'file'; name: string; path: FileTreePublicId; } interface FileTreeContextMenuOpenContext { anchorElement: HTMLElement; anchorRect: ContextMenuAnchorRect; /** * Closes the current context menu. Pass `{ restoreFocus: false }` when the * caller is about to transfer focus into another owned surface, such as the * inline rename input, so the menu close path does not steal focus back to * the row first. */ close: (options?: { restoreFocus?: boolean; }) => void; restoreFocus: () => void; } interface FileTreeHeaderCompositionOptions { html?: string; render?: () => HTMLElement | null; } type FileTreeContextMenuTriggerMode = 'both' | 'button' | 'right-click'; type FileTreeContextMenuButtonVisibility = 'always' | 'when-needed'; interface FileTreeContextMenuCompositionOptions { enabled?: boolean; triggerMode?: FileTreeContextMenuTriggerMode; buttonVisibility?: FileTreeContextMenuButtonVisibility; onOpen?: (item: FileTreeContextMenuItem, context: FileTreeContextMenuOpenContext) => void; onClose?: () => void; /** * If the interactive menu surface renders through a portal instead of inside * the returned element, mark that portaled root with * `data-file-tree-context-menu-root="true"` so internal clicks are not * treated as outside clicks. */ render?: (item: FileTreeContextMenuItem, context: FileTreeContextMenuOpenContext) => HTMLElement | null; } interface FileTreeCompositionOptions { contextMenu?: FileTreeContextMenuCompositionOptions; header?: FileTreeHeaderCompositionOptions; } interface FileTreeRowDecorationTextPart { text: string; color?: string; } interface FileTreeRowDecorationText { text: string; title?: string; parts?: readonly FileTreeRowDecorationTextPart[]; } interface FileTreeRowDecorationIcon { icon: RemappedIcon; title?: string; } type FileTreeRowDecoration = FileTreeRowDecorationText | FileTreeRowDecorationIcon; interface FileTreeRowDecorationContext { item: FileTreeContextMenuItem; row: FileTreeVisibleRow; } type FileTreeRowDecorationRenderer = (context: FileTreeRowDecorationContext) => FileTreeRowDecoration | null; //#endregion export { FileTreeAddEvent, FileTreeBatchEvent, FileTreeBatchOperation, FileTreeCollisionStrategy, FileTreeCompositionOptions, FileTreeContextMenuButtonVisibility, FileTreeContextMenuCompositionOptions, FileTreeContextMenuItem, FileTreeContextMenuOpenContext, FileTreeContextMenuTriggerMode, FileTreeControllerOptions, FileTreeDirectoryHandle, FileTreeDragAndDropConfig, FileTreeDropContext, FileTreeDropResult, FileTreeDropTarget, FileTreeFileHandle, FileTreeGitStatusPatch, FileTreeHeaderCompositionOptions, FileTreeHydrationProps, FileTreeInitialExpansion, FileTreeItemHandle, FileTreeItemHandleBase, FileTreeListener, FileTreeMoveEvent, FileTreeMoveOptions, FileTreeMutationEvent, FileTreeMutationEventForType, FileTreeMutationEventInvalidation, FileTreeMutationEventType, FileTreeMutationHandle, FileTreeMutationSemanticEvent, FileTreeOptions, FileTreePublicId, FileTreeRemoveEvent, FileTreeRemoveOptions, FileTreeRenameEvent, FileTreeRenamingConfig, FileTreeRenamingItem, FileTreeRenderOptions, FileTreeRenderProps, FileTreeResetEvent, FileTreeResetOptions, FileTreeResetPreparedOptions, FileTreeRowDecoration, FileTreeRowDecorationContext, FileTreeRowDecorationIcon, FileTreeRowDecorationRenderer, FileTreeRowDecorationText, FileTreeRowDecorationTextPart, FileTreeScrollOffset, FileTreeScrollToPathOptions, FileTreeSearchBlurBehavior, FileTreeSearchChangeListener, FileTreeSearchMode, FileTreeSearchSessionHandle, FileTreeSelectionChangeListener, FileTreeSortComparator, FileTreeSortEntry, FileTreeSsrPayload, FileTreeVisibleRow, FileTreeVisibleSegment }; //# sourceMappingURL=publicTypes.d.ts.map