@jupyterlab/filebrowser
Version:
JupyterLab - FileBrowser Widget
215 lines (214 loc) • 6.28 kB
TypeScript
import type { ITranslator } from '@jupyterlab/translation';
import type { Message } from '@lumino/messaging';
import { Widget } from '@lumino/widgets';
import type { FileBrowserModel } from './model';
/**
* A class which hosts folder breadcrumbs.
*/
export declare class BreadCrumbs extends Widget {
/**
* Construct a new file browser crumb widget.
*
* @param options Constructor options.
*/
constructor(options: BreadCrumbs.IOptions);
/**
* Handle the DOM events for the bread crumbs.
*
* @param event - The DOM event sent to the widget.
*
* #### Notes
* This method implements the DOM `EventListener` interface and is
* called in response to events on the panel's DOM node. It should
* not be called directly by user code.
*/
handleEvent(event: Event): void;
/**
* Whether to show the full path in the breadcrumbs
*/
get fullPath(): boolean;
set fullPath(value: boolean);
/**
* Number of items to show on left of ellipsis
*/
get minimumLeftItems(): number;
set minimumLeftItems(value: number);
/**
* Number of items to show on right of ellipsis
*/
get minimumRightItems(): number;
set minimumRightItems(value: number);
/**
* Dispose of the resources held by the widget.
*/
dispose(): 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;
/**
* A handler invoked on an `'update-request'` message.
*/
protected onUpdateRequest(msg: Message): void;
/**
* Restore crumb focus after breadcrumb activation and invoke activation callback.
*/
private _runPostActivationFocus;
/**
* Return breadcrumb segments in DOM order that participate in arrow-key focus.
*/
private _getFocusableCrumbElements;
/**
* Roving tabindex: one segment is in tab order (`tabIndex` 0), the rest -1.
*/
private _syncCrumbTabIndices;
/**
* Focus a crumb segment and make it the sole tab stop within the trail.
*/
private _focusCrumb;
/**
* Focus the last segment in the trail (the current directory), for keyboard UX after navigation.
*/
private _focusTrailingCrumb;
/**
* Walk from an event target to the nearest breadcrumb segment host, if any.
*/
private _resolveCrumbFromEventTarget;
/**
* Whether a crumb corresponds to the current directory segment.
*/
private _isCurrentDirectoryCrumb;
/**
* Navigate to the directory represented by a breadcrumb segment.
*/
private _activateCrumbSegment;
/**
* Resolve the destination path for an activated breadcrumb segment.
*/
private _destinationForCrumb;
/**
* Handle the `'keydown'` event for the widget.
*/
private _evtKeyDown;
/**
* Handle the `'click'` event for the widget.
*/
private _evtClick;
/**
* Handle the `'lm-dragenter'` event for the widget.
*/
private _evtDragEnter;
/**
* Handle the `'lm-dragleave'` event for the widget.
*/
private _evtDragLeave;
/**
* Handle the `'lm-dragover'` event for the widget.
*/
private _evtDragOver;
/**
* Handle the `'lm-drop'` event for the widget.
*/
private _evtDrop;
/**
* Get all breadcrumb elements that can be drop targets.
*/
private _getBreadcrumbElements;
/**
* Handle resize events with throttling.
*/
private _onResize;
/**
* Measure ALL breadcrumb item widths by rendering them off-screen.
* This ensures we have accurate widths for every path segment,
* including those currently hidden behind the ellipsis.
*/
private _measureAllItemWidths;
/**
* Calculate adaptive left/right items based on available width.
*/
private _calculateAdaptiveItems;
/**
* Enter edit mode: show the path input and hide the breadcrumb content.
*/
enterEditMode(): void;
/**
* Move focus to the trailing breadcrumb segment.
*/
focusLastCrumb(): void;
/**
* Exit edit mode and restore the breadcrumb display.
*/
private _exitEditMode;
/**
* Handle the model's `refreshed` signal.
* If we are in edit mode, dismiss it (the model path may have changed).
*/
private _onModelRefreshed;
protected translator: ITranslator;
private _trans;
private _model;
private _hasPreferred;
private _crumbs;
private _fullPath;
private _previousState;
private _minimumLeftItems;
private _minimumRightItems;
private _resizeObserver;
private _resizeThrottler;
private _cachedWidths;
private _lastRenderedWidth;
private _isEditMode;
private _lastPath;
private _crumbContainer;
private _crumbContent;
private _pathNavigator;
private _onPathEdited?;
private _onPathActivated?;
/**
* After `cd()` rebuilds the trail, restore focus to the current-directory segment.
*/
private _restoreBreadcrumbFocusAfterUpdate;
}
/**
* The namespace for the `BreadCrumbs` class statics.
*/
export declare namespace BreadCrumbs {
/**
* An options object for initializing a bread crumb widget.
*/
interface IOptions {
/**
* A file browser model instance.
*/
model: FileBrowserModel;
/**
* The application language translator.
*/
translator?: ITranslator;
/**
* Show the full file browser path in breadcrumbs
*/
fullPath?: boolean;
/**
* Number of items to show on left of ellipsis
*/
minimumLeftItems?: number;
/**
* Number of items to show on right of ellipsis
*/
minimumRightItems?: number;
/**
* Callback invoked after path edit changes directory.
*/
onPathEdited?: () => void;
/**
* Callback invoked after breadcrumb activation changes directory.
*/
onPathActivated?: () => void;
}
}