UNPKG

5.68 kBTypeScriptView Raw
1import { Toolbar } from '@jupyterlab/apputils';
2import { Contents } from '@jupyterlab/services';
3import { ITranslator } from '@jupyterlab/translation';
4import { IIterator } from '@lumino/algorithm';
5import { PanelLayout, Widget } from '@lumino/widgets';
6import { BreadCrumbs } from './crumbs';
7import { DirListing } from './listing';
8import { FilterFileBrowserModel } from './model';
9/**
10 * A widget which hosts a file browser.
11 *
12 * The widget uses the Jupyter Contents API to retrieve contents,
13 * and presents itself as a flat list of files and directories with
14 * breadcrumbs.
15 */
16export declare class FileBrowser extends Widget {
17 /**
18 * Construct a new file browser.
19 *
20 * @param options - The file browser options.
21 */
22 constructor(options: FileBrowser.IOptions);
23 /**
24 * The model used by the file browser.
25 */
26 readonly model: FilterFileBrowserModel;
27 /**
28 * The toolbar used by the file browser.
29 */
30 readonly toolbar: Toolbar<Widget>;
31 /**
32 * Override Widget.layout with a more specific PanelLayout type.
33 */
34 layout: PanelLayout;
35 /**
36 * Whether to show active file in file browser
37 */
38 get navigateToCurrentDirectory(): boolean;
39 set navigateToCurrentDirectory(value: boolean);
40 /**
41 * Whether to show the last modified column
42 */
43 get showLastModifiedColumn(): boolean;
44 set showLastModifiedColumn(value: boolean);
45 /**
46 * Whether to use fuzzy filtering on file names.
47 */
48 set useFuzzyFilter(value: boolean);
49 /**
50 * Whether to show hidden files
51 */
52 get showHiddenFiles(): boolean;
53 set showHiddenFiles(value: boolean);
54 /**
55 * Create an iterator over the listing's selected items.
56 *
57 * @returns A new iterator over the listing's selected items.
58 */
59 selectedItems(): IIterator<Contents.IModel>;
60 /**
61 * Select an item by name.
62 *
63 * @param name - The name of the item to select.
64 */
65 selectItemByName(name: string): Promise<void>;
66 clearSelectedItems(): void;
67 /**
68 * Rename the first currently selected item.
69 *
70 * @returns A promise that resolves with the new name of the item.
71 */
72 rename(): Promise<string>;
73 /**
74 * Cut the selected items.
75 */
76 cut(): void;
77 /**
78 * Copy the selected items.
79 */
80 copy(): void;
81 /**
82 * Paste the items from the clipboard.
83 *
84 * @returns A promise that resolves when the operation is complete.
85 */
86 paste(): Promise<void>;
87 /**
88 * Create a new directory
89 */
90 createNewDirectory(): void;
91 /**
92 * Create a new file
93 */
94 createNewFile(options: FileBrowser.IFileOptions): void;
95 /**
96 * Delete the currently selected item(s).
97 *
98 * @returns A promise that resolves when the operation is complete.
99 */
100 delete(): Promise<void>;
101 /**
102 * Duplicate the currently selected item(s).
103 *
104 * @returns A promise that resolves when the operation is complete.
105 */
106 duplicate(): Promise<void>;
107 /**
108 * Download the currently selected item(s).
109 */
110 download(): Promise<void>;
111 /**
112 * Shut down kernels on the applicable currently selected items.
113 *
114 * @returns A promise that resolves when the operation is complete.
115 */
116 shutdownKernels(): Promise<void>;
117 /**
118 * Select next item.
119 */
120 selectNext(): void;
121 /**
122 * Select previous item.
123 */
124 selectPrevious(): void;
125 /**
126 * Find a model given a click.
127 *
128 * @param event - The mouse event.
129 *
130 * @returns The model for the selected file.
131 */
132 modelForClick(event: MouseEvent): Contents.IModel | undefined;
133 /**
134 * Create the underlying DirListing instance.
135 *
136 * @param options - The DirListing constructor options.
137 *
138 * @returns The created DirListing instance.
139 */
140 protected createDirListing(options: DirListing.IOptions): DirListing;
141 protected translator: ITranslator;
142 /**
143 * Handle a connection lost signal from the model.
144 */
145 private _onConnectionFailure;
146 protected listing: DirListing;
147 protected crumbs: BreadCrumbs;
148 private _trans;
149 private _filenameSearcher;
150 private _manager;
151 private _directoryPending;
152 private _filePending;
153 private _navigateToCurrentDirectory;
154 private _showLastModifiedColumn;
155 private _useFuzzyFilter;
156 private _showHiddenFiles;
157}
158/**
159 * The namespace for the `FileBrowser` class statics.
160 */
161export declare namespace FileBrowser {
162 /**
163 * An options object for initializing a file browser widget.
164 */
165 interface IOptions {
166 /**
167 * The widget/DOM id of the file browser.
168 */
169 id: string;
170 /**
171 * A file browser model instance.
172 */
173 model: FilterFileBrowserModel;
174 /**
175 * An optional renderer for the directory listing area.
176 *
177 * The default is a shared instance of `DirListing.Renderer`.
178 */
179 renderer?: DirListing.IRenderer;
180 /**
181 * Whether a file browser automatically restores state when instantiated.
182 * The default is `true`.
183 *
184 * #### Notes
185 * The file browser model will need to be restored manually for the file
186 * browser to be able to save its state.
187 */
188 restore?: boolean;
189 /**
190 * The application language translator.
191 */
192 translator?: ITranslator;
193 }
194 /**
195 * An options object for creating a file.
196 */
197 interface IFileOptions {
198 /**
199 * The file extension.
200 */
201 ext: string;
202 }
203}