1 | import { DocumentRegistry } from '@jupyterlab/docregistry';
|
2 | import { Contents } from '@jupyterlab/services';
|
3 | import { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
4 | import { IIterator } from '@lumino/algorithm';
|
5 | import { IDragEvent } from '@lumino/dragdrop';
|
6 | import { Message } from '@lumino/messaging';
|
7 | import { ISignal } from '@lumino/signaling';
|
8 | import { Widget } from '@lumino/widgets';
|
9 | import { FilterFileBrowserModel } from './model';
|
10 |
|
11 |
|
12 |
|
13 | export declare class DirListing extends Widget {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | constructor(options: DirListing.IOptions);
|
20 | /**
|
21 | * Dispose of the resources held by the directory listing.
|
22 | */
|
23 | dispose(): void;
|
24 | /**
|
25 | * Get the model used by the listing.
|
26 | */
|
27 | get model(): FilterFileBrowserModel;
|
28 | /**
|
29 | * Get the dir listing header node.
|
30 | *
|
31 | * #### Notes
|
32 | * This is the node which holds the header cells.
|
33 | *
|
34 | * Modifying this node directly can lead to undefined behavior.
|
35 | */
|
36 | get headerNode(): HTMLElement;
|
37 | /**
|
38 | * Get the dir listing content node.
|
39 | *
|
40 | * #### Notes
|
41 | * This is the node which holds the item nodes.
|
42 | *
|
43 | * Modifying this node directly can lead to undefined behavior.
|
44 | */
|
45 | get contentNode(): HTMLElement;
|
46 | /**
|
47 | * The renderer instance used by the directory listing.
|
48 | */
|
49 | get renderer(): DirListing.IRenderer;
|
50 | /**
|
51 | * The current sort state.
|
52 | */
|
53 | get sortState(): DirListing.ISortState;
|
54 | /**
|
55 | * A signal fired when an item is opened.
|
56 | */
|
57 | get onItemOpened(): ISignal<DirListing, Contents.IModel>;
|
58 | /**
|
59 | * Create an iterator over the listing's selected items.
|
60 | *
|
61 | * @returns A new iterator over the listing's selected items.
|
62 | */
|
63 | selectedItems(): IIterator<Contents.IModel>;
|
64 | /**
|
65 | * Create an iterator over the listing's sorted items.
|
66 | *
|
67 | * @returns A new iterator over the listing's sorted items.
|
68 | */
|
69 | sortedItems(): IIterator<Contents.IModel>;
|
70 | /**
|
71 | * Sort the items using a sort condition.
|
72 | */
|
73 | sort(state: DirListing.ISortState): 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 | /**
|
95 | * Delete the currently selected item(s).
|
96 | *
|
97 | * @returns A promise that resolves when the operation is complete.
|
98 | */
|
99 | delete(): Promise<void>;
|
100 | /**
|
101 | * Duplicate the currently selected item(s).
|
102 | *
|
103 | * @returns A promise that resolves when the operation is complete.
|
104 | */
|
105 | duplicate(): Promise<void>;
|
106 | /**
|
107 | * Download the currently selected item(s).
|
108 | */
|
109 | download(): Promise<void>;
|
110 | /**
|
111 | * Shut down kernels on the applicable currently selected items.
|
112 | *
|
113 | * @returns A promise that resolves when the operation is complete.
|
114 | */
|
115 | shutdownKernels(): Promise<void>;
|
116 | /**
|
117 | * Select next item.
|
118 | *
|
119 | * @param keepExisting - Whether to keep the current selection and add to it.
|
120 | */
|
121 | selectNext(keepExisting?: boolean): void;
|
122 | /**
|
123 | * Select previous item.
|
124 | *
|
125 | * @param keepExisting - Whether to keep the current selection and add to it.
|
126 | */
|
127 | selectPrevious(keepExisting?: boolean): void;
|
128 | /**
|
129 | * Select the first item that starts with prefix being typed.
|
130 | */
|
131 | selectByPrefix(): void;
|
132 | /**
|
133 | * Get whether an item is selected by name.
|
134 | *
|
135 | * @param name - The name of of the item.
|
136 | *
|
137 | * @returns Whether the item is selected.
|
138 | */
|
139 | isSelected(name: string): boolean;
|
140 | /**
|
141 | * Find a model given a click.
|
142 | *
|
143 | * @param event - The mouse event.
|
144 | *
|
145 | * @returns The model for the selected file.
|
146 | */
|
147 | modelForClick(event: MouseEvent): Contents.IModel | undefined;
|
148 | /**
|
149 | * Clear the selected items.
|
150 | */
|
151 | clearSelectedItems(): void;
|
152 | /**
|
153 | * Select an item by name.
|
154 | *
|
155 | * @param name - The name of the item to select.
|
156 | * @param focus - Whether to move focus the selected item.
|
157 | *
|
158 | * @returns A promise that resolves when the name is selected.
|
159 | */
|
160 | selectItemByName(name: string, focus?: boolean): Promise<void>;
|
161 | /**
|
162 | * Handle the DOM events for the directory listing.
|
163 | *
|
164 | * @param event - The DOM event sent to the widget.
|
165 | *
|
166 | * #### Notes
|
167 | * This method implements the DOM `EventListener` interface and is
|
168 | * called in response to events on the panel's DOM node. It should
|
169 | * not be called directly by user code.
|
170 | */
|
171 | handleEvent(event: Event): void;
|
172 | /**
|
173 | * A message handler invoked on an `'after-attach'` message.
|
174 | */
|
175 | protected onAfterAttach(msg: Message): void;
|
176 | /**
|
177 | * A message handler invoked on a `'before-detach'` message.
|
178 | */
|
179 | protected onBeforeDetach(msg: Message): void;
|
180 | /**
|
181 | * A message handler invoked on an `'after-show'` message.
|
182 | */
|
183 | protected onAfterShow(msg: Message): void;
|
184 | /**
|
185 | * A handler invoked on an `'update-request'` message.
|
186 | */
|
187 | protected onUpdateRequest(msg: Message): void;
|
188 | onResize(msg: Widget.ResizeMessage): void;
|
189 | setColumnVisibility(name: DirListing.ToggleableColumn, visible: boolean): void;
|
190 | /**
|
191 | * Handle the `'click'` event for the widget.
|
192 | */
|
193 | private _evtClick;
|
194 | /**
|
195 | * Handle the `'scroll'` event for the widget.
|
196 | */
|
197 | private _evtScroll;
|
198 | /**
|
199 | * Handle the `'mousedown'` event for the widget.
|
200 | */
|
201 | private _evtMousedown;
|
202 | /**
|
203 | * Handle the `'mouseup'` event for the widget.
|
204 | */
|
205 | private _evtMouseup;
|
206 | /**
|
207 | * Handle the `'mousemove'` event for the widget.
|
208 | */
|
209 | private _evtMousemove;
|
210 | /**
|
211 | * Handle the opening of an item.
|
212 | */
|
213 | protected handleOpen(item: Contents.IModel): void;
|
214 | /**
|
215 | * Handle the `'keydown'` event for the widget.
|
216 | */
|
217 | protected evtKeydown(event: KeyboardEvent): void;
|
218 | /**
|
219 | * Handle the `'dblclick'` event for the widget.
|
220 | */
|
221 | protected evtDblClick(event: MouseEvent): void;
|
222 | /**
|
223 | * Handle the `drop` event for the widget.
|
224 | */
|
225 | protected evtNativeDrop(event: DragEvent): void;
|
226 | /**
|
227 | * Handle the `'lm-dragenter'` event for the widget.
|
228 | */
|
229 | protected evtDragEnter(event: IDragEvent): void;
|
230 | /**
|
231 | * Handle the `'lm-dragleave'` event for the widget.
|
232 | */
|
233 | protected evtDragLeave(event: IDragEvent): void;
|
234 | /**
|
235 | * Handle the `'lm-dragover'` event for the widget.
|
236 | */
|
237 | protected evtDragOver(event: IDragEvent): void;
|
238 | /**
|
239 | * Handle the `'lm-drop'` event for the widget.
|
240 | */
|
241 | protected evtDrop(event: IDragEvent): void;
|
242 | /**
|
243 | * Start a drag event.
|
244 | */
|
245 | private _startDrag;
|
246 | /**
|
247 | * Handle selection on a file node.
|
248 | */
|
249 | protected handleFileSelect(event: MouseEvent): void;
|
250 | /**
|
251 | * (Re-)focus on the selected file.
|
252 | *
|
253 | * If index is not given, it will be inferred from the current selection;
|
254 | * providing index saves on the iteration time.
|
255 | */
|
256 | private _focusSelectedFile;
|
257 | /**
|
258 | * Handle a multiple select on a file item node.
|
259 | */
|
260 | private _handleMultiSelect;
|
261 | /**
|
262 | * Copy the selected items, and optionally cut as well.
|
263 | */
|
264 | private _copy;
|
265 | /**
|
266 | * Delete the files with the given paths.
|
267 | */
|
268 | private _delete;
|
269 | /**
|
270 | * Allow the user to rename item on a given row.
|
271 | */
|
272 | private _doRename;
|
273 | /**
|
274 | * Select a given item.
|
275 | */
|
276 | private _selectItem;
|
277 | /**
|
278 | * Handle the `refreshed` signal from the model.
|
279 | */
|
280 | private _onModelRefreshed;
|
281 | /**
|
282 | * Handle a `pathChanged` signal from the model.
|
283 | */
|
284 | private _onPathChanged;
|
285 | /**
|
286 | * Handle a `fileChanged` signal from the model.
|
287 | */
|
288 | private _onFileChanged;
|
289 | /**
|
290 | * Handle an `activateRequested` signal from the manager.
|
291 | */
|
292 | private _onActivateRequested;
|
293 | protected translator: ITranslator;
|
294 | protected _model: FilterFileBrowserModel;
|
295 | private _trans;
|
296 | private _editNode;
|
297 | private _items;
|
298 | private _sortedItems;
|
299 | private _sortState;
|
300 | private _onItemOpened;
|
301 | private _drag;
|
302 | private _dragData;
|
303 | private _selectTimer;
|
304 | private _isCut;
|
305 | private _prevPath;
|
306 | private _clipboard;
|
307 | private _manager;
|
308 | private _softSelection;
|
309 | protected selection: {
|
310 | [key: string]: boolean;
|
311 | };
|
312 | private _renderer;
|
313 | private _searchPrefix;
|
314 | private _searchPrefixTimer;
|
315 | private _inRename;
|
316 | private _isDirty;
|
317 | private _hiddenColumns;
|
318 | }
|
319 |
|
320 |
|
321 |
|
322 | export declare namespace DirListing {
|
323 | |
324 |
|
325 |
|
326 | interface IOptions {
|
327 | |
328 |
|
329 |
|
330 | model: FilterFileBrowserModel;
|
331 | |
332 |
|
333 |
|
334 |
|
335 |
|
336 | renderer?: IRenderer;
|
337 | |
338 |
|
339 |
|
340 | translator?: ITranslator;
|
341 | }
|
342 | |
343 |
|
344 |
|
345 | interface ISortState {
|
346 | |
347 |
|
348 |
|
349 | direction: 'ascending' | 'descending';
|
350 | |
351 |
|
352 |
|
353 | key: 'name' | 'last_modified';
|
354 | }
|
355 | |
356 |
|
357 |
|
358 | type ToggleableColumn = 'last_modified';
|
359 | |
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 | interface IContentsThunk {
|
367 | |
368 |
|
369 |
|
370 | model: Contents.IModel;
|
371 | |
372 |
|
373 |
|
374 | withContent: () => Promise<Contents.IModel>;
|
375 | }
|
376 | |
377 |
|
378 |
|
379 | interface IRenderer {
|
380 | |
381 |
|
382 |
|
383 | createNode(): HTMLElement;
|
384 | |
385 |
|
386 |
|
387 |
|
388 |
|
389 | populateHeaderNode(node: HTMLElement, translator?: ITranslator, hiddenColumns?: Set<DirListing.ToggleableColumn>): void;
|
390 | |
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 | handleHeaderClick(node: HTMLElement, event: MouseEvent): ISortState | null;
|
400 | |
401 |
|
402 |
|
403 |
|
404 |
|
405 | createItemNode(hiddenColumns?: Set<DirListing.ToggleableColumn>): HTMLElement;
|
406 | |
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 | updateItemNode(node: HTMLElement, model: Contents.IModel, fileType?: DocumentRegistry.IFileType, translator?: ITranslator, hiddenColumns?: Set<DirListing.ToggleableColumn>): void;
|
416 | |
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 | getNameNode(node: HTMLElement): HTMLElement;
|
424 | |
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 | createDragImage(node: HTMLElement, count: number, trans: TranslationBundle, fileType?: DocumentRegistry.IFileType): HTMLElement;
|
436 | }
|
437 | |
438 |
|
439 |
|
440 | class Renderer implements IRenderer {
|
441 | |
442 |
|
443 |
|
444 | createNode(): HTMLElement;
|
445 | |
446 |
|
447 |
|
448 |
|
449 |
|
450 | populateHeaderNode(node: HTMLElement, translator?: ITranslator, hiddenColumns?: Set<DirListing.ToggleableColumn>): void;
|
451 | |
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | handleHeaderClick(node: HTMLElement, event: MouseEvent): ISortState | null;
|
461 | |
462 |
|
463 |
|
464 |
|
465 |
|
466 | createItemNode(hiddenColumns?: Set<DirListing.ToggleableColumn>): HTMLElement;
|
467 | |
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | updateItemNode(node: HTMLElement, model: Contents.IModel, fileType?: DocumentRegistry.IFileType, translator?: ITranslator, hiddenColumns?: Set<DirListing.ToggleableColumn>): void;
|
478 | |
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | getNameNode(node: HTMLElement): HTMLElement;
|
486 | |
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 | createDragImage(node: HTMLElement, count: number, trans: TranslationBundle, fileType?: DocumentRegistry.IFileType): HTMLElement;
|
498 | |
499 |
|
500 |
|
501 | protected createHeaderItemNode(label: string): HTMLElement;
|
502 | }
|
503 | |
504 |
|
505 |
|
506 | const defaultRenderer: Renderer;
|
507 | }
|