@jupyter-notebook/application 7.0.0-alpha.9 → 7.0.0-beta.0

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/app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- import { JupyterFrontEnd } from '@jupyterlab/application';
3
+ import { JupyterFrontEnd, } from '@jupyterlab/application';
4
4
  import { Base64ModelFactory } from '@jupyterlab/docregistry';
5
5
  import { createRendermimePlugins } from '@jupyterlab/application/lib/mimerenderers';
6
6
  import { LabStatus } from '@jupyterlab/application/lib/status';
@@ -65,7 +65,7 @@ export class NotebookApp extends JupyterFrontEnd {
65
65
  hubHost: PageConfig.getOption('hubHost') || undefined,
66
66
  hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
67
67
  hubUser: PageConfig.getOption('hubUser') || undefined,
68
- hubServerName: PageConfig.getOption('hubServerName') || undefined
68
+ hubServerName: PageConfig.getOption('hubServerName') || undefined,
69
69
  },
70
70
  directories: {
71
71
  appSettings: PageConfig.getOption('appSettingsDir'),
@@ -75,8 +75,8 @@ export class NotebookApp extends JupyterFrontEnd {
75
75
  themes: PageConfig.getOption('themesDir'),
76
76
  userSettings: PageConfig.getOption('userSettingsDir'),
77
77
  serverRoot: PageConfig.getOption('serverRoot'),
78
- workspaces: PageConfig.getOption('workspacesDir')
79
- }
78
+ workspaces: PageConfig.getOption('workspacesDir'),
79
+ },
80
80
  };
81
81
  }
82
82
  /**
@@ -104,7 +104,7 @@ export class NotebookApp extends JupyterFrontEnd {
104
104
  if (!Array.isArray(data)) {
105
105
  data = [data];
106
106
  }
107
- data.forEach(item => {
107
+ data.forEach((item) => {
108
108
  try {
109
109
  this.registerPlugin(item);
110
110
  }
@@ -119,7 +119,7 @@ export class NotebookApp extends JupyterFrontEnd {
119
119
  * @param mods - The plugin modules to register.
120
120
  */
121
121
  registerPluginModules(mods) {
122
- mods.forEach(mod => {
122
+ mods.forEach((mod) => {
123
123
  this.registerPluginModule(mod);
124
124
  });
125
125
  }
@@ -18,7 +18,7 @@ export declare class PanelHandler {
18
18
  */
19
19
  addWidget(widget: Widget, rank: number): void;
20
20
  /**
21
- * A message hook for child add/remove messages on the main area dock panel.
21
+ * A message hook for child remove messages on the panel handler.
22
22
  */
23
23
  private _panelChildHook;
24
24
  protected _items: Private.IRankItem[];
@@ -60,6 +60,10 @@ export declare class SidePanelHandler extends PanelHandler {
60
60
  * Signal fired when a widget is removed from the panel
61
61
  */
62
62
  get widgetRemoved(): ISignal<SidePanelHandler, Widget>;
63
+ /**
64
+ * Get the close button element.
65
+ */
66
+ get closeButton(): HTMLButtonElement;
63
67
  /**
64
68
  * Expand the sidebar.
65
69
  *
@@ -118,6 +122,7 @@ export declare class SidePanelHandler extends PanelHandler {
118
122
  private _widgetPanel;
119
123
  private _currentWidget;
120
124
  private _lastCurrentWidget;
125
+ private _closeButton;
121
126
  private _widgetAdded;
122
127
  private _widgetRemoved;
123
128
  }
@@ -154,7 +159,7 @@ export declare class SidePanelPalette {
154
159
  _commandPalette: ICommandPalette;
155
160
  _items: SidePanelPaletteItem[];
156
161
  }
157
- declare type SidePanelPaletteItem = {
162
+ type SidePanelPaletteItem = {
158
163
  /**
159
164
  * The ID of the widget associated to the command palette.
160
165
  */
@@ -171,7 +176,7 @@ declare type SidePanelPaletteItem = {
171
176
  /**
172
177
  * An interface for the options to include in SideBarPalette constructor.
173
178
  */
174
- declare type SidePanelPaletteOption = {
179
+ type SidePanelPaletteOption = {
175
180
  /**
176
181
  * The commands palette.
177
182
  */
@@ -11,26 +11,14 @@ import { Panel, StackedPanel, Widget } from '@lumino/widgets';
11
11
  export class PanelHandler {
12
12
  constructor() {
13
13
  /**
14
- * A message hook for child add/remove messages on the main area dock panel.
14
+ * A message hook for child remove messages on the panel handler.
15
15
  */
16
16
  this._panelChildHook = (handler, msg) => {
17
17
  switch (msg.type) {
18
- case 'child-added':
19
- {
20
- const widget = msg.child;
21
- // If we already know about this widget, we're done
22
- if (this._items.find(v => v.widget === widget)) {
23
- break;
24
- }
25
- // Otherwise, add to the end by default
26
- const rank = this._items[this._items.length - 1].rank;
27
- this._items.push({ widget, rank });
28
- }
29
- break;
30
18
  case 'child-removed':
31
19
  {
32
20
  const widget = msg.child;
33
- ArrayExt.removeFirstWhere(this._items, v => v.widget === widget);
21
+ ArrayExt.removeFirstWhere(this._items, (v) => v.widget === widget);
34
22
  }
35
23
  break;
36
24
  default:
@@ -79,18 +67,19 @@ export class SidePanelHandler extends PanelHandler {
79
67
  this._lastCurrentWidget = null;
80
68
  this._widgetPanel = new StackedPanel();
81
69
  this._widgetPanel.widgetRemoved.connect(this._onWidgetRemoved, this);
82
- const closeButton = document.createElement('button');
70
+ this._closeButton = document.createElement('button');
83
71
  closeIcon.element({
84
- container: closeButton,
72
+ container: this._closeButton,
85
73
  height: '16px',
86
- width: 'auto'
74
+ width: 'auto',
87
75
  });
88
- closeButton.onclick = () => {
76
+ this._closeButton.onclick = () => {
89
77
  this.collapse();
90
78
  this.hide();
91
79
  };
92
- closeButton.className = 'jp-Button jp-SidePanel-collapse';
93
- const icon = new Widget({ node: closeButton });
80
+ this._closeButton.className = 'jp-Button jp-SidePanel-collapse';
81
+ this._closeButton.title = 'Collapse side panel';
82
+ const icon = new Widget({ node: this._closeButton });
94
83
  this._panel.addWidget(icon);
95
84
  this._panel.addWidget(this._widgetPanel);
96
85
  }
@@ -124,7 +113,7 @@ export class SidePanelHandler extends PanelHandler {
124
113
  * Get the widgets list.
125
114
  */
126
115
  get widgets() {
127
- return this._items.map(obj => obj.widget);
116
+ return this._items.map((obj) => obj.widget);
128
117
  }
129
118
  /**
130
119
  * Signal fired when a widget is added to the panel
@@ -138,6 +127,12 @@ export class SidePanelHandler extends PanelHandler {
138
127
  get widgetRemoved() {
139
128
  return this._widgetRemoved;
140
129
  }
130
+ /**
131
+ * Get the close button element.
132
+ */
133
+ get closeButton() {
134
+ return this._closeButton;
135
+ }
141
136
  /**
142
137
  * Expand the sidebar.
143
138
  *
@@ -226,13 +221,13 @@ export class SidePanelHandler extends PanelHandler {
226
221
  * Find the index of the item with the given widget, or `-1`.
227
222
  */
228
223
  _findWidgetIndex(widget) {
229
- return ArrayExt.findFirstIndex(this._items, i => i.widget === widget);
224
+ return ArrayExt.findFirstIndex(this._items, (i) => i.widget === widget);
230
225
  }
231
226
  /**
232
227
  * Find the widget with the given id, or `null`.
233
228
  */
234
229
  _findWidgetByID(id) {
235
- const item = find(this._items, value => value.widget.id === id);
230
+ const item = find(this._items, (value) => value.widget.id === id);
236
231
  return item ? item.widget : null;
237
232
  }
238
233
  /**
@@ -293,15 +288,15 @@ export class SidePanelPalette {
293
288
  args: {
294
289
  side: area,
295
290
  title: `Show ${widget.title.caption}`,
296
- id: widget.id
297
- }
291
+ id: widget.id,
292
+ },
298
293
  });
299
294
  // Keep the disposableDelegate objet to be able to dispose of the item if the widget
300
295
  // is remove from the side panel.
301
296
  this._items.push({
302
297
  widgetId: widget.id,
303
298
  area: area,
304
- disposable: disposableDelegate
299
+ disposable: disposableDelegate,
305
300
  });
306
301
  }
307
302
  /**
package/lib/shell.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { JupyterFrontEnd } from '@jupyterlab/application';
2
2
  import { DocumentRegistry } from '@jupyterlab/docregistry';
3
+ import { ITranslator } from '@jupyterlab/translation';
3
4
  import { Token } from '@lumino/coreutils';
4
5
  import { ISignal } from '@lumino/signaling';
5
6
  import { Widget } from '@lumino/widgets';
@@ -54,6 +55,11 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
54
55
  * Promise that resolves when the main widget is loaded
55
56
  */
56
57
  get restored(): Promise<void>;
58
+ /**
59
+ * Getter and setter for the translator.
60
+ */
61
+ get translator(): ITranslator;
62
+ set translator(value: ITranslator);
57
63
  /**
58
64
  * Activate a widget in its area.
59
65
  */
@@ -106,8 +112,10 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
106
112
  private _menuHandler;
107
113
  private _leftHandler;
108
114
  private _rightHandler;
109
- private _spacer;
115
+ private _spacer_top;
116
+ private _spacer_bottom;
110
117
  private _main;
118
+ private _translator;
111
119
  private _currentChanged;
112
120
  private _mainWidgetLoaded;
113
121
  }
package/lib/shell.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
+ import { nullTranslator } from '@jupyterlab/translation';
3
4
  import { find } from '@lumino/algorithm';
4
5
  import { PromiseDelegate, Token } from '@lumino/coreutils';
5
6
  import { Signal } from '@lumino/signaling';
@@ -19,6 +20,7 @@ const DEFAULT_RANK = 900;
19
20
  export class NotebookShell extends Widget {
20
21
  constructor() {
21
22
  super();
23
+ this._translator = nullTranslator;
22
24
  this._currentChanged = new Signal(this);
23
25
  this._mainWidgetLoaded = new PromiseDelegate();
24
26
  this.id = 'main';
@@ -30,10 +32,15 @@ export class NotebookShell extends Widget {
30
32
  const topWrapper = (this._topWrapper = new Panel());
31
33
  const menuWrapper = (this._menuWrapper = new Panel());
32
34
  this._topHandler.panel.id = 'top-panel';
35
+ this._topHandler.panel.node.setAttribute('role', 'banner');
33
36
  this._menuHandler.panel.id = 'menu-panel';
37
+ this._menuHandler.panel.node.setAttribute('role', 'navigation');
34
38
  this._main.id = 'main-panel';
35
- this._spacer = new Widget();
36
- this._spacer.id = 'spacer-widget';
39
+ this._main.node.setAttribute('role', 'main');
40
+ this._spacer_top = new Widget();
41
+ this._spacer_top.id = 'spacer-widget-top';
42
+ this._spacer_bottom = new Widget();
43
+ this._spacer_bottom.id = 'spacer-widget-bottom';
37
44
  // create wrappers around the top and menu areas
38
45
  topWrapper.id = 'top-panel-wrapper';
39
46
  topWrapper.addWidget(this._topHandler.panel);
@@ -43,13 +50,15 @@ export class NotebookShell extends Widget {
43
50
  const leftHandler = this._leftHandler;
44
51
  const rightHandler = this._rightHandler;
45
52
  leftHandler.panel.id = 'jp-left-stack';
53
+ leftHandler.panel.node.setAttribute('role', 'complementary');
46
54
  rightHandler.panel.id = 'jp-right-stack';
55
+ rightHandler.panel.node.setAttribute('role', 'complementary');
47
56
  // Hide the side panels by default.
48
57
  leftHandler.hide();
49
58
  rightHandler.hide();
50
59
  const middleLayout = new BoxLayout({
51
60
  spacing: 0,
52
- direction: 'top-to-bottom'
61
+ direction: 'top-to-bottom',
53
62
  });
54
63
  BoxLayout.setStretch(this._topWrapper, 0);
55
64
  BoxLayout.setStretch(this._menuWrapper, 0);
@@ -57,8 +66,9 @@ export class NotebookShell extends Widget {
57
66
  const middlePanel = new Panel({ layout: middleLayout });
58
67
  middlePanel.addWidget(this._topWrapper);
59
68
  middlePanel.addWidget(this._menuWrapper);
60
- middlePanel.addWidget(this._spacer);
69
+ middlePanel.addWidget(this._spacer_top);
61
70
  middlePanel.addWidget(this._main);
71
+ middlePanel.addWidget(this._spacer_bottom);
62
72
  middlePanel.layout = middleLayout;
63
73
  // TODO: Consider storing this as an attribute this._hsplitPanel if saving/restoring layout needed
64
74
  const hsplitPanel = new SplitPanel();
@@ -134,13 +144,28 @@ export class NotebookShell extends Widget {
134
144
  get restored() {
135
145
  return this._mainWidgetLoaded.promise;
136
146
  }
147
+ /**
148
+ * Getter and setter for the translator.
149
+ */
150
+ get translator() {
151
+ var _a;
152
+ return (_a = this._translator) !== null && _a !== void 0 ? _a : nullTranslator;
153
+ }
154
+ set translator(value) {
155
+ if (value !== this._translator) {
156
+ this._translator = value;
157
+ const trans = value.load('notebook');
158
+ this._leftHandler.closeButton.title = trans.__('Collapse %1 side panel', this._leftHandler.area);
159
+ this._rightHandler.closeButton.title = trans.__('Collapse %1 side panel', this._rightHandler.area);
160
+ }
161
+ }
137
162
  /**
138
163
  * Activate a widget in its area.
139
164
  */
140
165
  activateById(id) {
141
166
  // Search all areas that can have widgets for this widget, starting with main.
142
167
  for (const area of ['main', 'top', 'left', 'right', 'menu']) {
143
- const widget = find(this.widgets(area), w => w.id === id);
168
+ const widget = find(this.widgets(area), (w) => w.id === id);
144
169
  if (widget) {
145
170
  if (area === 'left') {
146
171
  this.expandLeft(id);
@@ -197,14 +222,14 @@ export class NotebookShell extends Widget {
197
222
  */
198
223
  collapseTop() {
199
224
  this._topWrapper.setHidden(true);
200
- this._spacer.setHidden(true);
225
+ this._spacer_top.setHidden(true);
201
226
  }
202
227
  /**
203
228
  * Expand the top area to show the header and the spacer.
204
229
  */
205
230
  expandTop() {
206
231
  this._topWrapper.setHidden(false);
207
- this._spacer.setHidden(false);
232
+ this._spacer_top.setHidden(false);
208
233
  }
209
234
  /**
210
235
  * Return the list of widgets for the given area.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/application",
3
- "version": "7.0.0-alpha.9",
3
+ "version": "7.0.0-beta.0",
4
4
  "description": "Jupyter Notebook - Application",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -35,7 +35,6 @@
35
35
  "build:test": "tsc --build tsconfig.test.json",
36
36
  "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
37
37
  "docs": "typedoc src",
38
- "prepublishOnly": "npm run build",
39
38
  "test": "jest",
40
39
  "test:cov": "jest --collect-coverage",
41
40
  "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
@@ -43,27 +42,27 @@
43
42
  "watch": "tsc -b --watch"
44
43
  },
45
44
  "dependencies": {
46
- "@jupyterlab/application": "^4.0.0-alpha.16",
47
- "@jupyterlab/coreutils": "^6.0.0-alpha.16",
48
- "@jupyterlab/docregistry": "^4.0.0-alpha.16",
49
- "@jupyterlab/rendermime-interfaces": "^3.8.0-alpha.16",
50
- "@jupyterlab/ui-components": "^4.0.0-alpha.31",
51
- "@lumino/algorithm": "^2.0.0-alpha.6",
52
- "@lumino/coreutils": "^2.0.0-alpha.6",
53
- "@lumino/messaging": "^2.0.0-alpha.6",
54
- "@lumino/polling": "^2.0.0-alpha.6",
55
- "@lumino/signaling": "^2.0.0-alpha.6",
56
- "@lumino/widgets": "^2.0.0-alpha.6"
45
+ "@jupyterlab/application": "^4.0.0-beta.0",
46
+ "@jupyterlab/coreutils": "^6.0.0-beta.0",
47
+ "@jupyterlab/docregistry": "^4.0.0-beta.0",
48
+ "@jupyterlab/rendermime-interfaces": "^3.8.0-beta.0",
49
+ "@jupyterlab/ui-components": "^4.0.0-beta.0",
50
+ "@lumino/algorithm": "^2.0.0",
51
+ "@lumino/coreutils": "^2.0.0",
52
+ "@lumino/messaging": "^2.0.0",
53
+ "@lumino/polling": "^2.0.0",
54
+ "@lumino/signaling": "^2.0.0",
55
+ "@lumino/widgets": "^2.0.1"
57
56
  },
58
57
  "devDependencies": {
59
58
  "@babel/core": "^7.11.6",
60
59
  "@babel/preset-env": "^7.12.1",
61
- "@jupyterlab/testutils": "^4.0.0-alpha.16",
62
- "@types/jest": "^26.0.10",
63
- "jest": "^26.4.2",
60
+ "@jupyterlab/testutils": "^4.0.0-beta.0",
61
+ "@types/jest": "^29.2.5",
62
+ "jest": "^29.3.1",
64
63
  "rimraf": "^3.0.2",
65
- "ts-jest": "^26.3.0",
66
- "typescript": "~4.7.3"
64
+ "ts-jest": "^29.0.3",
65
+ "typescript": "~5.0.2"
67
66
  },
68
67
  "publishConfig": {
69
68
  "access": "public"
package/style/base.css CHANGED
@@ -59,24 +59,33 @@ body {
59
59
  }
60
60
 
61
61
  #main-panel {
62
- box-shadow: var(--jp-elevation-z4);
63
62
  margin-left: auto;
64
63
  margin-right: auto;
65
64
  max-width: var(--jp-notebook-max-width);
66
65
  }
67
66
 
68
- #spacer-widget {
67
+ #spacer-widget-top {
68
+ min-height: 16px;
69
+ }
70
+
71
+ /* Only edit pages should have a bottom space */
72
+
73
+ body[data-notebook='edit'] #spacer-widget-bottom {
69
74
  min-height: 16px;
70
75
  }
71
76
 
72
77
  /* Special case notebooks as document oriented pages */
73
78
 
79
+ [data-notebook]:not(body[data-notebook='notebooks']) #main-panel {
80
+ box-shadow: var(--jp-elevation-z4);
81
+ }
82
+
74
83
  body[data-notebook='notebooks'] #main-panel {
75
84
  margin-left: unset;
76
85
  margin-right: unset;
77
86
  max-width: unset;
78
87
  }
79
88
 
80
- body[data-notebook='notebooks'] #spacer-widget {
89
+ body[data-notebook='notebooks'] #spacer-widget-top {
81
90
  min-height: unset;
82
91
  }