UNPKG

3.54 kBTypeScriptView Raw
1import type { WidgetTracker } from '@jupyterlab/apputils';
2import type { IStateDB } from '@jupyterlab/statedb';
3import { Token } from '@lumino/coreutils';
4import type { FileBrowser } from './browser';
5/**
6 * The file browser factory token.
7 */
8export declare const IFileBrowserFactory: Token<IFileBrowserFactory>;
9/**
10 * The default file browser token.
11 */
12export declare const IDefaultFileBrowser: Token<FileBrowser>;
13/**
14 * Default file browser type.
15 */
16export type IDefaultFileBrowser = FileBrowser;
17/**
18 * The file browser factory interface.
19 */
20export interface IFileBrowserFactory {
21 /**
22 * Create a new file browser instance.
23 *
24 * @param id - The widget/DOM id of the file browser.
25 *
26 * @param options - The optional file browser configuration object.
27 *
28 * #### Notes
29 * The ID parameter is used to set the widget ID. It is also used as part of
30 * the unique key necessary to store the file browser's restoration data in
31 * the state database if that functionality is enabled.
32 *
33 * If, after the file browser has been generated by the factory, the ID of the
34 * resulting widget is changed by client code, the restoration functionality
35 * will not be disrupted as long as there are no ID collisions, i.e., as long
36 * as the initial ID passed into the factory is used for only one file browser
37 * instance.
38 */
39 createFileBrowser(id: string, options?: IFileBrowserFactory.IOptions): FileBrowser;
40 /**
41 * The widget tracker used by the factory to track file browsers.
42 */
43 readonly tracker: WidgetTracker<FileBrowser>;
44}
45/**
46 * A namespace for file browser factory interfaces.
47 */
48export declare namespace IFileBrowserFactory {
49 /**
50 * The options for creating a file browser using a file browser factory.
51 *
52 * #### Notes
53 * In future versions of JupyterLab, some of these options may disappear,
54 * which is a backward-incompatible API change and will necessitate a new
55 * version release. This is because in future versions, there will likely be
56 * an application-wide notion of a singleton command registry and a singleton
57 * state database.
58 */
59 interface IOptions {
60 /**
61 * Whether a file browser automatically loads its initial path.
62 *
63 * #### Notes
64 * The default is `true`.
65 */
66 auto?: boolean;
67 /**
68 * An optional `Contents.IDrive` name for the model.
69 * If given, the model will prepend `driveName:` to
70 * all paths used in file operations.
71 */
72 driveName?: string;
73 /**
74 * The time interval for browser refreshing, in ms.
75 */
76 refreshInterval?: number;
77 /**
78 * Whether a file browser automatically restores state when instantiated.
79 * The default is `true`.
80 *
81 * #### Notes
82 * The file browser model will need to be restored before for the file
83 * browser to start saving its state.
84 */
85 restore?: boolean;
86 /**
87 * The state database to use for saving file browser state and restoring it.
88 *
89 * #### Notes
90 * Unless the value `null` is set for this option, the application state
91 * database will be automatically passed in and used for state restoration.
92 */
93 state?: IStateDB | null;
94 }
95}
96/**
97 * The token that indicates the default file browser commands are loaded.
98 */
99export declare const IFileBrowserCommands: Token<void>;