UNPKG

@jupyterlab/filebrowser

Version:
109 lines (108 loc) 3.45 kB
import type { ITranslator } from '@jupyterlab/translation'; import type { Message } from '@lumino/messaging'; import type { ISignal } from '@lumino/signaling'; import { Widget } from '@lumino/widgets'; import type { FileBrowserModel } from './model'; /** * A widget that renders a path text input with directory autocomplete. * It owns only the input field and the suggestions dropdown. * The trigger button and edit-mode state are managed by the parent widget. */ export declare class PathNavigator extends Widget { constructor(options: PathNavigator.IOptions); /** * A signal emitted when the navigator closes (Escape, blur, or after * navigation is committed). The parent widget should use this to exit * edit mode. */ get closed(): ISignal<this, void>; /** * Dispose of the resources held by the widget. */ dispose(): void; /** * Open the path input: prefill with the model's current path, focus, * and load suggestions. */ open(): void; /** * A message handler invoked on an `'after-attach'` message. */ protected onAfterAttach(msg: Message): void; /** * A message handler invoked on a `'before-detach'` message. */ protected onBeforeDetach(msg: Message): void; handleEvent(event: Event): void; /** * Close the input and notify the parent via the `closed` signal. */ private _close; /** * Navigate to the given path, then close the input. */ private _commitNavigation; /** * Whether the refreshed path corresponds to the last submitted path. */ matchesSubmittedPath(localPath: string): boolean; /** * Fetch and display directory suggestions for the given input value. */ private _updateSuggestions; /** * Re-render the suggestions list from the given paths. */ private _renderSuggestions; /** * Handle keyboard navigation and confirmation inside the input. */ private _evtKeydown; /** * Handle mousedown on a suggestion item. * * Using mousedown (before blur) and calling preventDefault() keeps focus on * the input, so we can navigate without the blur handler firing first. */ private _evtSuggestionMousedown; /** * Move the active suggestion up or down by `direction` steps. */ private _navigateSuggestions; /** * Accept the highlighted suggestion (Tab key). * If none is highlighted, complete to the sole match or longest common prefix. */ private _acceptSuggestion; /** * Handle the model's `refreshed` signal. * Invalidate the suggestion cache so the next lookup fetches fresh data. * If the input is currently open, proactively re-fetch suggestions. */ private _onModelRefreshed; private _model; private _trans; private _inputNode; private _suggestionsNode; private _closed; private _isOpen; private _suggestions; private _currentFilteredSuggestions; private _activeSuggestionIndex; private _suggestionDirPath; private _suggestionFetchTime; private _fetchId; private _submittedLocalPath; } export declare namespace PathNavigator { interface IOptions { /** * The file browser model. */ model: FileBrowserModel; /** * The application language translator. */ translator?: ITranslator; } }