@jupyterlab/apputils 0.17.2 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/thememanager.d.ts +17 -1
- package/lib/thememanager.js +19 -0
- package/lib/thememanager.js.map +1 -1
- package/lib/toolbar.d.ts +51 -47
- package/lib/toolbar.js +117 -178
- package/lib/toolbar.js.map +1 -1
- package/package.json +3 -3
- package/style/commandpalette.css +2 -4
- package/style/styling.css +0 -5
- package/style/toolbar.css +62 -44
package/lib/thememanager.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ISettingRegistry } from '@jupyterlab/coreutils';
|
|
1
|
+
import { IChangedArgs, ISettingRegistry } from '@jupyterlab/coreutils';
|
|
2
2
|
import { Token } from '@phosphor/coreutils';
|
|
3
3
|
import { IDisposable } from '@phosphor/disposable';
|
|
4
4
|
import { Widget } from '@phosphor/widgets';
|
|
5
|
+
import { ISignal } from '@phosphor/signaling';
|
|
5
6
|
import { ISplashScreen } from './splash';
|
|
6
7
|
/**
|
|
7
8
|
* The theme manager token.
|
|
@@ -28,6 +29,10 @@ export declare class ThemeManager {
|
|
|
28
29
|
* The names of the registered themes.
|
|
29
30
|
*/
|
|
30
31
|
readonly themes: ReadonlyArray<string>;
|
|
32
|
+
/**
|
|
33
|
+
* A signal fired when the application theme changes.
|
|
34
|
+
*/
|
|
35
|
+
readonly themeChanged: ISignal<this, IChangedArgs<string>>;
|
|
31
36
|
/**
|
|
32
37
|
* Load a theme CSS file by path.
|
|
33
38
|
*
|
|
@@ -46,6 +51,10 @@ export declare class ThemeManager {
|
|
|
46
51
|
* Set the current theme.
|
|
47
52
|
*/
|
|
48
53
|
setTheme(name: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Test whether a given theme is light.
|
|
56
|
+
*/
|
|
57
|
+
isLight(name: string): boolean;
|
|
49
58
|
/**
|
|
50
59
|
* Handle the current settings.
|
|
51
60
|
*/
|
|
@@ -71,6 +80,7 @@ export declare class ThemeManager {
|
|
|
71
80
|
private _settings;
|
|
72
81
|
private _splash;
|
|
73
82
|
private _themes;
|
|
83
|
+
private _themeChanged;
|
|
74
84
|
}
|
|
75
85
|
/**
|
|
76
86
|
* A namespace for `ThemeManager` statics.
|
|
@@ -109,6 +119,12 @@ export declare namespace ThemeManager {
|
|
|
109
119
|
* The display name of the theme.
|
|
110
120
|
*/
|
|
111
121
|
name: string;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the theme is light or dark. Downstream authors
|
|
124
|
+
* of extensions can use this information to customize their
|
|
125
|
+
* UI depending upon the current theme.
|
|
126
|
+
*/
|
|
127
|
+
isLight: boolean;
|
|
112
128
|
/**
|
|
113
129
|
* Load the theme.
|
|
114
130
|
*
|
package/lib/thememanager.js
CHANGED
|
@@ -6,6 +6,7 @@ const coreutils_1 = require("@jupyterlab/coreutils");
|
|
|
6
6
|
const algorithm_1 = require("@phosphor/algorithm");
|
|
7
7
|
const coreutils_2 = require("@phosphor/coreutils");
|
|
8
8
|
const disposable_1 = require("@phosphor/disposable");
|
|
9
|
+
const signaling_1 = require("@phosphor/signaling");
|
|
9
10
|
const dialog_1 = require("./dialog");
|
|
10
11
|
/* tslint:disable */
|
|
11
12
|
/**
|
|
@@ -34,6 +35,7 @@ class ThemeManager {
|
|
|
34
35
|
this._pending = 0;
|
|
35
36
|
this._requests = {};
|
|
36
37
|
this._themes = {};
|
|
38
|
+
this._themeChanged = new signaling_1.Signal(this);
|
|
37
39
|
const { host, key, splash, url } = options;
|
|
38
40
|
const registry = options.settings;
|
|
39
41
|
this._base = url;
|
|
@@ -57,6 +59,12 @@ class ThemeManager {
|
|
|
57
59
|
get themes() {
|
|
58
60
|
return Object.keys(this._themes);
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* A signal fired when the application theme changes.
|
|
64
|
+
*/
|
|
65
|
+
get themeChanged() {
|
|
66
|
+
return this._themeChanged;
|
|
67
|
+
}
|
|
60
68
|
/**
|
|
61
69
|
* Load a theme CSS file by path.
|
|
62
70
|
*
|
|
@@ -105,6 +113,12 @@ class ThemeManager {
|
|
|
105
113
|
setTheme(name) {
|
|
106
114
|
return this._settings.set('theme', name);
|
|
107
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Test whether a given theme is light.
|
|
118
|
+
*/
|
|
119
|
+
isLight(name) {
|
|
120
|
+
return this._themes[name].isLight;
|
|
121
|
+
}
|
|
108
122
|
/**
|
|
109
123
|
* Handle the current settings.
|
|
110
124
|
*/
|
|
@@ -185,6 +199,11 @@ class ThemeManager {
|
|
|
185
199
|
this._current = theme;
|
|
186
200
|
Private.fitAll(this._host);
|
|
187
201
|
splash.dispose();
|
|
202
|
+
this._themeChanged.emit({
|
|
203
|
+
name: 'theme',
|
|
204
|
+
oldValue: current,
|
|
205
|
+
newValue: theme
|
|
206
|
+
});
|
|
188
207
|
})
|
|
189
208
|
.catch(reason => {
|
|
190
209
|
this._onError(reason);
|
package/lib/thememanager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thememanager.js","sourceRoot":"","sources":["../../../../apputils/src/thememanager.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;AAE3D,qDAAiE;AAEjE,mDAA2C;AAE3C,mDAA4C;AAE5C,qDAAuE;AAIvE,qCAA8C;AAI9C,oBAAoB;AACpB;;GAEG;AACU,QAAA,aAAa,GAAG,IAAI,iBAAK,CACpC,oCAAoC,CACrC,CAAC;AAQF;;GAEG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;GAEG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH;IACE;;OAEG;IACH,YAAY,OAA8B;QAuMlC,aAAQ,GAAkB,IAAI,CAAC;QAE/B,WAAM,GAAsB,EAAE,CAAC;QAC/B,iBAAY,GAAyB,IAAI,CAAC;QAC1C,aAAQ,GAAG,CAAC,CAAC;QACb,cAAS,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IAAI,CAAC,GAAG,EAAE;YACT,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC;aACD,KAAK,CAAC,MAAM,CAAC,EAAE;YACd,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtB,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACK,QAAQ,CAAC,MAAW;QAC1B,mBAAU,CAAC;YACT,KAAK,EAAE,qBAAqB;YAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,CAAC,eAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;CAYF;AApND,oCAoNC;AA6DD;;GAEG;AACH,IAAU,OAAO,CAQhB;AARD,WAAU,OAAO;IACf;;OAEG;IACH,gBAAuB,MAAc;QACnC,gBAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IAHe,cAAM,SAGrB,CAAA;AACH,CAAC,EARS,OAAO,KAAP,OAAO,QAQhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport { ISettingRegistry, URLExt } from '@jupyterlab/coreutils';\n\nimport { each } from '@phosphor/algorithm';\n\nimport { Token } from '@phosphor/coreutils';\n\nimport { DisposableDelegate, IDisposable } from '@phosphor/disposable';\n\nimport { Widget } from '@phosphor/widgets';\n\nimport { Dialog, showDialog } from './dialog';\n\nimport { ISplashScreen } from './splash';\n\n/* tslint:disable */\n/**\n * The theme manager token.\n */\nexport const IThemeManager = new Token<IThemeManager>(\n '@jupyterlab/apputils:IThemeManager'\n);\n/* tslint:enable */\n\n/**\n * An interface for a theme manager.\n */\nexport interface IThemeManager extends ThemeManager {}\n\n/**\n * The number of milliseconds between theme loading attempts.\n */\nconst REQUEST_INTERVAL = 75;\n\n/**\n * The number of times to attempt to load a theme before giving up.\n */\nconst REQUEST_THRESHOLD = 20;\n\n/**\n * A class that provides theme management.\n */\nexport class ThemeManager {\n /**\n * Construct a new theme manager.\n */\n constructor(options: ThemeManager.IOptions) {\n const { host, key, splash, url } = options;\n const registry = options.settings;\n\n this._base = url;\n this._host = host;\n this._splash = splash;\n\n registry.load(key).then(settings => {\n this._settings = settings;\n this._settings.changed.connect(this._loadSettings, this);\n this._loadSettings();\n });\n }\n\n /**\n * Get the name of the current theme.\n */\n get theme(): string | null {\n return this._current;\n }\n\n /**\n * The names of the registered themes.\n */\n get themes(): ReadonlyArray<string> {\n return Object.keys(this._themes);\n }\n\n /**\n * Load a theme CSS file by path.\n *\n * @param path - The path of the file to load.\n */\n loadCSS(path: string): Promise<void> {\n const base = this._base;\n const href = URLExt.isLocal(path) ? URLExt.join(base, path) : path;\n const links = this._links;\n\n return new Promise((resolve, reject) => {\n const link = document.createElement('link');\n\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('type', 'text/css');\n link.setAttribute('href', href);\n link.addEventListener('load', () => {\n resolve(undefined);\n });\n link.addEventListener('error', () => {\n reject(`Stylesheet failed to load: ${href}`);\n });\n\n document.body.appendChild(link);\n links.push(link);\n });\n }\n\n /**\n * Register a theme with the theme manager.\n *\n * @param theme - The theme to register.\n *\n * @returns A disposable that can be used to unregister the theme.\n */\n register(theme: ThemeManager.ITheme): IDisposable {\n const { name } = theme;\n const themes = this._themes;\n\n if (themes[name]) {\n throw new Error(`Theme already registered for ${name}`);\n }\n\n themes[name] = theme;\n\n return new DisposableDelegate(() => {\n delete themes[name];\n });\n }\n\n /**\n * Set the current theme.\n */\n setTheme(name: string): Promise<void> {\n return this._settings.set('theme', name);\n }\n\n /**\n * Handle the current settings.\n */\n private _loadSettings(): void {\n const outstanding = this._outstanding;\n const pending = this._pending;\n const requests = this._requests;\n\n // If another request is pending, cancel it.\n if (pending) {\n window.clearTimeout(pending);\n this._pending = 0;\n }\n\n const settings = this._settings;\n const themes = this._themes;\n const theme = settings.composite['theme'] as string;\n\n // If another promise is outstanding, wait until it finishes before\n // attempting to load the settings. Because outstanding promises cannot\n // be aborted, the order in which they occur must be enforced.\n if (outstanding) {\n outstanding\n .then(() => {\n this._loadSettings();\n })\n .catch(() => {\n this._loadSettings();\n });\n this._outstanding = null;\n return;\n }\n\n // Increment the request counter.\n requests[theme] = requests[theme] ? requests[theme] + 1 : 1;\n\n // If the theme exists, load it right away.\n if (themes[theme]) {\n this._outstanding = this._loadTheme(theme);\n delete requests[theme];\n return;\n }\n\n // If the request has taken too long, give up.\n if (requests[theme] > REQUEST_THRESHOLD) {\n const fallback = settings.default('theme') as string;\n\n // Stop tracking the requests for this theme.\n delete requests[theme];\n\n if (!themes[fallback]) {\n this._onError(`Neither theme ${theme} nor default ${fallback} loaded.`);\n return;\n }\n\n console.warn(`Could not load theme ${theme}, using default ${fallback}.`);\n this._outstanding = this._loadTheme(fallback);\n return;\n }\n\n // If the theme does not yet exist, attempt to wait for it.\n this._pending = window.setTimeout(() => {\n this._loadSettings();\n }, REQUEST_INTERVAL);\n }\n\n /**\n * Load the theme.\n *\n * #### Notes\n * This method assumes that the `theme` exists.\n */\n private _loadTheme(theme: string): Promise<void> {\n const current = this._current;\n const links = this._links;\n const themes = this._themes;\n const splash = this._splash.show();\n\n // Unload any CSS files that have been loaded.\n links.forEach(link => {\n if (link.parentElement) {\n link.parentElement.removeChild(link);\n }\n });\n links.length = 0;\n\n // Unload the previously loaded theme.\n const old = current ? themes[current].unload() : Promise.resolve();\n\n return Promise.all([old, themes[theme].load()])\n .then(() => {\n this._current = theme;\n Private.fitAll(this._host);\n splash.dispose();\n })\n .catch(reason => {\n this._onError(reason);\n splash.dispose();\n });\n }\n\n /**\n * Handle a theme error.\n */\n private _onError(reason: any): void {\n showDialog({\n title: 'Error Loading Theme',\n body: String(reason),\n buttons: [Dialog.okButton({ label: 'OK' })]\n });\n }\n\n private _base: string;\n private _current: string | null = null;\n private _host: Widget;\n private _links: HTMLLinkElement[] = [];\n private _outstanding: Promise<void> | null = null;\n private _pending = 0;\n private _requests: { [theme: string]: number } = {};\n private _settings: ISettingRegistry.ISettings;\n private _splash: ISplashScreen;\n private _themes: { [key: string]: ThemeManager.ITheme } = {};\n}\n\n/**\n * A namespace for `ThemeManager` statics.\n */\nexport namespace ThemeManager {\n /**\n * The options used to create a theme manager.\n */\n export interface IOptions {\n /**\n * The host widget for the theme manager.\n */\n host: Widget;\n\n /**\n * The setting registry key that holds theme setting data.\n */\n key: string;\n\n /**\n * The settings registry.\n */\n settings: ISettingRegistry;\n\n /**\n * The splash screen to show when loading themes.\n */\n splash: ISplashScreen;\n\n /**\n * The url for local theme loading.\n */\n url: string;\n }\n\n /**\n * An interface for a theme.\n */\n export interface ITheme {\n /**\n * The display name of the theme.\n */\n name: string;\n\n /**\n * Load the theme.\n *\n * @returns A promise that resolves when the theme has loaded.\n */\n load(): Promise<void>;\n\n /**\n * Unload the theme.\n *\n * @returns A promise that resolves when the theme has unloaded.\n */\n unload(): Promise<void>;\n }\n}\n\n/**\n * A namespace for module private data.\n */\nnamespace Private {\n /**\n * Fit a widget and all of its children, recursively.\n */\n export function fitAll(widget: Widget): void {\n each(widget.children(), fitAll);\n widget.fit();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"thememanager.js","sourceRoot":"","sources":["../../../../apputils/src/thememanager.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;AAE3D,qDAA+E;AAE/E,mDAA2C;AAE3C,mDAA4C;AAE5C,qDAAuE;AAIvE,mDAAsD;AAEtD,qCAA8C;AAI9C,oBAAoB;AACpB;;GAEG;AACU,QAAA,aAAa,GAAG,IAAI,iBAAK,CACpC,oCAAoC,CACrC,CAAC;AAQF;;GAE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C,CAAC;IACL,CAAC;CAaF;AAxOD,oCAwOC;AAoED;;GAEG;AACH,IAAU,OAAO,CAQhB;AARD,WAAU,OAAO;IACf;;OAEG;IACH,gBAAuB,MAAc;QACnC,gBAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IAHe,cAAM,SAGrB,CAAA;AACH,CAAC,EARS,OAAO,KAAP,OAAO,QAQhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport { IChangedArgs, ISettingRegistry, URLExt } from '@jupyterlab/coreutils';\n\nimport { each } from '@phosphor/algorithm';\n\nimport { Token } from '@phosphor/coreutils';\n\nimport { DisposableDelegate, IDisposable } from '@phosphor/disposable';\n\nimport { Widget } from '@phosphor/widgets';\n\nimport { ISignal, Signal } from '@phosphor/signaling';\n\nimport { Dialog, showDialog } from './dialog';\n\nimport { ISplashScreen } from './splash';\n\n/* tslint:disable */\n/**\n * The theme manager token.\n */\nexport const IThemeManager = new Token<IThemeManager>(\n '@jupyterlab/apputils:IThemeManager'\n);\n/* tslint:enable */\n\n/**\n * An interface for a theme manager.\n */\nexport interface IThemeManager extends ThemeManager {}\n\n/**\n * The number of milliseconds between theme loading attempts.\n */\nconst REQUEST_INTERVAL = 75;\n\n/**\n * The number of times to attempt to load a theme before giving up.\n */\nconst REQUEST_THRESHOLD = 20;\n\n/**\n * A class that provides theme management.\n */\nexport class ThemeManager {\n /**\n * Construct a new theme manager.\n */\n constructor(options: ThemeManager.IOptions) {\n const { host, key, splash, url } = options;\n const registry = options.settings;\n\n this._base = url;\n this._host = host;\n this._splash = splash;\n\n registry.load(key).then(settings => {\n this._settings = settings;\n this._settings.changed.connect(this._loadSettings, this);\n this._loadSettings();\n });\n }\n\n /**\n * Get the name of the current theme.\n */\n get theme(): string | null {\n return this._current;\n }\n\n /**\n * The names of the registered themes.\n */\n get themes(): ReadonlyArray<string> {\n return Object.keys(this._themes);\n }\n\n /**\n * A signal fired when the application theme changes.\n */\n get themeChanged(): ISignal<this, IChangedArgs<string>> {\n return this._themeChanged;\n }\n\n /**\n * Load a theme CSS file by path.\n *\n * @param path - The path of the file to load.\n */\n loadCSS(path: string): Promise<void> {\n const base = this._base;\n const href = URLExt.isLocal(path) ? URLExt.join(base, path) : path;\n const links = this._links;\n\n return new Promise((resolve, reject) => {\n const link = document.createElement('link');\n\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('type', 'text/css');\n link.setAttribute('href', href);\n link.addEventListener('load', () => {\n resolve(undefined);\n });\n link.addEventListener('error', () => {\n reject(`Stylesheet failed to load: ${href}`);\n });\n\n document.body.appendChild(link);\n links.push(link);\n });\n }\n\n /**\n * Register a theme with the theme manager.\n *\n * @param theme - The theme to register.\n *\n * @returns A disposable that can be used to unregister the theme.\n */\n register(theme: ThemeManager.ITheme): IDisposable {\n const { name } = theme;\n const themes = this._themes;\n\n if (themes[name]) {\n throw new Error(`Theme already registered for ${name}`);\n }\n\n themes[name] = theme;\n\n return new DisposableDelegate(() => {\n delete themes[name];\n });\n }\n\n /**\n * Set the current theme.\n */\n setTheme(name: string): Promise<void> {\n return this._settings.set('theme', name);\n }\n\n /**\n * Test whether a given theme is light.\n */\n isLight(name: string): boolean {\n return this._themes[name].isLight;\n }\n\n /**\n * Handle the current settings.\n */\n private _loadSettings(): void {\n const outstanding = this._outstanding;\n const pending = this._pending;\n const requests = this._requests;\n\n // If another request is pending, cancel it.\n if (pending) {\n window.clearTimeout(pending);\n this._pending = 0;\n }\n\n const settings = this._settings;\n const themes = this._themes;\n const theme = settings.composite['theme'] as string;\n\n // If another promise is outstanding, wait until it finishes before\n // attempting to load the settings. Because outstanding promises cannot\n // be aborted, the order in which they occur must be enforced.\n if (outstanding) {\n outstanding\n .then(() => {\n this._loadSettings();\n })\n .catch(() => {\n this._loadSettings();\n });\n this._outstanding = null;\n return;\n }\n\n // Increment the request counter.\n requests[theme] = requests[theme] ? requests[theme] + 1 : 1;\n\n // If the theme exists, load it right away.\n if (themes[theme]) {\n this._outstanding = this._loadTheme(theme);\n delete requests[theme];\n return;\n }\n\n // If the request has taken too long, give up.\n if (requests[theme] > REQUEST_THRESHOLD) {\n const fallback = settings.default('theme') as string;\n\n // Stop tracking the requests for this theme.\n delete requests[theme];\n\n if (!themes[fallback]) {\n this._onError(`Neither theme ${theme} nor default ${fallback} loaded.`);\n return;\n }\n\n console.warn(`Could not load theme ${theme}, using default ${fallback}.`);\n this._outstanding = this._loadTheme(fallback);\n return;\n }\n\n // If the theme does not yet exist, attempt to wait for it.\n this._pending = window.setTimeout(() => {\n this._loadSettings();\n }, REQUEST_INTERVAL);\n }\n\n /**\n * Load the theme.\n *\n * #### Notes\n * This method assumes that the `theme` exists.\n */\n private _loadTheme(theme: string): Promise<void> {\n const current = this._current;\n const links = this._links;\n const themes = this._themes;\n const splash = this._splash.show();\n\n // Unload any CSS files that have been loaded.\n links.forEach(link => {\n if (link.parentElement) {\n link.parentElement.removeChild(link);\n }\n });\n links.length = 0;\n\n // Unload the previously loaded theme.\n const old = current ? themes[current].unload() : Promise.resolve();\n\n return Promise.all([old, themes[theme].load()])\n .then(() => {\n this._current = theme;\n Private.fitAll(this._host);\n splash.dispose();\n this._themeChanged.emit({\n name: 'theme',\n oldValue: current,\n newValue: theme\n });\n })\n .catch(reason => {\n this._onError(reason);\n splash.dispose();\n });\n }\n\n /**\n * Handle a theme error.\n */\n private _onError(reason: any): void {\n showDialog({\n title: 'Error Loading Theme',\n body: String(reason),\n buttons: [Dialog.okButton({ label: 'OK' })]\n });\n }\n\n private _base: string;\n private _current: string | null = null;\n private _host: Widget;\n private _links: HTMLLinkElement[] = [];\n private _outstanding: Promise<void> | null = null;\n private _pending = 0;\n private _requests: { [theme: string]: number } = {};\n private _settings: ISettingRegistry.ISettings;\n private _splash: ISplashScreen;\n private _themes: { [key: string]: ThemeManager.ITheme } = {};\n private _themeChanged = new Signal<this, IChangedArgs<string>>(this);\n}\n\n/**\n * A namespace for `ThemeManager` statics.\n */\nexport namespace ThemeManager {\n /**\n * The options used to create a theme manager.\n */\n export interface IOptions {\n /**\n * The host widget for the theme manager.\n */\n host: Widget;\n\n /**\n * The setting registry key that holds theme setting data.\n */\n key: string;\n\n /**\n * The settings registry.\n */\n settings: ISettingRegistry;\n\n /**\n * The splash screen to show when loading themes.\n */\n splash: ISplashScreen;\n\n /**\n * The url for local theme loading.\n */\n url: string;\n }\n\n /**\n * An interface for a theme.\n */\n export interface ITheme {\n /**\n * The display name of the theme.\n */\n name: string;\n\n /**\n * Whether the theme is light or dark. Downstream authors\n * of extensions can use this information to customize their\n * UI depending upon the current theme.\n */\n isLight: boolean;\n\n /**\n * Load the theme.\n *\n * @returns A promise that resolves when the theme has loaded.\n */\n load(): Promise<void>;\n\n /**\n * Unload the theme.\n *\n * @returns A promise that resolves when the theme has unloaded.\n */\n unload(): Promise<void>;\n }\n}\n\n/**\n * A namespace for module private data.\n */\nnamespace Private {\n /**\n * Fit a widget and all of its children, recursively.\n */\n export function fitAll(widget: Widget): void {\n each(widget.children(), fitAll);\n widget.fit();\n }\n}\n"]}
|
package/lib/toolbar.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ReactElementWidget } from './vdom';
|
|
1
2
|
import { IIterator } from '@phosphor/algorithm';
|
|
2
3
|
import { CommandRegistry } from '@phosphor/commands';
|
|
3
4
|
import { Message } from '@phosphor/messaging';
|
|
4
5
|
import { Widget } from '@phosphor/widgets';
|
|
5
6
|
import { IClientSession } from './clientsession';
|
|
7
|
+
import * as React from 'react';
|
|
6
8
|
/**
|
|
7
9
|
* A class which provides a toolbar widget.
|
|
8
10
|
*/
|
|
@@ -74,16 +76,6 @@ export declare class Toolbar<T extends Widget = Widget> extends Widget {
|
|
|
74
76
|
* The namespace for Toolbar class statics.
|
|
75
77
|
*/
|
|
76
78
|
export declare namespace Toolbar {
|
|
77
|
-
/**
|
|
78
|
-
* Create a toolbar item for a command or `null` if the command does not exist
|
|
79
|
-
* in the registry.
|
|
80
|
-
*
|
|
81
|
-
* Notes:
|
|
82
|
-
* If the command has an icon label it will be added to the button.
|
|
83
|
-
* If there is no icon label, and no icon class, the main label will
|
|
84
|
-
* be added.
|
|
85
|
-
*/
|
|
86
|
-
function createFromCommand(commands: CommandRegistry, id: string): ToolbarButton | null;
|
|
87
79
|
/**
|
|
88
80
|
* Create an interrupt toolbar item.
|
|
89
81
|
*/
|
|
@@ -121,53 +113,65 @@ export declare namespace Toolbar {
|
|
|
121
113
|
function createKernelStatusItem(session: IClientSession): Widget;
|
|
122
114
|
}
|
|
123
115
|
/**
|
|
124
|
-
*
|
|
116
|
+
* Namespace for ToolbarButtonComponent.
|
|
125
117
|
*/
|
|
126
|
-
export declare
|
|
118
|
+
export declare namespace ToolbarButtonComponent {
|
|
127
119
|
/**
|
|
128
|
-
*
|
|
120
|
+
* Interface for ToolbarButttonComponent props.
|
|
129
121
|
*/
|
|
130
|
-
|
|
122
|
+
interface IProps {
|
|
123
|
+
className?: string;
|
|
124
|
+
label?: string;
|
|
125
|
+
iconClassName?: string;
|
|
126
|
+
iconLabel?: string;
|
|
127
|
+
tooltip?: string;
|
|
128
|
+
onClick?: () => void;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* React component for a toolbar button.
|
|
133
|
+
*
|
|
134
|
+
* @param props - The props for ToolbarButtonComponent.
|
|
135
|
+
*/
|
|
136
|
+
export declare function ToolbarButtonComponent(props: ToolbarButtonComponent.IProps): JSX.Element;
|
|
137
|
+
/**
|
|
138
|
+
* Phosphor Widget version of ToolbarButtonComponent.
|
|
139
|
+
*/
|
|
140
|
+
export declare class ToolbarButton extends ReactElementWidget {
|
|
131
141
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* @param event - The DOM event sent to the widget.
|
|
142
|
+
* Create a ToolbarButton.
|
|
135
143
|
*
|
|
136
|
-
*
|
|
137
|
-
* This method implements the DOM `EventListener` interface and is
|
|
138
|
-
* called in response to events on the dock panel's node. It should
|
|
139
|
-
* not be called directly by user code.
|
|
144
|
+
* @param props - Props for ToolbarButtonComponent.
|
|
140
145
|
*/
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Handle `after-attach` messages for the widget.
|
|
144
|
-
*/
|
|
145
|
-
protected onAfterAttach(msg: Message): void;
|
|
146
|
-
/**
|
|
147
|
-
* Handle `before-detach` messages for the widget.
|
|
148
|
-
*/
|
|
149
|
-
protected onBeforeDetach(msg: Message): void;
|
|
150
|
-
private _onClick;
|
|
146
|
+
constructor(props?: ToolbarButtonComponent.IProps);
|
|
151
147
|
}
|
|
152
148
|
/**
|
|
153
|
-
*
|
|
149
|
+
* Namespace for CommandToolbarButtonComponent.
|
|
154
150
|
*/
|
|
155
|
-
export declare namespace
|
|
151
|
+
export declare namespace CommandToolbarButtonComponent {
|
|
156
152
|
/**
|
|
157
|
-
*
|
|
153
|
+
* Interface for CommandToolbarButtonComponent props.
|
|
158
154
|
*/
|
|
159
|
-
interface
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*/
|
|
163
|
-
onClick?: () => void;
|
|
164
|
-
/**
|
|
165
|
-
* The class name added to the button.
|
|
166
|
-
*/
|
|
167
|
-
className?: string;
|
|
168
|
-
/**
|
|
169
|
-
* The tooltip added to the button node.
|
|
170
|
-
*/
|
|
171
|
-
tooltip?: string;
|
|
155
|
+
interface IProps {
|
|
156
|
+
commands: CommandRegistry;
|
|
157
|
+
id: string;
|
|
172
158
|
}
|
|
173
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* React component for a toolbar button that wraps a command.
|
|
162
|
+
*
|
|
163
|
+
* This wraps the ToolbarButtonComponent and watches the command registry
|
|
164
|
+
* for changes to the command.
|
|
165
|
+
*/
|
|
166
|
+
export declare class CommandToolbarButtonComponent extends React.Component<CommandToolbarButtonComponent.IProps> {
|
|
167
|
+
constructor(props: CommandToolbarButtonComponent.IProps);
|
|
168
|
+
render(): JSX.Element;
|
|
169
|
+
private _onChange;
|
|
170
|
+
private _childProps;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Phosphor Widget version of ToolbarButtonComponent.
|
|
174
|
+
*/
|
|
175
|
+
export declare class CommandToolbarButton extends ReactElementWidget {
|
|
176
|
+
constructor(props: CommandToolbarButtonComponent.IProps);
|
|
177
|
+
}
|
package/lib/toolbar.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Jupyter Development Team.
|
|
3
3
|
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
5
|
+
if (mod && mod.__esModule) return mod;
|
|
6
|
+
var result = {};
|
|
7
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
8
|
+
result["default"] = mod;
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
4
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const vdom_1 = require("./vdom");
|
|
5
13
|
const algorithm_1 = require("@phosphor/algorithm");
|
|
6
14
|
const messaging_1 = require("@phosphor/messaging");
|
|
7
15
|
const properties_1 = require("@phosphor/properties");
|
|
8
16
|
const widgets_1 = require("@phosphor/widgets");
|
|
9
|
-
const
|
|
17
|
+
const React = __importStar(require("react"));
|
|
10
18
|
/**
|
|
11
19
|
* The class name added to toolbars.
|
|
12
20
|
*/
|
|
@@ -15,18 +23,6 @@ const TOOLBAR_CLASS = 'jp-Toolbar';
|
|
|
15
23
|
* The class name added to toolbar items.
|
|
16
24
|
*/
|
|
17
25
|
const TOOLBAR_ITEM_CLASS = 'jp-Toolbar-item';
|
|
18
|
-
/**
|
|
19
|
-
* The class name added to toolbar buttons.
|
|
20
|
-
*/
|
|
21
|
-
const TOOLBAR_BUTTON_CLASS = 'jp-Toolbar-button';
|
|
22
|
-
/**
|
|
23
|
-
* The class name added to toolbar interrupt button.
|
|
24
|
-
*/
|
|
25
|
-
const TOOLBAR_INTERRUPT_CLASS = 'jp-StopIcon';
|
|
26
|
-
/**
|
|
27
|
-
* The class name added to toolbar restart button.
|
|
28
|
-
*/
|
|
29
|
-
const TOOLBAR_RESTART_CLASS = 'jp-RefreshIcon';
|
|
30
26
|
/**
|
|
31
27
|
* The class name added to toolbar kernel name text.
|
|
32
28
|
*/
|
|
@@ -260,70 +256,12 @@ exports.Toolbar = Toolbar;
|
|
|
260
256
|
* The namespace for Toolbar class statics.
|
|
261
257
|
*/
|
|
262
258
|
(function (Toolbar) {
|
|
263
|
-
/**
|
|
264
|
-
* Create a toolbar item for a command or `null` if the command does not exist
|
|
265
|
-
* in the registry.
|
|
266
|
-
*
|
|
267
|
-
* Notes:
|
|
268
|
-
* If the command has an icon label it will be added to the button.
|
|
269
|
-
* If there is no icon label, and no icon class, the main label will
|
|
270
|
-
* be added.
|
|
271
|
-
*/
|
|
272
|
-
function createFromCommand(commands, id) {
|
|
273
|
-
if (!commands.hasCommand(id)) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
const button = new ToolbarButton({
|
|
277
|
-
onClick: () => {
|
|
278
|
-
commands.execute(id);
|
|
279
|
-
button.node.blur();
|
|
280
|
-
},
|
|
281
|
-
className: Private.commandClassName(commands, id),
|
|
282
|
-
tooltip: Private.commandTooltip(commands, id)
|
|
283
|
-
});
|
|
284
|
-
let oldClasses = Private.commandClassName(commands, id).split(/\s/);
|
|
285
|
-
button.node.disabled = !commands.isEnabled(id);
|
|
286
|
-
Private.setNodeContentFromCommand(button.node, commands, id);
|
|
287
|
-
// Ensure that we pick up relevant changes to the command:
|
|
288
|
-
function onChange(sender, args) {
|
|
289
|
-
if (args.id !== id) {
|
|
290
|
-
return; // Not our command
|
|
291
|
-
}
|
|
292
|
-
if (args.type === 'removed') {
|
|
293
|
-
// Dispose of button
|
|
294
|
-
button.dispose();
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
if (args.type !== 'changed') {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
// Update all fields (onClick is already indirected)
|
|
301
|
-
const newClasses = Private.commandClassName(sender, id).split(/\s/);
|
|
302
|
-
for (let cls of oldClasses) {
|
|
303
|
-
if (cls && newClasses.indexOf(cls) === -1) {
|
|
304
|
-
button.removeClass(cls);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
for (let cls of newClasses) {
|
|
308
|
-
if (cls && oldClasses.indexOf(cls) === -1) {
|
|
309
|
-
button.addClass(cls);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
oldClasses = newClasses;
|
|
313
|
-
button.node.title = Private.commandTooltip(sender, id);
|
|
314
|
-
Private.setNodeContentFromCommand(button.node, sender, id);
|
|
315
|
-
button.node.disabled = !sender.isEnabled(id);
|
|
316
|
-
}
|
|
317
|
-
commands.commandChanged.connect(onChange, button);
|
|
318
|
-
return button;
|
|
319
|
-
}
|
|
320
|
-
Toolbar.createFromCommand = createFromCommand;
|
|
321
259
|
/**
|
|
322
260
|
* Create an interrupt toolbar item.
|
|
323
261
|
*/
|
|
324
262
|
function createInterruptButton(session) {
|
|
325
263
|
return new ToolbarButton({
|
|
326
|
-
|
|
264
|
+
iconClassName: 'jp-StopIcon jp-Icon jp-Icon-16',
|
|
327
265
|
onClick: () => {
|
|
328
266
|
if (session.kernel) {
|
|
329
267
|
session.kernel.interrupt();
|
|
@@ -338,7 +276,7 @@ exports.Toolbar = Toolbar;
|
|
|
338
276
|
*/
|
|
339
277
|
function createRestartButton(session) {
|
|
340
278
|
return new ToolbarButton({
|
|
341
|
-
|
|
279
|
+
iconClassName: 'jp-RefreshIcon jp-Icon jp-Icon-16',
|
|
342
280
|
onClick: () => {
|
|
343
281
|
session.restart();
|
|
344
282
|
},
|
|
@@ -366,7 +304,7 @@ exports.Toolbar = Toolbar;
|
|
|
366
304
|
* It can handle a change in context or kernel.
|
|
367
305
|
*/
|
|
368
306
|
function createKernelNameItem(session) {
|
|
369
|
-
return new Private.KernelName(session);
|
|
307
|
+
return new Private.KernelName({ session });
|
|
370
308
|
}
|
|
371
309
|
Toolbar.createKernelNameItem = createKernelNameItem;
|
|
372
310
|
/**
|
|
@@ -384,70 +322,95 @@ exports.Toolbar = Toolbar;
|
|
|
384
322
|
Toolbar.createKernelStatusItem = createKernelStatusItem;
|
|
385
323
|
})(Toolbar = exports.Toolbar || (exports.Toolbar = {}));
|
|
386
324
|
/**
|
|
387
|
-
*
|
|
325
|
+
* React component for a toolbar button.
|
|
326
|
+
*
|
|
327
|
+
* @param props - The props for ToolbarButtonComponent.
|
|
388
328
|
*/
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
.replace(/\s{2,}/g, ' ')
|
|
402
|
-
.split(/\s/)
|
|
403
|
-
: null;
|
|
404
|
-
if (classes) {
|
|
405
|
-
classes.forEach(name => {
|
|
406
|
-
this.addClass(name);
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
this.node.title = options.tooltip || '';
|
|
410
|
-
}
|
|
329
|
+
function ToolbarButtonComponent(props) {
|
|
330
|
+
return (React.createElement("button", { className: props.className
|
|
331
|
+
? props.className + ' jp-ToolbarButtonComponent'
|
|
332
|
+
: 'jp-ToolbarButtonComponent', onClick: props.onClick, title: props.tooltip || props.iconLabel },
|
|
333
|
+
props.iconClassName && (React.createElement("span", { className: props.iconClassName + ' jp-ToolbarButtonComponent-icon' })),
|
|
334
|
+
props.label && (React.createElement("span", { className: "jp-ToolbarButtonComponent-label" }, props.label))));
|
|
335
|
+
}
|
|
336
|
+
exports.ToolbarButtonComponent = ToolbarButtonComponent;
|
|
337
|
+
/**
|
|
338
|
+
* Phosphor Widget version of ToolbarButtonComponent.
|
|
339
|
+
*/
|
|
340
|
+
class ToolbarButton extends vdom_1.ReactElementWidget {
|
|
411
341
|
/**
|
|
412
|
-
*
|
|
342
|
+
* Create a ToolbarButton.
|
|
413
343
|
*
|
|
414
|
-
* @param
|
|
415
|
-
*
|
|
416
|
-
* #### Notes
|
|
417
|
-
* This method implements the DOM `EventListener` interface and is
|
|
418
|
-
* called in response to events on the dock panel's node. It should
|
|
419
|
-
* not be called directly by user code.
|
|
344
|
+
* @param props - Props for ToolbarButtonComponent.
|
|
420
345
|
*/
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (event.button === 0) {
|
|
425
|
-
this._onClick();
|
|
426
|
-
}
|
|
427
|
-
break;
|
|
428
|
-
default:
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
346
|
+
constructor(props = {}) {
|
|
347
|
+
super(React.createElement(ToolbarButtonComponent, Object.assign({}, props)));
|
|
348
|
+
this.addClass('jp-ToolbarButton');
|
|
431
349
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
350
|
+
}
|
|
351
|
+
exports.ToolbarButton = ToolbarButton;
|
|
352
|
+
/**
|
|
353
|
+
* React component for a toolbar button that wraps a command.
|
|
354
|
+
*
|
|
355
|
+
* This wraps the ToolbarButtonComponent and watches the command registry
|
|
356
|
+
* for changes to the command.
|
|
357
|
+
*/
|
|
358
|
+
class CommandToolbarButtonComponent extends React.Component {
|
|
359
|
+
constructor(props) {
|
|
360
|
+
super(props);
|
|
361
|
+
props.commands.commandChanged.connect(this._onChange, this);
|
|
362
|
+
this._childProps = Private.propsFromCommand(this.props);
|
|
363
|
+
}
|
|
364
|
+
render() {
|
|
365
|
+
return React.createElement(ToolbarButtonComponent, Object.assign({}, this._childProps));
|
|
366
|
+
}
|
|
367
|
+
_onChange(sender, args) {
|
|
368
|
+
if (args.id !== this.props.id) {
|
|
369
|
+
return; // Not our command
|
|
370
|
+
}
|
|
371
|
+
if (args.type !== 'changed') {
|
|
372
|
+
return; // Not a change
|
|
373
|
+
}
|
|
374
|
+
this._childProps = Private.propsFromCommand(this.props);
|
|
375
|
+
this.forceUpdate();
|
|
437
376
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
377
|
+
}
|
|
378
|
+
exports.CommandToolbarButtonComponent = CommandToolbarButtonComponent;
|
|
379
|
+
/**
|
|
380
|
+
* Phosphor Widget version of ToolbarButtonComponent.
|
|
381
|
+
*/
|
|
382
|
+
class CommandToolbarButton extends vdom_1.ReactElementWidget {
|
|
383
|
+
constructor(props) {
|
|
384
|
+
super(React.createElement(CommandToolbarButtonComponent, Object.assign({}, props)));
|
|
385
|
+
this.addClass('jp-CommandToolbarButton');
|
|
443
386
|
}
|
|
444
387
|
}
|
|
445
|
-
exports.
|
|
388
|
+
exports.CommandToolbarButton = CommandToolbarButton;
|
|
446
389
|
/**
|
|
447
390
|
* A namespace for private data.
|
|
448
391
|
*/
|
|
449
392
|
var Private;
|
|
450
393
|
(function (Private) {
|
|
394
|
+
function propsFromCommand(options) {
|
|
395
|
+
let { commands, id } = options;
|
|
396
|
+
const iconClassName = commands.iconClass(id);
|
|
397
|
+
const iconLabel = commands.iconLabel(id);
|
|
398
|
+
const label = commands.label(id);
|
|
399
|
+
let className = commands.className(id);
|
|
400
|
+
// Add the boolean state classes.
|
|
401
|
+
if (commands.isToggled(id)) {
|
|
402
|
+
className += ' p-mod-toggled';
|
|
403
|
+
}
|
|
404
|
+
if (!commands.isVisible(id)) {
|
|
405
|
+
className += ' p-mod-hidden';
|
|
406
|
+
}
|
|
407
|
+
const tooltip = commands.caption(id) || label || iconLabel;
|
|
408
|
+
const onClick = () => {
|
|
409
|
+
commands.execute(id);
|
|
410
|
+
};
|
|
411
|
+
return { className, iconClassName, tooltip, onClick };
|
|
412
|
+
}
|
|
413
|
+
Private.propsFromCommand = propsFromCommand;
|
|
451
414
|
/**
|
|
452
415
|
* An attached property for the name of a toolbar item.
|
|
453
416
|
*/
|
|
@@ -455,13 +418,6 @@ var Private;
|
|
|
455
418
|
name: 'name',
|
|
456
419
|
create: () => ''
|
|
457
420
|
});
|
|
458
|
-
/**
|
|
459
|
-
* ToolbarButton tooltip formatter for a command.
|
|
460
|
-
*/
|
|
461
|
-
function commandTooltip(commands, id) {
|
|
462
|
-
return commands.caption(id);
|
|
463
|
-
}
|
|
464
|
-
Private.commandTooltip = commandTooltip;
|
|
465
421
|
/**
|
|
466
422
|
* A no-op function.
|
|
467
423
|
*/
|
|
@@ -469,38 +425,6 @@ var Private;
|
|
|
469
425
|
/* no-op */
|
|
470
426
|
}
|
|
471
427
|
Private.noOp = noOp;
|
|
472
|
-
/**
|
|
473
|
-
* Get the class names for a command based ToolBarButton
|
|
474
|
-
*/
|
|
475
|
-
function commandClassName(commands, id) {
|
|
476
|
-
let name = commands.className(id);
|
|
477
|
-
// Add the boolean state classes.
|
|
478
|
-
if (commands.isToggled(id)) {
|
|
479
|
-
name += ' p-mod-toggled';
|
|
480
|
-
}
|
|
481
|
-
if (!commands.isVisible(id)) {
|
|
482
|
-
name += ' p-mod-hidden';
|
|
483
|
-
}
|
|
484
|
-
return name;
|
|
485
|
-
}
|
|
486
|
-
Private.commandClassName = commandClassName;
|
|
487
|
-
/**
|
|
488
|
-
* Fill the node of a command based ToolBarButton.
|
|
489
|
-
*/
|
|
490
|
-
function setNodeContentFromCommand(node, commands, id) {
|
|
491
|
-
const iconClass = commands.iconClass(id);
|
|
492
|
-
const iconLabel = commands.iconLabel(id);
|
|
493
|
-
const label = commands.label(id);
|
|
494
|
-
node.innerHTML = '';
|
|
495
|
-
if (iconClass) {
|
|
496
|
-
node.className += ` ${iconClass}`;
|
|
497
|
-
node.setAttribute('title', iconLabel || label);
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
node.innerText = label;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
Private.setNodeContentFromCommand = setNodeContentFromCommand;
|
|
504
428
|
/**
|
|
505
429
|
* A spacer widget.
|
|
506
430
|
*/
|
|
@@ -515,28 +439,43 @@ var Private;
|
|
|
515
439
|
}
|
|
516
440
|
Private.Spacer = Spacer;
|
|
517
441
|
/**
|
|
518
|
-
*
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
constructor(
|
|
525
|
-
super(
|
|
442
|
+
* React component for a kernel name button.
|
|
443
|
+
*
|
|
444
|
+
* This wraps the ToolbarButtonComponent and watches the kernel
|
|
445
|
+
* session for changes.
|
|
446
|
+
*/
|
|
447
|
+
class KernelNameComponent extends React.Component {
|
|
448
|
+
constructor(props) {
|
|
449
|
+
super(props);
|
|
450
|
+
props.session.kernelChanged.connect(this._onKernelChanged, this);
|
|
451
|
+
this._childProps = {
|
|
526
452
|
className: TOOLBAR_KERNEL_NAME_CLASS,
|
|
527
453
|
onClick: () => {
|
|
528
|
-
session.selectKernel();
|
|
454
|
+
this.props.session.selectKernel();
|
|
529
455
|
},
|
|
530
|
-
tooltip: 'Switch kernel'
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
456
|
+
tooltip: 'Switch kernel',
|
|
457
|
+
label: props.session.kernelDisplayName
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
render() {
|
|
461
|
+
return React.createElement(ToolbarButtonComponent, Object.assign({}, this._childProps));
|
|
534
462
|
}
|
|
535
463
|
/**
|
|
536
464
|
* Update the text of the kernel name item.
|
|
537
465
|
*/
|
|
538
466
|
_onKernelChanged(session) {
|
|
539
|
-
this.
|
|
467
|
+
this._childProps.label = session.kernelDisplayName;
|
|
468
|
+
this.forceUpdate();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
Private.KernelNameComponent = KernelNameComponent;
|
|
472
|
+
/**
|
|
473
|
+
* Phosphor Widget version of ToolbarButtonComponent.
|
|
474
|
+
*/
|
|
475
|
+
class KernelName extends vdom_1.ReactElementWidget {
|
|
476
|
+
constructor(props) {
|
|
477
|
+
super(React.createElement(KernelNameComponent, Object.assign({}, props)));
|
|
478
|
+
this.addClass('jp-KernelName');
|
|
540
479
|
}
|
|
541
480
|
}
|
|
542
481
|
Private.KernelName = KernelName;
|
package/lib/toolbar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../../../../apputils/src/toolbar.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;AAE3D,mDAAiE;AAIjE,mDAA2D;AAE3D,qDAAwD;AAExD,+CAAwD;AAIxD,uCAAoC;AAEpC;;GAEG;AACH,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAE7C;;GAEG;AACH,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C;;GAEG;AACH,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAE9D;;GAEG;AACH,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,mBAAoB,SAAQ,qBAAW;IAAvC;;QA6GU,WAAM,GAAG,KAAK,CAAC;IACzB,CAAC;IA7GC;;;;;OAKG;IACO,YAAY,CAAC,GAAY;QACjC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,MAAO,CAAC,UAAU,EAAE;YAC3B,wEAAwE;YACxE,oBAAoB;YACpB,IAAI,gBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,E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AAiB,CAAC;QACpD,CAAC;KACF;IAtBY,kBAAU,aAsBtB,CAAA;IAED;;OAEG;IACH,kBAA0B,SAAQ,gBAAM;QACtC;;WAEG;QACH,YAAY,OAAuB;YACjC,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAAC;YAC3C,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;QAED;;WAEG;QACK,gBAAgB,CAAC,OAAuB;YAC9C,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,OAAO;aACR;YACD,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;YACxD,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;YACxD,IAAI,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAC1B,CAAC;KACF;IAxBY,oBAAY,eAwBxB,CAAA;AACH,CAAC,EArIS,OAAO,KAAP,OAAO,QAqIhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport { IIterator, find, map, some } from '@phosphor/algorithm';\n\nimport { CommandRegistry } from '@phosphor/commands';\n\nimport { Message, MessageLoop } from '@phosphor/messaging';\n\nimport { AttachedProperty } from '@phosphor/properties';\n\nimport { PanelLayout, Widget } from '@phosphor/widgets';\n\nimport { IClientSession } from './clientsession';\n\nimport { Styling } from './styling';\n\n/**\n * The class name added to toolbars.\n */\nconst TOOLBAR_CLASS = 'jp-Toolbar';\n\n/**\n * The class name added to toolbar items.\n */\nconst TOOLBAR_ITEM_CLASS = 'jp-Toolbar-item';\n\n/**\n * The class name added to toolbar buttons.\n */\nconst TOOLBAR_BUTTON_CLASS = 'jp-Toolbar-button';\n\n/**\n * The class name added to toolbar interrupt button.\n */\nconst TOOLBAR_INTERRUPT_CLASS = 'jp-StopIcon';\n\n/**\n * The class name added to toolbar restart button.\n */\nconst TOOLBAR_RESTART_CLASS = 'jp-RefreshIcon';\n\n/**\n * The class name added to toolbar kernel name text.\n */\nconst TOOLBAR_KERNEL_NAME_CLASS = 'jp-Toolbar-kernelName';\n\n/**\n * The class name added to toolbar spacer.\n */\nconst TOOLBAR_SPACER_CLASS = 'jp-Toolbar-spacer';\n\n/**\n * The class name added to toolbar kernel status icon.\n */\nconst TOOLBAR_KERNEL_STATUS_CLASS = 'jp-Toolbar-kernelStatus';\n\n/**\n * The class name added to a busy kernel indicator.\n */\nconst TOOLBAR_BUSY_CLASS = 'jp-FilledCircleIcon';\n\nconst TOOLBAR_IDLE_CLASS = 'jp-CircleIcon';\n\n/**\n * A layout for toolbars.\n *\n * #### Notes\n * This layout automatically collapses its height if there are no visible\n * toolbar widgets, and expands to the standard toolbar height if there are\n * visible toolbar widgets.\n */\nclass ToolbarLayout extends PanelLayout {\n /**\n * A message handler invoked on a `'fit-request'` message.\n *\n * If any child widget is visible, expand the toolbar height to the normal\n * toolbar height.\n */\n protected onFitRequest(msg: Message): void {\n super.onFitRequest(msg);\n if (this.parent!.isAttached) {\n // If there are any widgets not explicitly hidden, expand the toolbar to\n // accommodate them.\n if (some(this.widgets, w => !w.isHidden)) {\n this.parent!.node.style.minHeight = 'var(--jp-private-toolbar-height)';\n } else {\n this.parent!.node.style.minHeight = '';\n }\n }\n\n // Set the dirty flag to ensure only a single update occurs.\n this._dirty = true;\n\n // Notify the ancestor that it should fit immediately. This may\n // cause a resize of the parent, fulfilling the required update.\n if (this.parent!.parent) {\n MessageLoop.sendMessage(this.parent!.parent!, Widget.Msg.FitRequest);\n }\n\n // If the dirty flag is still set, the parent was not resized.\n // Trigger the required update on the parent widget immediately.\n if (this._dirty) {\n MessageLoop.sendMessage(this.parent!, Widget.Msg.UpdateRequest);\n }\n }\n\n /**\n * A message handler invoked on an `'update-request'` message.\n */\n protected onUpdateRequest(msg: Message): void {\n super.onUpdateRequest(msg);\n if (this.parent!.isVisible) {\n this._dirty = false;\n }\n }\n\n /**\n * A message handler invoked on a `'child-shown'` message.\n */\n protected onChildShown(msg: Widget.ChildMessage): void {\n super.onChildShown(msg);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * A message handler invoked on a `'child-hidden'` message.\n */\n protected onChildHidden(msg: Widget.ChildMessage): void {\n super.onChildHidden(msg);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * A message handler invoked on a `'before-attach'` message.\n */\n protected onBeforeAttach(msg: Message): void {\n super.onBeforeAttach(msg);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * Attach a widget to the parent's DOM node.\n *\n * @param index - The current index of the widget in the layout.\n *\n * @param widget - The widget to attach to the parent.\n *\n * #### Notes\n * This is a reimplementation of the superclass method.\n */\n protected attachWidget(index: number, widget: Widget): void {\n super.attachWidget(index, widget);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * Detach a widget from the parent's DOM node.\n *\n * @param index - The previous index of the widget in the layout.\n *\n * @param widget - The widget to detach from the parent.\n *\n * #### Notes\n * This is a reimplementation of the superclass method.\n */\n protected detachWidget(index: number, widget: Widget): void {\n super.detachWidget(index, widget);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n private _dirty = false;\n}\n\n/**\n * A class which provides a toolbar widget.\n */\nexport class Toolbar<T extends Widget = Widget> extends Widget {\n /**\n * Construct a new toolbar widget.\n */\n constructor() {\n super();\n this.addClass(TOOLBAR_CLASS);\n this.layout = new ToolbarLayout();\n }\n\n /**\n * Get an iterator over the ordered toolbar item names.\n *\n * @returns An iterator over the toolbar item names.\n */\n names(): IIterator<string> {\n let layout = this.layout as ToolbarLayout;\n return map(layout.widgets, widget => {\n return Private.nameProperty.get(widget);\n });\n }\n\n /**\n * Add an item to the end of the toolbar.\n *\n * @param name - The name of the widget to add to the toolbar.\n *\n * @param widget - The widget to add to the toolbar.\n *\n * @param index - The optional name of the item to insert after.\n *\n * @returns Whether the item was added to toolbar. Returns false if\n * an item of the same name is already in the toolbar.\n *\n * #### Notes\n * The item can be removed from the toolbar by setting its parent to `null`.\n */\n addItem(name: string, widget: T): boolean {\n let layout = this.layout as ToolbarLayout;\n return this.insertItem(layout.widgets.length, name, widget);\n }\n\n /**\n * Insert an item into the toolbar at the specified index.\n *\n * @param index - The index at which to insert the item.\n *\n * @param name - The name of the item.\n *\n * @param widget - The widget to add.\n *\n * @returns Whether the item was added to the toolbar. Returns false if\n * an item of the same name is already in the toolbar.\n *\n * #### Notes\n * The index will be clamped to the bounds of the items.\n * The item can be removed from the toolbar by setting its parent to `null`.\n */\n insertItem(index: number, name: string, widget: T): boolean {\n let existing = find(this.names(), value => value === name);\n if (existing) {\n return false;\n }\n widget.addClass(TOOLBAR_ITEM_CLASS);\n let layout = this.layout as ToolbarLayout;\n layout.insertWidget(index, widget);\n Private.nameProperty.set(widget, name);\n return true;\n }\n\n /**\n * Handle the DOM events for the widget.\n *\n * @param event - The DOM event sent to the widget.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the dock panel's node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n switch (event.type) {\n case 'click':\n if (!this.node.contains(document.activeElement) && this.parent) {\n this.parent.activate();\n }\n break;\n default:\n break;\n }\n }\n\n /**\n * Handle `after-attach` messages for the widget.\n */\n protected onAfterAttach(msg: Message): void {\n this.node.addEventListener('click', this);\n }\n\n /**\n * Handle `before-detach` messages for the widget.\n */\n protected onBeforeDetach(msg: Message): void {\n this.node.removeEventListener('click', this);\n }\n}\n\n/**\n * The namespace for Toolbar class statics.\n */\nexport namespace Toolbar {\n /**\n * Create a toolbar item for a command or `null` if the command does not exist\n * in the registry.\n *\n * Notes:\n * If the command has an icon label it will be added to the button.\n * If there is no icon label, and no icon class, the main label will\n * be added.\n */\n export function createFromCommand(\n commands: CommandRegistry,\n id: string\n ): ToolbarButton | null {\n if (!commands.hasCommand(id)) {\n return null;\n }\n\n const button = new ToolbarButton({\n onClick: () => {\n commands.execute(id);\n button.node.blur();\n },\n className: Private.commandClassName(commands, id),\n tooltip: Private.commandTooltip(commands, id)\n });\n let oldClasses = Private.commandClassName(commands, id).split(/\\s/);\n\n (button.node as HTMLButtonElement).disabled = !commands.isEnabled(id);\n Private.setNodeContentFromCommand(button.node, commands, id);\n\n // Ensure that we pick up relevant changes to the command:\n function onChange(\n sender: CommandRegistry,\n args: CommandRegistry.ICommandChangedArgs\n ) {\n if (args.id !== id) {\n return; // Not our command\n }\n\n if (args.type === 'removed') {\n // Dispose of button\n button.dispose();\n return;\n }\n\n if (args.type !== 'changed') {\n return;\n }\n\n // Update all fields (onClick is already indirected)\n const newClasses = Private.commandClassName(sender, id).split(/\\s/);\n\n for (let cls of oldClasses) {\n if (cls && newClasses.indexOf(cls) === -1) {\n button.removeClass(cls);\n }\n }\n for (let cls of newClasses) {\n if (cls && oldClasses.indexOf(cls) === -1) {\n button.addClass(cls);\n }\n }\n oldClasses = newClasses;\n button.node.title = Private.commandTooltip(sender, id);\n Private.setNodeContentFromCommand(button.node, sender, id);\n (button.node as HTMLButtonElement).disabled = !sender.isEnabled(id);\n }\n commands.commandChanged.connect(onChange, button);\n\n return button;\n }\n\n /**\n * Create an interrupt toolbar item.\n */\n export function createInterruptButton(\n session: IClientSession\n ): ToolbarButton {\n return new ToolbarButton({\n className: TOOLBAR_INTERRUPT_CLASS,\n onClick: () => {\n if (session.kernel) {\n session.kernel.interrupt();\n }\n },\n tooltip: 'Interrupt the kernel'\n });\n }\n\n /**\n * Create a restart toolbar item.\n */\n export function createRestartButton(session: IClientSession): ToolbarButton {\n return new ToolbarButton({\n className: TOOLBAR_RESTART_CLASS,\n onClick: () => {\n session.restart();\n },\n tooltip: 'Restart the kernel'\n });\n }\n\n /**\n * Create a toolbar spacer item.\n *\n * #### Notes\n * It is a flex spacer that separates the left toolbar items\n * from the right toolbar items.\n */\n export function createSpacerItem(): Widget {\n return new Private.Spacer();\n }\n\n /**\n * Create a kernel name indicator item.\n *\n * #### Notes\n * It will display the `'display_name`' of the current kernel,\n * or `'No Kernel!'` if there is no kernel.\n * It can handle a change in context or kernel.\n */\n export function createKernelNameItem(session: IClientSession): ToolbarButton {\n return new Private.KernelName(session);\n }\n\n /**\n * Create a kernel status indicator item.\n *\n * #### Notes\n * It show display a busy status if the kernel status is\n * not idle.\n * It will show the current status in the node title.\n * It can handle a change to the context or the kernel.\n */\n export function createKernelStatusItem(session: IClientSession): Widget {\n return new Private.KernelStatus(session);\n }\n}\n\n/**\n * A widget which acts as a button in a toolbar.\n */\nexport class ToolbarButton extends Widget {\n /**\n * Construct a new toolbar button.\n */\n constructor(options: ToolbarButton.IOptions = {}) {\n super({ node: document.createElement('button') });\n Styling.styleNodeByTag(this.node, 'button');\n this.addClass(TOOLBAR_BUTTON_CLASS);\n this._onClick = options.onClick || Private.noOp;\n\n const classes = options.className\n ? options.className\n .trim()\n .replace(/\\s{2,}/g, ' ')\n .split(/\\s/)\n : null;\n\n if (classes) {\n classes.forEach(name => {\n this.addClass(name);\n });\n }\n\n this.node.title = options.tooltip || '';\n }\n\n /**\n * Handle the DOM events for the widget.\n *\n * @param event - The DOM event sent to the widget.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the dock panel's node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n switch (event.type) {\n case 'click':\n if ((event as MouseEvent).button === 0) {\n this._onClick();\n }\n break;\n default:\n break;\n }\n }\n\n /**\n * Handle `after-attach` messages for the widget.\n */\n protected onAfterAttach(msg: Message): void {\n this.node.addEventListener('click', this);\n }\n\n /**\n * Handle `before-detach` messages for the widget.\n */\n protected onBeforeDetach(msg: Message): void {\n this.node.removeEventListener('click', this);\n }\n\n private _onClick: () => void;\n}\n\n/**\n * A namespace for `ToolbarButton` statics.\n */\nexport namespace ToolbarButton {\n /**\n * The options used to construct a toolbar button.\n */\n export interface IOptions {\n /**\n * The callback for a click event.\n */\n onClick?: () => void;\n\n /**\n * The class name added to the button.\n */\n className?: string;\n\n /**\n * The tooltip added to the button node.\n */\n tooltip?: string;\n }\n}\n\n/**\n * A namespace for private data.\n */\nnamespace Private {\n /**\n * An attached property for the name of a toolbar item.\n */\n export const nameProperty = new AttachedProperty<Widget, string>({\n name: 'name',\n create: () => ''\n });\n\n /**\n * ToolbarButton tooltip formatter for a command.\n */\n export function commandTooltip(\n commands: CommandRegistry,\n id: string\n ): string {\n return commands.caption(id);\n }\n\n /**\n * A no-op function.\n */\n export function noOp() {\n /* no-op */\n }\n\n /**\n * Get the class names for a command based ToolBarButton\n */\n export function commandClassName(\n commands: CommandRegistry,\n id: string\n ): string {\n let name = commands.className(id);\n // Add the boolean state classes.\n if (commands.isToggled(id)) {\n name += ' p-mod-toggled';\n }\n if (!commands.isVisible(id)) {\n name += ' p-mod-hidden';\n }\n return name;\n }\n\n /**\n * Fill the node of a command based ToolBarButton.\n */\n export function setNodeContentFromCommand(\n node: HTMLElement,\n commands: CommandRegistry,\n id: string\n ): void {\n const iconClass = commands.iconClass(id);\n const iconLabel = commands.iconLabel(id);\n const label = commands.label(id);\n\n node.innerHTML = '';\n if (iconClass) {\n node.className += ` ${iconClass}`;\n node.setAttribute('title', iconLabel || label);\n } else {\n node.innerText = label;\n }\n }\n\n /**\n * A spacer widget.\n */\n export class Spacer extends Widget {\n /**\n * Construct a new spacer widget.\n */\n constructor() {\n super();\n this.addClass(TOOLBAR_SPACER_CLASS);\n }\n }\n\n /**\n * A kernel name widget.\n */\n export class KernelName extends ToolbarButton {\n /**\n * Construct a new kernel name widget.\n */\n constructor(session: IClientSession) {\n super({\n className: TOOLBAR_KERNEL_NAME_CLASS,\n onClick: () => {\n session.selectKernel();\n },\n tooltip: 'Switch kernel'\n });\n this._onKernelChanged(session);\n session.kernelChanged.connect(this._onKernelChanged, this);\n }\n\n /**\n * Update the text of the kernel name item.\n */\n private _onKernelChanged(session: IClientSession): void {\n this.node.textContent = session.kernelDisplayName;\n }\n }\n\n /**\n * A toolbar item that displays kernel status.\n */\n export class KernelStatus extends Widget {\n /**\n * Construct a new kernel status widget.\n */\n constructor(session: IClientSession) {\n super();\n this.addClass(TOOLBAR_KERNEL_STATUS_CLASS);\n this._onStatusChanged(session);\n session.statusChanged.connect(this._onStatusChanged, this);\n }\n\n /**\n * Handle a status on a kernel.\n */\n private _onStatusChanged(session: IClientSession) {\n if (this.isDisposed) {\n return;\n }\n let status = session.status;\n this.toggleClass(TOOLBAR_IDLE_CLASS, status === 'idle');\n this.toggleClass(TOOLBAR_BUSY_CLASS, status !== 'idle');\n let title = 'Kernel ' + status[0].toUpperCase() + status.slice(1);\n this.node.title = title;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../../../../apputils/src/toolbar.tsx"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;AAE3D,iCAA4C;AAE5C,mDAAiE;AAIjE,mDAA2D;AAE3D,qDAAwD;AAExD,+CAAwD;AAIxD,6CAA+B;AAE/B;;GAEG;AACH,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAE7C;;GAEG;AACH,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAE9D;;GAEG;AACH,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD,MAAM,kBA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B,CAAC;KAGF;IA7BY,2BAAmB,sBA6B/B,CAAA;IAED;;OAEG;IACH,gBAAwB,SAAQ,yBAAkB;QAChD,YAAY,KAAiC;YAC3C,KAAK,CAAC,oBAAC,mBAAmB,oBAAK,KAAK,EAAI,CAAC,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjC,CAAC;KACF;IALY,kBAAU,aAKtB,CAAA;IAED;;OAEG;IACH,kBAA0B,SAAQ,gBAAM;QACtC;;WAEG;QACH,YAAY,OAAuB;YACjC,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAAC;YAC3C,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;QAED;;WAEG;QACK,gBAAgB,CAAC,OAAuB;YAC9C,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,OAAO;aACR;YACD,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;YACxD,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;YACxD,IAAI,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAC1B,CAAC;KACF;IAxBY,oBAAY,eAwBxB,CAAA;AACH,CAAC,EA1IS,OAAO,KAAP,OAAO,QA0IhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport { ReactElementWidget } from './vdom';\n\nimport { IIterator, find, map, some } from '@phosphor/algorithm';\n\nimport { CommandRegistry } from '@phosphor/commands';\n\nimport { Message, MessageLoop } from '@phosphor/messaging';\n\nimport { AttachedProperty } from '@phosphor/properties';\n\nimport { PanelLayout, Widget } from '@phosphor/widgets';\n\nimport { IClientSession } from './clientsession';\n\nimport * as React from 'react';\n\n/**\n * The class name added to toolbars.\n */\nconst TOOLBAR_CLASS = 'jp-Toolbar';\n\n/**\n * The class name added to toolbar items.\n */\nconst TOOLBAR_ITEM_CLASS = 'jp-Toolbar-item';\n\n/**\n * The class name added to toolbar kernel name text.\n */\nconst TOOLBAR_KERNEL_NAME_CLASS = 'jp-Toolbar-kernelName';\n\n/**\n * The class name added to toolbar spacer.\n */\nconst TOOLBAR_SPACER_CLASS = 'jp-Toolbar-spacer';\n\n/**\n * The class name added to toolbar kernel status icon.\n */\nconst TOOLBAR_KERNEL_STATUS_CLASS = 'jp-Toolbar-kernelStatus';\n\n/**\n * The class name added to a busy kernel indicator.\n */\nconst TOOLBAR_BUSY_CLASS = 'jp-FilledCircleIcon';\n\nconst TOOLBAR_IDLE_CLASS = 'jp-CircleIcon';\n\n/**\n * A layout for toolbars.\n *\n * #### Notes\n * This layout automatically collapses its height if there are no visible\n * toolbar widgets, and expands to the standard toolbar height if there are\n * visible toolbar widgets.\n */\nclass ToolbarLayout extends PanelLayout {\n /**\n * A message handler invoked on a `'fit-request'` message.\n *\n * If any child widget is visible, expand the toolbar height to the normal\n * toolbar height.\n */\n protected onFitRequest(msg: Message): void {\n super.onFitRequest(msg);\n if (this.parent!.isAttached) {\n // If there are any widgets not explicitly hidden, expand the toolbar to\n // accommodate them.\n if (some(this.widgets, w => !w.isHidden)) {\n this.parent!.node.style.minHeight = 'var(--jp-private-toolbar-height)';\n } else {\n this.parent!.node.style.minHeight = '';\n }\n }\n\n // Set the dirty flag to ensure only a single update occurs.\n this._dirty = true;\n\n // Notify the ancestor that it should fit immediately. This may\n // cause a resize of the parent, fulfilling the required update.\n if (this.parent!.parent) {\n MessageLoop.sendMessage(this.parent!.parent!, Widget.Msg.FitRequest);\n }\n\n // If the dirty flag is still set, the parent was not resized.\n // Trigger the required update on the parent widget immediately.\n if (this._dirty) {\n MessageLoop.sendMessage(this.parent!, Widget.Msg.UpdateRequest);\n }\n }\n\n /**\n * A message handler invoked on an `'update-request'` message.\n */\n protected onUpdateRequest(msg: Message): void {\n super.onUpdateRequest(msg);\n if (this.parent!.isVisible) {\n this._dirty = false;\n }\n }\n\n /**\n * A message handler invoked on a `'child-shown'` message.\n */\n protected onChildShown(msg: Widget.ChildMessage): void {\n super.onChildShown(msg);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * A message handler invoked on a `'child-hidden'` message.\n */\n protected onChildHidden(msg: Widget.ChildMessage): void {\n super.onChildHidden(msg);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * A message handler invoked on a `'before-attach'` message.\n */\n protected onBeforeAttach(msg: Message): void {\n super.onBeforeAttach(msg);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * Attach a widget to the parent's DOM node.\n *\n * @param index - The current index of the widget in the layout.\n *\n * @param widget - The widget to attach to the parent.\n *\n * #### Notes\n * This is a reimplementation of the superclass method.\n */\n protected attachWidget(index: number, widget: Widget): void {\n super.attachWidget(index, widget);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n /**\n * Detach a widget from the parent's DOM node.\n *\n * @param index - The previous index of the widget in the layout.\n *\n * @param widget - The widget to detach from the parent.\n *\n * #### Notes\n * This is a reimplementation of the superclass method.\n */\n protected detachWidget(index: number, widget: Widget): void {\n super.detachWidget(index, widget);\n\n // Post a fit request for the parent widget.\n this.parent!.fit();\n }\n\n private _dirty = false;\n}\n\n/**\n * A class which provides a toolbar widget.\n */\nexport class Toolbar<T extends Widget = Widget> extends Widget {\n /**\n * Construct a new toolbar widget.\n */\n constructor() {\n super();\n this.addClass(TOOLBAR_CLASS);\n this.layout = new ToolbarLayout();\n }\n\n /**\n * Get an iterator over the ordered toolbar item names.\n *\n * @returns An iterator over the toolbar item names.\n */\n names(): IIterator<string> {\n let layout = this.layout as ToolbarLayout;\n return map(layout.widgets, widget => {\n return Private.nameProperty.get(widget);\n });\n }\n\n /**\n * Add an item to the end of the toolbar.\n *\n * @param name - The name of the widget to add to the toolbar.\n *\n * @param widget - The widget to add to the toolbar.\n *\n * @param index - The optional name of the item to insert after.\n *\n * @returns Whether the item was added to toolbar. Returns false if\n * an item of the same name is already in the toolbar.\n *\n * #### Notes\n * The item can be removed from the toolbar by setting its parent to `null`.\n */\n addItem(name: string, widget: T): boolean {\n let layout = this.layout as ToolbarLayout;\n return this.insertItem(layout.widgets.length, name, widget);\n }\n\n /**\n * Insert an item into the toolbar at the specified index.\n *\n * @param index - The index at which to insert the item.\n *\n * @param name - The name of the item.\n *\n * @param widget - The widget to add.\n *\n * @returns Whether the item was added to the toolbar. Returns false if\n * an item of the same name is already in the toolbar.\n *\n * #### Notes\n * The index will be clamped to the bounds of the items.\n * The item can be removed from the toolbar by setting its parent to `null`.\n */\n insertItem(index: number, name: string, widget: T): boolean {\n let existing = find(this.names(), value => value === name);\n if (existing) {\n return false;\n }\n widget.addClass(TOOLBAR_ITEM_CLASS);\n let layout = this.layout as ToolbarLayout;\n layout.insertWidget(index, widget);\n Private.nameProperty.set(widget, name);\n return true;\n }\n\n /**\n * Handle the DOM events for the widget.\n *\n * @param event - The DOM event sent to the widget.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the dock panel's node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n switch (event.type) {\n case 'click':\n if (!this.node.contains(document.activeElement) && this.parent) {\n this.parent.activate();\n }\n break;\n default:\n break;\n }\n }\n\n /**\n * Handle `after-attach` messages for the widget.\n */\n protected onAfterAttach(msg: Message): void {\n this.node.addEventListener('click', this);\n }\n\n /**\n * Handle `before-detach` messages for the widget.\n */\n protected onBeforeDetach(msg: Message): void {\n this.node.removeEventListener('click', this);\n }\n}\n\n/**\n * The namespace for Toolbar class statics.\n */\nexport namespace Toolbar {\n /**\n * Create an interrupt toolbar item.\n */\n export function createInterruptButton(\n session: IClientSession\n ): ToolbarButton {\n return new ToolbarButton({\n iconClassName: 'jp-StopIcon jp-Icon jp-Icon-16',\n onClick: () => {\n if (session.kernel) {\n session.kernel.interrupt();\n }\n },\n tooltip: 'Interrupt the kernel'\n });\n }\n\n /**\n * Create a restart toolbar item.\n */\n export function createRestartButton(session: IClientSession): ToolbarButton {\n return new ToolbarButton({\n iconClassName: 'jp-RefreshIcon jp-Icon jp-Icon-16',\n onClick: () => {\n session.restart();\n },\n tooltip: 'Restart the kernel'\n });\n }\n\n /**\n * Create a toolbar spacer item.\n *\n * #### Notes\n * It is a flex spacer that separates the left toolbar items\n * from the right toolbar items.\n */\n export function createSpacerItem(): Widget {\n return new Private.Spacer();\n }\n\n /**\n * Create a kernel name indicator item.\n *\n * #### Notes\n * It will display the `'display_name`' of the current kernel,\n * or `'No Kernel!'` if there is no kernel.\n * It can handle a change in context or kernel.\n */\n export function createKernelNameItem(session: IClientSession): ToolbarButton {\n return new Private.KernelName({ session });\n }\n\n /**\n * Create a kernel status indicator item.\n *\n * #### Notes\n * It show display a busy status if the kernel status is\n * not idle.\n * It will show the current status in the node title.\n * It can handle a change to the context or the kernel.\n */\n export function createKernelStatusItem(session: IClientSession): Widget {\n return new Private.KernelStatus(session);\n }\n}\n\n/**\n * Namespace for ToolbarButtonComponent.\n */\nexport namespace ToolbarButtonComponent {\n /**\n * Interface for ToolbarButttonComponent props.\n */\n export interface IProps {\n className?: string;\n label?: string;\n iconClassName?: string;\n iconLabel?: string;\n tooltip?: string;\n onClick?: () => void;\n }\n}\n\n/**\n * React component for a toolbar button.\n *\n * @param props - The props for ToolbarButtonComponent.\n */\nexport function ToolbarButtonComponent(props: ToolbarButtonComponent.IProps) {\n return (\n <button\n className={\n props.className\n ? props.className + ' jp-ToolbarButtonComponent'\n : 'jp-ToolbarButtonComponent'\n }\n onClick={props.onClick}\n title={props.tooltip || props.iconLabel}\n >\n {props.iconClassName && (\n <span\n className={props.iconClassName + ' jp-ToolbarButtonComponent-icon'}\n />\n )}\n {props.label && (\n <span className=\"jp-ToolbarButtonComponent-label\">{props.label}</span>\n )}\n </button>\n );\n}\n\n/**\n * Phosphor Widget version of ToolbarButtonComponent.\n */\nexport class ToolbarButton extends ReactElementWidget {\n /**\n * Create a ToolbarButton.\n *\n * @param props - Props for ToolbarButtonComponent.\n */\n constructor(props: ToolbarButtonComponent.IProps = {}) {\n super(<ToolbarButtonComponent {...props} />);\n this.addClass('jp-ToolbarButton');\n }\n}\n\n/**\n * Namespace for CommandToolbarButtonComponent.\n */\nexport namespace CommandToolbarButtonComponent {\n /**\n * Interface for CommandToolbarButtonComponent props.\n */\n export interface IProps {\n commands: CommandRegistry;\n id: string;\n }\n}\n\n/**\n * React component for a toolbar button that wraps a command.\n *\n * This wraps the ToolbarButtonComponent and watches the command registry\n * for changes to the command.\n */\nexport class CommandToolbarButtonComponent extends React.Component<\n CommandToolbarButtonComponent.IProps\n> {\n constructor(props: CommandToolbarButtonComponent.IProps) {\n super(props);\n props.commands.commandChanged.connect(this._onChange, this);\n this._childProps = Private.propsFromCommand(this.props);\n }\n\n public render() {\n return <ToolbarButtonComponent {...this._childProps} />;\n }\n\n private _onChange(\n sender: CommandRegistry,\n args: CommandRegistry.ICommandChangedArgs\n ) {\n if (args.id !== this.props.id) {\n return; // Not our command\n }\n\n if (args.type !== 'changed') {\n return; // Not a change\n }\n\n this._childProps = Private.propsFromCommand(this.props);\n this.forceUpdate();\n }\n\n private _childProps: ToolbarButtonComponent.IProps;\n}\n\n/**\n * Phosphor Widget version of ToolbarButtonComponent.\n */\nexport class CommandToolbarButton extends ReactElementWidget {\n constructor(props: CommandToolbarButtonComponent.IProps) {\n super(<CommandToolbarButtonComponent {...props} />);\n this.addClass('jp-CommandToolbarButton');\n }\n}\n\n/**\n * A namespace for private data.\n */\nnamespace Private {\n export function propsFromCommand(\n options: CommandToolbarButtonComponent.IProps\n ): ToolbarButtonComponent.IProps {\n let { commands, id } = options;\n const iconClassName = commands.iconClass(id);\n const iconLabel = commands.iconLabel(id);\n const label = commands.label(id);\n let className = commands.className(id);\n // Add the boolean state classes.\n if (commands.isToggled(id)) {\n className += ' p-mod-toggled';\n }\n if (!commands.isVisible(id)) {\n className += ' p-mod-hidden';\n }\n const tooltip = commands.caption(id) || label || iconLabel;\n const onClick = () => {\n commands.execute(id);\n };\n return { className, iconClassName, tooltip, onClick };\n }\n\n /**\n * An attached property for the name of a toolbar item.\n */\n export const nameProperty = new AttachedProperty<Widget, string>({\n name: 'name',\n create: () => ''\n });\n\n /**\n * A no-op function.\n */\n export function noOp() {\n /* no-op */\n }\n\n /**\n * A spacer widget.\n */\n export class Spacer extends Widget {\n /**\n * Construct a new spacer widget.\n */\n constructor() {\n super();\n this.addClass(TOOLBAR_SPACER_CLASS);\n }\n }\n\n /**\n * Namespace for KernelNameComponent.\n */\n export namespace KernelNameComponent {\n /**\n * Interface for KernelNameComponent props.\n */\n export interface IProps {\n session: IClientSession;\n }\n }\n\n /**\n * React component for a kernel name button.\n *\n * This wraps the ToolbarButtonComponent and watches the kernel\n * session for changes.\n */\n export class KernelNameComponent extends React.Component<\n KernelNameComponent.IProps\n > {\n constructor(props: KernelNameComponent.IProps) {\n super(props);\n props.session.kernelChanged.connect(this._onKernelChanged, this);\n this._childProps = {\n className: TOOLBAR_KERNEL_NAME_CLASS,\n onClick: () => {\n this.props.session.selectKernel();\n },\n tooltip: 'Switch kernel',\n label: props.session.kernelDisplayName\n };\n }\n\n public render() {\n return <ToolbarButtonComponent {...this._childProps} />;\n }\n\n /**\n * Update the text of the kernel name item.\n */\n private _onKernelChanged(session: IClientSession): void {\n this._childProps.label = session.kernelDisplayName;\n this.forceUpdate();\n }\n\n private _childProps: ToolbarButtonComponent.IProps;\n }\n\n /**\n * Phosphor Widget version of ToolbarButtonComponent.\n */\n export class KernelName extends ReactElementWidget {\n constructor(props: KernelNameComponent.IProps) {\n super(<KernelNameComponent {...props} />);\n this.addClass('jp-KernelName');\n }\n }\n\n /**\n * A toolbar item that displays kernel status.\n */\n export class KernelStatus extends Widget {\n /**\n * Construct a new kernel status widget.\n */\n constructor(session: IClientSession) {\n super();\n this.addClass(TOOLBAR_KERNEL_STATUS_CLASS);\n this._onStatusChanged(session);\n session.statusChanged.connect(this._onStatusChanged, this);\n }\n\n /**\n * Handle a status on a kernel.\n */\n private _onStatusChanged(session: IClientSession) {\n if (this.isDisposed) {\n return;\n }\n let status = session.status;\n this.toggleClass(TOOLBAR_IDLE_CLASS, status === 'idle');\n this.toggleClass(TOOLBAR_BUSY_CLASS, status !== 'idle');\n let title = 'Kernel ' + status[0].toUpperCase() + status.slice(1);\n this.node.title = title;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/apputils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "JupyterLab - Application Utilities",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"watch": "tsc -w --listEmittedFiles"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@jupyterlab/coreutils": "^2.
|
|
34
|
-
"@jupyterlab/services": "^3.
|
|
33
|
+
"@jupyterlab/coreutils": "^2.1.4",
|
|
34
|
+
"@jupyterlab/services": "^3.1.4",
|
|
35
35
|
"@phosphor/algorithm": "^1.1.2",
|
|
36
36
|
"@phosphor/commands": "^1.5.0",
|
|
37
37
|
"@phosphor/coreutils": "^1.3.0",
|
package/style/commandpalette.css
CHANGED
|
@@ -30,9 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
.p-CommandPalette-search {
|
|
32
32
|
padding: 8px;
|
|
33
|
-
background-color: var(--jp-layout-
|
|
34
|
-
border-bottom: 1px solid var(--jp-border-color1);
|
|
35
|
-
box-shadow: var(--jp-toolbar-box-shadow);
|
|
33
|
+
background-color: var(--jp-layout-color1);
|
|
36
34
|
z-index: 2;
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -96,7 +94,7 @@
|
|
|
96
94
|
|----------------------------------------------------------------------------*/
|
|
97
95
|
|
|
98
96
|
.p-CommandPalette-header {
|
|
99
|
-
padding:
|
|
97
|
+
padding: 8px 0 8px 22px;
|
|
100
98
|
color: var(--jp-ui-font-color1);
|
|
101
99
|
font-size: var(--jp-ui-font-size0);
|
|
102
100
|
font-weight: 600;
|
package/style/styling.css
CHANGED
|
@@ -41,11 +41,6 @@ input.jp-mod-styled:focus {
|
|
|
41
41
|
box-shadow: inset 0 0 4px var(--md-blue-300);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
button.jp-mod-styled:focus {
|
|
45
|
-
box-shadow: inset 0 0 0 1px #ffffff;
|
|
46
|
-
border: rgba(0, 0, 0, 0) solid 1px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
44
|
.jp-select-wrapper {
|
|
50
45
|
display: flex;
|
|
51
46
|
flex-direction: column;
|
package/style/toolbar.css
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
|----------------------------------------------------------------------------*/
|
|
6
6
|
|
|
7
7
|
:root {
|
|
8
|
-
--jp-private-toolbar-height:
|
|
8
|
+
--jp-private-toolbar-height: calc(
|
|
9
|
+
28px + var(--jp-border-width)
|
|
10
|
+
); /* leave 28px for content */
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
.jp-Toolbar {
|
|
@@ -21,70 +23,86 @@
|
|
|
21
23
|
z-index: 1;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
font-size: var(--jp-ui-font-size1);
|
|
30
|
-
line-height: var(--jp-private-toolbar-height);
|
|
31
|
-
height: 100%;
|
|
26
|
+
/* Toolbar items */
|
|
27
|
+
|
|
28
|
+
.jp-Toolbar > .jp-Toolbar-item.jp-Toolbar-spacer {
|
|
29
|
+
flex-grow: 1;
|
|
30
|
+
flex-shrink: 1;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
.jp-Toolbar-item.jp-Toolbar-
|
|
33
|
+
.jp-Toolbar-item.jp-Toolbar-kernelStatus {
|
|
35
34
|
display: inline-block;
|
|
36
|
-
height: 24px;
|
|
37
35
|
width: 32px;
|
|
38
|
-
background-color: var(--jp-layout-color1);
|
|
39
36
|
background-repeat: no-repeat;
|
|
40
37
|
background-position: center;
|
|
41
38
|
background-size: 16px;
|
|
42
|
-
border: 1px solid var(--jp-layout-color1);
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
.jp-Toolbar
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
.jp-Toolbar > .jp-Toolbar-item {
|
|
42
|
+
flex: 0 0 auto;
|
|
43
|
+
display: flex;
|
|
44
|
+
padding-left: 1px;
|
|
45
|
+
padding-right: 1px;
|
|
46
|
+
font-size: var(--jp-ui-font-size1);
|
|
47
|
+
line-height: var(--jp-private-toolbar-height);
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Toolbar buttons */
|
|
52
|
+
|
|
53
|
+
/* This is the div we use to wrap the react component into a Widget */
|
|
54
|
+
div.jp-ToolbarButton {
|
|
55
|
+
color: transparent;
|
|
56
|
+
border: none;
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
outline: none;
|
|
59
|
+
appearance: none;
|
|
60
|
+
-webkit-appearance: none;
|
|
61
|
+
-moz-appearance: none;
|
|
62
|
+
padding: 0px;
|
|
63
|
+
margin: 0px;
|
|
48
64
|
}
|
|
49
65
|
|
|
50
|
-
.jp-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
button.jp-ToolbarButtonComponent {
|
|
67
|
+
background: var(--jp-layout-color1);
|
|
68
|
+
border: none;
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
outline: none;
|
|
71
|
+
appearance: none;
|
|
72
|
+
-webkit-appearance: none;
|
|
73
|
+
-moz-appearance: none;
|
|
74
|
+
padding: 0px 6px;
|
|
75
|
+
margin: 0px;
|
|
76
|
+
height: 24px;
|
|
77
|
+
border-radius: var(--jp-border-radius);
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
53
80
|
}
|
|
54
81
|
|
|
55
|
-
.jp-
|
|
56
|
-
|
|
57
|
-
background-color: var(--jp-toolbar-active-background);
|
|
58
|
-
box-shadow: var(--jp-toolbar-box-shadow);
|
|
82
|
+
button.jp-ToolbarButtonComponent:focus {
|
|
83
|
+
background: var(--jp-layout-color2);
|
|
59
84
|
}
|
|
60
85
|
|
|
61
|
-
.jp-
|
|
62
|
-
|
|
86
|
+
button.jp-ToolbarButtonComponent:enabled:hover {
|
|
87
|
+
background: var(--jp-layout-color2);
|
|
63
88
|
}
|
|
64
89
|
|
|
65
|
-
.jp-
|
|
66
|
-
background
|
|
67
|
-
box-shadow: inset 0 0px 1px rgba(0, 0, 0, 0.5);
|
|
90
|
+
button.jp-ToolbarButtonComponent:enabled:active {
|
|
91
|
+
background: var(--jp-layout-color3);
|
|
68
92
|
}
|
|
69
93
|
|
|
70
|
-
.jp-
|
|
71
|
-
|
|
72
|
-
flex-shrink: 1;
|
|
94
|
+
button.jp-ToolbarButtonComponent:disabled {
|
|
95
|
+
opacity: 0.4;
|
|
73
96
|
}
|
|
74
97
|
|
|
75
|
-
.jp-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
letter-spacing: normal;
|
|
79
|
-
text-align: left;
|
|
80
|
-
font-size: var(--jp-ui-font-size1);
|
|
81
|
-
line-height: 22px;
|
|
98
|
+
button.jp-ToolbarButtonComponent span {
|
|
99
|
+
padding: 0px;
|
|
100
|
+
flex: 0 0 auto;
|
|
82
101
|
}
|
|
83
102
|
|
|
84
|
-
.jp-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
background-size: 16px;
|
|
103
|
+
button.jp-ToolbarButtonComponent .jp-ToolbarButtonComponent-label {
|
|
104
|
+
font-size: var(--jp-ui-font-size1);
|
|
105
|
+
line-height: 100%;
|
|
106
|
+
padding-left: 2px;
|
|
107
|
+
color: var(--jp-ui-font-color1);
|
|
90
108
|
}
|