@jupyterlab/apputils 4.0.0-alpha.2 → 4.0.0-alpha.20
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/clipboard.d.ts +1 -1
- package/lib/dialog.d.ts +73 -4
- package/lib/dialog.js +143 -30
- package/lib/dialog.js.map +1 -1
- package/lib/domutils.js.map +1 -1
- package/lib/index.d.ts +6 -5
- package/lib/index.js +6 -5
- package/lib/index.js.map +1 -1
- package/lib/inputdialog.d.ts +35 -3
- package/lib/inputdialog.js +122 -12
- package/lib/inputdialog.js.map +1 -1
- package/lib/kernelstatuses.d.ts +74 -2
- package/lib/kernelstatuses.js +142 -2
- package/lib/kernelstatuses.js.map +1 -1
- package/lib/mainareawidget.d.ts +9 -0
- package/lib/mainareawidget.js +29 -4
- package/lib/mainareawidget.js.map +1 -1
- package/lib/menufactory.js +14 -15
- package/lib/menufactory.js.map +1 -1
- package/lib/notification.d.ts +336 -0
- package/lib/notification.js +310 -0
- package/lib/notification.js.map +1 -0
- package/lib/runningSessions.d.ts +72 -0
- package/lib/runningSessions.js +119 -0
- package/lib/runningSessions.js.map +1 -0
- package/lib/sanitizer.d.ts +6 -4
- package/lib/sanitizer.js +32 -12
- package/lib/sanitizer.js.map +1 -1
- package/lib/semanticCommand.js +11 -2
- package/lib/semanticCommand.js.map +1 -1
- package/lib/sessioncontext.d.ts +2 -3
- package/lib/sessioncontext.js +46 -27
- package/lib/sessioncontext.js.map +1 -1
- package/lib/testutils.d.ts +5 -0
- package/lib/testutils.js +46 -0
- package/lib/testutils.js.map +1 -0
- package/lib/thememanager.js +13 -4
- package/lib/thememanager.js.map +1 -1
- package/lib/tokens.d.ts +26 -9
- package/lib/tokens.js +1 -6
- package/lib/tokens.js.map +1 -1
- package/lib/toolbar/factory.d.ts +12 -2
- package/lib/toolbar/factory.js +237 -145
- package/lib/toolbar/factory.js.map +1 -1
- package/lib/toolbar/index.js +4 -0
- package/lib/toolbar/index.js.map +1 -1
- package/lib/toolbar/registry.d.ts +11 -0
- package/lib/toolbar/registry.js +20 -3
- package/lib/toolbar/registry.js.map +1 -1
- package/lib/toolbar/widget.d.ts +3 -0
- package/lib/toolbar/widget.js +3 -0
- package/lib/toolbar/widget.js.map +1 -1
- package/lib/widgettracker.d.ts +13 -1
- package/lib/widgettracker.js +29 -2
- package/lib/widgettracker.js.map +1 -1
- package/package.json +30 -30
- package/src/clipboard.ts +107 -0
- package/src/commandlinker.ts +209 -0
- package/src/commandpalette.ts +175 -0
- package/src/dialog.tsx +1133 -0
- package/src/domutils.ts +53 -0
- package/src/index.ts +78 -0
- package/src/inputdialog.ts +551 -0
- package/src/kernelstatuses.tsx +279 -0
- package/src/mainareawidget.ts +362 -0
- package/src/menufactory.ts +201 -0
- package/src/notification.ts +559 -0
- package/src/printing.ts +180 -0
- package/src/runningSessions.tsx +233 -0
- package/src/sanitizer.ts +968 -0
- package/src/semanticCommand.ts +77 -0
- package/src/sessioncontext.tsx +1712 -0
- package/src/testutils.ts +49 -0
- package/src/thememanager.ts +519 -0
- package/src/tokens.ts +372 -0
- package/src/toolbar/factory.ts +422 -0
- package/src/toolbar/index.ts +8 -0
- package/src/toolbar/registry.ts +158 -0
- package/src/toolbar/widget.tsx +243 -0
- package/src/widgettracker.ts +391 -0
- package/src/windowresolver.ts +218 -0
- package/style/base.css +0 -1
- package/style/commandpalette.css +7 -10
- package/style/dialog.css +23 -7
- package/style/index.css +1 -0
- package/style/index.js +1 -0
- package/style/inputdialog.css +5 -0
- package/style/materialcolors.css +8 -21
- package/lib/hoverbox.d.ts +0 -82
- package/lib/hoverbox.js +0 -100
- package/lib/hoverbox.js.map +0 -1
- package/style/hoverbox.css +0 -13
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Widget } from '@lumino/widgets';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options when add a command to a semantic group.
|
|
10
|
+
*/
|
|
11
|
+
interface ISemanticCommand {
|
|
12
|
+
/**
|
|
13
|
+
* Command id
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether this command is enabled for a given widget
|
|
18
|
+
* @param widget Widget
|
|
19
|
+
*/
|
|
20
|
+
isEnabled?(widget: Widget): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Command rank in the semantic group
|
|
23
|
+
*
|
|
24
|
+
* #### Note
|
|
25
|
+
* If multiple commands are enabled at the same time,
|
|
26
|
+
* the one with the smallest rank will be executed.
|
|
27
|
+
*/
|
|
28
|
+
rank?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Semantic group of commands
|
|
33
|
+
*/
|
|
34
|
+
export class SemanticCommand {
|
|
35
|
+
/**
|
|
36
|
+
* Default rank for semantic command
|
|
37
|
+
*/
|
|
38
|
+
static readonly DEFAULT_RANK = 500;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Add a command to the semantic group
|
|
42
|
+
*
|
|
43
|
+
* @param command Command to add
|
|
44
|
+
*/
|
|
45
|
+
add(command: ISemanticCommand): void {
|
|
46
|
+
if (this._commands.map(c => c.id).includes(command.id)) {
|
|
47
|
+
throw Error(`Command ${command.id} is already defined.`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this._commands.push({
|
|
51
|
+
isEnabled: () => true,
|
|
52
|
+
rank: SemanticCommand.DEFAULT_RANK,
|
|
53
|
+
...command
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the command id of the enabled command from this group
|
|
59
|
+
* for the given widget.
|
|
60
|
+
*
|
|
61
|
+
* @param widget Widget
|
|
62
|
+
* @returns Command id
|
|
63
|
+
*/
|
|
64
|
+
getActiveCommandId(widget: Widget): string | null {
|
|
65
|
+
const commands = this._commands
|
|
66
|
+
.filter(c => c.isEnabled(widget))
|
|
67
|
+
.sort((a, b) => {
|
|
68
|
+
const rankDelta = a.rank - b.rank;
|
|
69
|
+
return rankDelta || (a.id < b.id ? -1 : 1);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const command = commands[0] ?? { id: null };
|
|
73
|
+
return command.id;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected _commands = new Array<Required<ISemanticCommand>>();
|
|
77
|
+
}
|