UNPKG

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