@jupyterlab/apputils 0.19.1-alpha.0 → 0.19.1
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/LICENSE +34 -0
- package/lib/clientsession.d.ts +443 -443
- package/lib/clientsession.js +883 -883
- package/lib/clipboard.d.ts +33 -33
- package/lib/clipboard.js +88 -88
- package/lib/commandlinker.d.ts +121 -121
- package/lib/commandlinker.js +175 -175
- package/lib/commandpalette.d.ts +33 -33
- package/lib/commandpalette.js +12 -12
- package/lib/dialog.d.ts +357 -357
- package/lib/dialog.js +540 -540
- package/lib/domutils.d.ts +13 -13
- package/lib/domutils.js +28 -28
- package/lib/hoverbox.d.ts +82 -82
- package/lib/hoverbox.js +101 -101
- package/lib/iframe.d.ts +14 -14
- package/lib/iframe.js +45 -45
- package/lib/index.d.ts +19 -19
- package/lib/index.js +26 -26
- package/lib/instancetracker.d.ts +278 -278
- package/lib/instancetracker.js +318 -318
- package/lib/mainareawidget.d.ts +108 -108
- package/lib/mainareawidget.js +184 -184
- package/lib/sanitizer.d.ts +44 -44
- package/lib/sanitizer.js +913 -913
- package/lib/spinner.d.ts +15 -15
- package/lib/spinner.js +30 -30
- package/lib/splash.d.ts +19 -19
- package/lib/splash.js +10 -10
- package/lib/styling.d.ts +27 -27
- package/lib/styling.js +92 -92
- package/lib/thememanager.d.ts +141 -141
- package/lib/thememanager.js +238 -238
- package/lib/toolbar.d.ts +178 -178
- package/lib/toolbar.js +515 -515
- package/lib/vdom.d.ts +90 -90
- package/lib/vdom.js +130 -130
- package/lib/windowresolver.d.ts +37 -37
- package/lib/windowresolver.js +173 -173
- package/package.json +9 -6
package/lib/commandlinker.js
CHANGED
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*-----------------------------------------------------------------------------
|
|
3
|
-
| Copyright (c) Jupyter Development Team.
|
|
4
|
-
| Distributed under the terms of the Modified BSD License.
|
|
5
|
-
|----------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const coreutils_1 = require("@phosphor/coreutils");
|
|
8
|
-
/**
|
|
9
|
-
* The command data attribute added to nodes that are connected.
|
|
10
|
-
*/
|
|
11
|
-
const COMMAND_ATTR = 'commandlinker-command';
|
|
12
|
-
/**
|
|
13
|
-
* The args data attribute added to nodes that are connected.
|
|
14
|
-
*/
|
|
15
|
-
const ARGS_ATTR = 'commandlinker-args';
|
|
16
|
-
/**
|
|
17
|
-
* A static class that provides helper methods to generate clickable nodes that
|
|
18
|
-
* execute registered commands with pre-populated arguments.
|
|
19
|
-
*/
|
|
20
|
-
class CommandLinker {
|
|
21
|
-
/**
|
|
22
|
-
* Instantiate a new command linker.
|
|
23
|
-
*/
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this._isDisposed = false;
|
|
26
|
-
this._commands = options.commands;
|
|
27
|
-
document.body.addEventListener('click', this);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Test whether the linker is disposed.
|
|
31
|
-
*/
|
|
32
|
-
get isDisposed() {
|
|
33
|
-
return this._isDisposed;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Dispose of the resources held by the linker.
|
|
37
|
-
*/
|
|
38
|
-
dispose() {
|
|
39
|
-
if (this.isDisposed) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this._isDisposed = true;
|
|
43
|
-
document.body.removeEventListener('click', this);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Connect a command/argument pair to a given node so that when it is clicked,
|
|
47
|
-
* the command will execute.
|
|
48
|
-
*
|
|
49
|
-
* @param node - The node being connected.
|
|
50
|
-
*
|
|
51
|
-
* @param command - The command ID to execute upon click.
|
|
52
|
-
*
|
|
53
|
-
* @param args - The arguments with which to invoke the command.
|
|
54
|
-
*
|
|
55
|
-
* @returns The same node that was passed in, after it has been connected.
|
|
56
|
-
*
|
|
57
|
-
* #### Notes
|
|
58
|
-
* Only `click` events will execute the command on a connected node. So, there
|
|
59
|
-
* are two considerations that are relevant:
|
|
60
|
-
* 1. If a node is connected, the default click action will be prevented.
|
|
61
|
-
* 2. The `HTMLElement` passed in should be clickable.
|
|
62
|
-
*/
|
|
63
|
-
connectNode(node, command, args) {
|
|
64
|
-
node.setAttribute(`data-${COMMAND_ATTR}`, command);
|
|
65
|
-
if (args !== void 0) {
|
|
66
|
-
node.setAttribute(`data-${ARGS_ATTR}`, JSON.stringify(args));
|
|
67
|
-
}
|
|
68
|
-
return node;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Disconnect a node that has been connected to execute a command on click.
|
|
72
|
-
*
|
|
73
|
-
* @param node - The node being disconnected.
|
|
74
|
-
*
|
|
75
|
-
* @returns The same node that was passed in, after it has been disconnected.
|
|
76
|
-
*
|
|
77
|
-
* #### Notes
|
|
78
|
-
* This method is safe to call multiple times and is safe to call on nodes
|
|
79
|
-
* that were never connected.
|
|
80
|
-
*
|
|
81
|
-
* This method can be called on rendered virtual DOM nodes that were populated
|
|
82
|
-
* using the `populateVNodeDataset` method in order to disconnect them from
|
|
83
|
-
* executing their command/argument pair.
|
|
84
|
-
*/
|
|
85
|
-
disconnectNode(node) {
|
|
86
|
-
node.removeAttribute(`data-${COMMAND_ATTR}`);
|
|
87
|
-
node.removeAttribute(`data-${ARGS_ATTR}`);
|
|
88
|
-
return node;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Handle the DOM events for the command linker helper class.
|
|
92
|
-
*
|
|
93
|
-
* @param event - The DOM event sent to the class.
|
|
94
|
-
*
|
|
95
|
-
* #### Notes
|
|
96
|
-
* This method implements the DOM `EventListener` interface and is
|
|
97
|
-
* called in response to events on the panel's DOM node. It should
|
|
98
|
-
* not be called directly by user code.
|
|
99
|
-
*/
|
|
100
|
-
handleEvent(event) {
|
|
101
|
-
switch (event.type) {
|
|
102
|
-
case 'click':
|
|
103
|
-
this._evtClick(event);
|
|
104
|
-
break;
|
|
105
|
-
default:
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Populate the `dataset` attribute within the collection of attributes used
|
|
111
|
-
* to instantiate a virtual DOM node with the values necessary for its
|
|
112
|
-
* rendered DOM node to respond to clicks by executing a command/argument
|
|
113
|
-
* pair.
|
|
114
|
-
*
|
|
115
|
-
* @param command - The command ID to execute upon click.
|
|
116
|
-
*
|
|
117
|
-
* @param args - The arguments with which to invoke the command.
|
|
118
|
-
*
|
|
119
|
-
* @returns A `dataset` collection for use within virtual node attributes.
|
|
120
|
-
*
|
|
121
|
-
* #### Notes
|
|
122
|
-
* The return value can be used on its own as the value for the `dataset`
|
|
123
|
-
* attribute of a virtual element, or it can be added to an existing `dataset`
|
|
124
|
-
* as in the example below.
|
|
125
|
-
*
|
|
126
|
-
* #### Example
|
|
127
|
-
* ```typescript
|
|
128
|
-
* let command = 'some:command-id';
|
|
129
|
-
* let args = { alpha: 'beta' };
|
|
130
|
-
* let anchor = h.a({
|
|
131
|
-
* className: 'some-class',
|
|
132
|
-
* dataset: {
|
|
133
|
-
* foo: '1',
|
|
134
|
-
* bar: '2',
|
|
135
|
-
* ../...linker.populateVNodeDataset(command, args)
|
|
136
|
-
* }
|
|
137
|
-
* }, 'some text');
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
populateVNodeDataset(command, args) {
|
|
141
|
-
let dataset;
|
|
142
|
-
if (args !== void 0) {
|
|
143
|
-
dataset = { [ARGS_ATTR]: JSON.stringify(args), [COMMAND_ATTR]: command };
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
dataset = { [COMMAND_ATTR]: command };
|
|
147
|
-
}
|
|
148
|
-
return dataset;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* The global click handler that deploys commands/argument pairs that are
|
|
152
|
-
* attached to the node being clicked.
|
|
153
|
-
*/
|
|
154
|
-
_evtClick(event) {
|
|
155
|
-
let target = event.target;
|
|
156
|
-
while (target && target.parentElement) {
|
|
157
|
-
if (target.hasAttribute(`data-${COMMAND_ATTR}`)) {
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
let command = target.getAttribute(`data-${COMMAND_ATTR}`);
|
|
160
|
-
if (!command) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
let argsValue = target.getAttribute(`data-${ARGS_ATTR}`);
|
|
164
|
-
let args = coreutils_1.JSONExt.emptyObject;
|
|
165
|
-
if (argsValue) {
|
|
166
|
-
args = JSON.parse(argsValue);
|
|
167
|
-
}
|
|
168
|
-
this._commands.execute(command, args);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
target = target.parentElement;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.CommandLinker = CommandLinker;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*-----------------------------------------------------------------------------
|
|
3
|
+
| Copyright (c) Jupyter Development Team.
|
|
4
|
+
| Distributed under the terms of the Modified BSD License.
|
|
5
|
+
|----------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const coreutils_1 = require("@phosphor/coreutils");
|
|
8
|
+
/**
|
|
9
|
+
* The command data attribute added to nodes that are connected.
|
|
10
|
+
*/
|
|
11
|
+
const COMMAND_ATTR = 'commandlinker-command';
|
|
12
|
+
/**
|
|
13
|
+
* The args data attribute added to nodes that are connected.
|
|
14
|
+
*/
|
|
15
|
+
const ARGS_ATTR = 'commandlinker-args';
|
|
16
|
+
/**
|
|
17
|
+
* A static class that provides helper methods to generate clickable nodes that
|
|
18
|
+
* execute registered commands with pre-populated arguments.
|
|
19
|
+
*/
|
|
20
|
+
class CommandLinker {
|
|
21
|
+
/**
|
|
22
|
+
* Instantiate a new command linker.
|
|
23
|
+
*/
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this._isDisposed = false;
|
|
26
|
+
this._commands = options.commands;
|
|
27
|
+
document.body.addEventListener('click', this);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Test whether the linker is disposed.
|
|
31
|
+
*/
|
|
32
|
+
get isDisposed() {
|
|
33
|
+
return this._isDisposed;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Dispose of the resources held by the linker.
|
|
37
|
+
*/
|
|
38
|
+
dispose() {
|
|
39
|
+
if (this.isDisposed) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this._isDisposed = true;
|
|
43
|
+
document.body.removeEventListener('click', this);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Connect a command/argument pair to a given node so that when it is clicked,
|
|
47
|
+
* the command will execute.
|
|
48
|
+
*
|
|
49
|
+
* @param node - The node being connected.
|
|
50
|
+
*
|
|
51
|
+
* @param command - The command ID to execute upon click.
|
|
52
|
+
*
|
|
53
|
+
* @param args - The arguments with which to invoke the command.
|
|
54
|
+
*
|
|
55
|
+
* @returns The same node that was passed in, after it has been connected.
|
|
56
|
+
*
|
|
57
|
+
* #### Notes
|
|
58
|
+
* Only `click` events will execute the command on a connected node. So, there
|
|
59
|
+
* are two considerations that are relevant:
|
|
60
|
+
* 1. If a node is connected, the default click action will be prevented.
|
|
61
|
+
* 2. The `HTMLElement` passed in should be clickable.
|
|
62
|
+
*/
|
|
63
|
+
connectNode(node, command, args) {
|
|
64
|
+
node.setAttribute(`data-${COMMAND_ATTR}`, command);
|
|
65
|
+
if (args !== void 0) {
|
|
66
|
+
node.setAttribute(`data-${ARGS_ATTR}`, JSON.stringify(args));
|
|
67
|
+
}
|
|
68
|
+
return node;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Disconnect a node that has been connected to execute a command on click.
|
|
72
|
+
*
|
|
73
|
+
* @param node - The node being disconnected.
|
|
74
|
+
*
|
|
75
|
+
* @returns The same node that was passed in, after it has been disconnected.
|
|
76
|
+
*
|
|
77
|
+
* #### Notes
|
|
78
|
+
* This method is safe to call multiple times and is safe to call on nodes
|
|
79
|
+
* that were never connected.
|
|
80
|
+
*
|
|
81
|
+
* This method can be called on rendered virtual DOM nodes that were populated
|
|
82
|
+
* using the `populateVNodeDataset` method in order to disconnect them from
|
|
83
|
+
* executing their command/argument pair.
|
|
84
|
+
*/
|
|
85
|
+
disconnectNode(node) {
|
|
86
|
+
node.removeAttribute(`data-${COMMAND_ATTR}`);
|
|
87
|
+
node.removeAttribute(`data-${ARGS_ATTR}`);
|
|
88
|
+
return node;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Handle the DOM events for the command linker helper class.
|
|
92
|
+
*
|
|
93
|
+
* @param event - The DOM event sent to the class.
|
|
94
|
+
*
|
|
95
|
+
* #### Notes
|
|
96
|
+
* This method implements the DOM `EventListener` interface and is
|
|
97
|
+
* called in response to events on the panel's DOM node. It should
|
|
98
|
+
* not be called directly by user code.
|
|
99
|
+
*/
|
|
100
|
+
handleEvent(event) {
|
|
101
|
+
switch (event.type) {
|
|
102
|
+
case 'click':
|
|
103
|
+
this._evtClick(event);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Populate the `dataset` attribute within the collection of attributes used
|
|
111
|
+
* to instantiate a virtual DOM node with the values necessary for its
|
|
112
|
+
* rendered DOM node to respond to clicks by executing a command/argument
|
|
113
|
+
* pair.
|
|
114
|
+
*
|
|
115
|
+
* @param command - The command ID to execute upon click.
|
|
116
|
+
*
|
|
117
|
+
* @param args - The arguments with which to invoke the command.
|
|
118
|
+
*
|
|
119
|
+
* @returns A `dataset` collection for use within virtual node attributes.
|
|
120
|
+
*
|
|
121
|
+
* #### Notes
|
|
122
|
+
* The return value can be used on its own as the value for the `dataset`
|
|
123
|
+
* attribute of a virtual element, or it can be added to an existing `dataset`
|
|
124
|
+
* as in the example below.
|
|
125
|
+
*
|
|
126
|
+
* #### Example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* let command = 'some:command-id';
|
|
129
|
+
* let args = { alpha: 'beta' };
|
|
130
|
+
* let anchor = h.a({
|
|
131
|
+
* className: 'some-class',
|
|
132
|
+
* dataset: {
|
|
133
|
+
* foo: '1',
|
|
134
|
+
* bar: '2',
|
|
135
|
+
* ../...linker.populateVNodeDataset(command, args)
|
|
136
|
+
* }
|
|
137
|
+
* }, 'some text');
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
populateVNodeDataset(command, args) {
|
|
141
|
+
let dataset;
|
|
142
|
+
if (args !== void 0) {
|
|
143
|
+
dataset = { [ARGS_ATTR]: JSON.stringify(args), [COMMAND_ATTR]: command };
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
dataset = { [COMMAND_ATTR]: command };
|
|
147
|
+
}
|
|
148
|
+
return dataset;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The global click handler that deploys commands/argument pairs that are
|
|
152
|
+
* attached to the node being clicked.
|
|
153
|
+
*/
|
|
154
|
+
_evtClick(event) {
|
|
155
|
+
let target = event.target;
|
|
156
|
+
while (target && target.parentElement) {
|
|
157
|
+
if (target.hasAttribute(`data-${COMMAND_ATTR}`)) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
let command = target.getAttribute(`data-${COMMAND_ATTR}`);
|
|
160
|
+
if (!command) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
let argsValue = target.getAttribute(`data-${ARGS_ATTR}`);
|
|
164
|
+
let args = coreutils_1.JSONExt.emptyObject;
|
|
165
|
+
if (argsValue) {
|
|
166
|
+
args = JSON.parse(argsValue);
|
|
167
|
+
}
|
|
168
|
+
this._commands.execute(command, args);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
target = target.parentElement;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.CommandLinker = CommandLinker;
|
package/lib/commandpalette.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Token } from '@phosphor/coreutils';
|
|
2
|
-
import { IDisposable } from '@phosphor/disposable';
|
|
3
|
-
import { CommandPalette } from '@phosphor/widgets';
|
|
4
|
-
/**
|
|
5
|
-
* The command palette token.
|
|
6
|
-
*/
|
|
7
|
-
export declare const ICommandPalette: Token<ICommandPalette>;
|
|
8
|
-
/**
|
|
9
|
-
* The options for creating a command palette item.
|
|
10
|
-
*/
|
|
11
|
-
export interface IPaletteItem extends CommandPalette.IItemOptions {
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The interface for a Jupyter Lab command palette.
|
|
15
|
-
*/
|
|
16
|
-
export interface ICommandPalette {
|
|
17
|
-
/**
|
|
18
|
-
* The placeholder text of the command palette's search input.
|
|
19
|
-
*/
|
|
20
|
-
placeholder: string;
|
|
21
|
-
/**
|
|
22
|
-
* Activate the command palette for user input.
|
|
23
|
-
*/
|
|
24
|
-
activate(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Add a command item to the command palette.
|
|
27
|
-
*
|
|
28
|
-
* @param options - The options for creating the command item.
|
|
29
|
-
*
|
|
30
|
-
* @returns A disposable that will remove the item from the palette.
|
|
31
|
-
*/
|
|
32
|
-
addItem(options: IPaletteItem): IDisposable;
|
|
33
|
-
}
|
|
1
|
+
import { Token } from '@phosphor/coreutils';
|
|
2
|
+
import { IDisposable } from '@phosphor/disposable';
|
|
3
|
+
import { CommandPalette } from '@phosphor/widgets';
|
|
4
|
+
/**
|
|
5
|
+
* The command palette token.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ICommandPalette: Token<ICommandPalette>;
|
|
8
|
+
/**
|
|
9
|
+
* The options for creating a command palette item.
|
|
10
|
+
*/
|
|
11
|
+
export interface IPaletteItem extends CommandPalette.IItemOptions {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The interface for a Jupyter Lab command palette.
|
|
15
|
+
*/
|
|
16
|
+
export interface ICommandPalette {
|
|
17
|
+
/**
|
|
18
|
+
* The placeholder text of the command palette's search input.
|
|
19
|
+
*/
|
|
20
|
+
placeholder: string;
|
|
21
|
+
/**
|
|
22
|
+
* Activate the command palette for user input.
|
|
23
|
+
*/
|
|
24
|
+
activate(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Add a command item to the command palette.
|
|
27
|
+
*
|
|
28
|
+
* @param options - The options for creating the command item.
|
|
29
|
+
*
|
|
30
|
+
* @returns A disposable that will remove the item from the palette.
|
|
31
|
+
*/
|
|
32
|
+
addItem(options: IPaletteItem): IDisposable;
|
|
33
|
+
}
|
package/lib/commandpalette.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*-----------------------------------------------------------------------------
|
|
3
|
-
| Copyright (c) Jupyter Development Team.
|
|
4
|
-
| Distributed under the terms of the Modified BSD License.
|
|
5
|
-
|----------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const coreutils_1 = require("@phosphor/coreutils");
|
|
8
|
-
/* tslint:disable */
|
|
9
|
-
/**
|
|
10
|
-
* The command palette token.
|
|
11
|
-
*/
|
|
12
|
-
exports.ICommandPalette = new coreutils_1.Token('@jupyterlab/apputils:ICommandPalette');
|
|
1
|
+
"use strict";
|
|
2
|
+
/*-----------------------------------------------------------------------------
|
|
3
|
+
| Copyright (c) Jupyter Development Team.
|
|
4
|
+
| Distributed under the terms of the Modified BSD License.
|
|
5
|
+
|----------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const coreutils_1 = require("@phosphor/coreutils");
|
|
8
|
+
/* tslint:disable */
|
|
9
|
+
/**
|
|
10
|
+
* The command palette token.
|
|
11
|
+
*/
|
|
12
|
+
exports.ICommandPalette = new coreutils_1.Token('@jupyterlab/apputils:ICommandPalette');
|