Socket
Socket
Sign inDemoInstall

@jupyterlab/ui-components

Package Overview
Dependencies
Maintainers
10
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlab/ui-components - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

2

lib/components/toolbar.d.ts

@@ -198,4 +198,4 @@ import { ITranslator } from '@jupyterlab/translation';

protected readonly popupOpener: ToolbarPopupOpener;
private readonly _resizer;
private readonly _widgetWidths;
private readonly _resizer;
private _widgetPositions;

@@ -202,0 +202,0 @@ private _zoom;

@@ -331,3 +331,3 @@ // Copyright (c) Jupyter Development Team.

this.popupOpener = new ToolbarPopupOpener();
this._widgetWidths = {};
this._widgetWidths = new Map();
this._widgetPositions = new Map();

@@ -339,3 +339,3 @@ this._zoomChanged = true;

await this._onResize(callTwice);
}, 300);
}, 500);
}

@@ -383,7 +383,2 @@ /**

const position = (targetPosition !== null && targetPosition !== void 0 ? targetPosition : 0) + offset;
this._widgetPositions.forEach((value, key) => {
if (key !== TOOLBAR_OPENER_NAME && value >= position) {
this._widgetPositions.set(key, value + 1);
}
});
return this.insertItem(position, name, widget);

@@ -408,2 +403,3 @@ }

insertItem(index, name, widget) {
var _a;
let status;

@@ -417,6 +413,25 @@ if (widget instanceof ToolbarPopupOpener) {

}
// Save the widgets position when a new widget is inserted.
// Save the widgets position when a widget is inserted or moved.
if (name !== TOOLBAR_OPENER_NAME &&
this._widgetPositions.get(name) === undefined) {
this._widgetPositions.get(name) !== index) {
// If the widget is inserted, set its current position as last.
const currentPosition = (_a = this._widgetPositions.get(name)) !== null && _a !== void 0 ? _a : this._widgetPositions.size;
// Change the position of moved widgets.
this._widgetPositions.forEach((value, key) => {
if (key !== TOOLBAR_OPENER_NAME) {
if (value >= index && value < currentPosition) {
this._widgetPositions.set(key, value + 1);
}
else if (value <= index && value > currentPosition) {
this._widgetPositions.set(key, value - 1);
}
}
});
// Save the new position of the widget.
this._widgetPositions.set(name, index);
// Invokes resizing to ensure correct display of items after an addition, only
// if the toolbar is rendered.
if (this.isVisible) {
void this._onResize();
}
}

@@ -472,3 +487,3 @@ return status;

const opener = this.popupOpener;
const openerWidth = 30;
const openerWidth = 32;
// left and right padding.

@@ -479,11 +494,23 @@ const toolbarPadding = 2 + 5;

.then(values => {
var _a;
var _a, _b;
let { width, widgetsToRemove } = values;
while (widgetsToRemove.length > 0) {
// Insert the widget in the right position in the opener popup.
// Insert the widget at the right position in the opener popup, relatively
// to the saved position of the first item of the popup toolbar.
// Get the saved position of the widget to insert.
const widget = widgetsToRemove.pop();
const name = Private.nameProperty.get(widget);
width -= this._widgetWidths[name];
width -= this._widgetWidths.get(name) || 0;
const position = (_a = this._widgetPositions.get(name)) !== null && _a !== void 0 ? _a : 0;
const index = opener.widgetCount() + position - this._widgetPositions.size;
// Get the saved position of the first item in the popup toolbar.
// If there is no widget, set the value at last item.
let openerFirstIndex = this._widgetPositions.size;
const openerFirst = opener.widgetAt(0);
if (openerFirst) {
const openerFirstName = Private.nameProperty.get(openerFirst);
openerFirstIndex =
(_b = this._widgetPositions.get(openerFirstName)) !== null && _b !== void 0 ? _b : openerFirstIndex;
}
// Insert the widget in the popup toolbar.
const index = position - openerFirstIndex;
opener.insertWidget(index, widget);

@@ -542,2 +569,3 @@ }

async _getWidgetsToRemove(width, toolbarWidth, openerWidth) {
var _a;
const opener = this.popupOpener;

@@ -550,2 +578,3 @@ const layout = this.layout;

const widget = layout.widgets[index];
const name = Private.nameProperty.get(widget);
// Compute the widget size only if

@@ -556,3 +585,3 @@ // - the zoom has changed.

if (this._zoomChanged) {
widgetWidth = await this._saveWidgetWidth(widget);
widgetWidth = await this._saveWidgetWidth(name, widget);
}

@@ -563,3 +592,4 @@ else {

widgetWidth =
this._getWidgetWidth(widget) || (await this._saveWidgetWidth(widget));
this._getWidgetWidth(widget) ||
(await this._saveWidgetWidth(name, widget));
}

@@ -572,3 +602,8 @@ width += widgetWidth;

}
if (width > toolbarWidth) {
// Remove the widget if it is out of the toolbar or incorrectly positioned.
// Incorrect positioning can occur when the widget is added after the toolbar
// has been rendered and should be in the popup. E.g. debugger icon with a
// narrow notebook toolbar.
if (width > toolbarWidth ||
((_a = this._widgetPositions.get(name)) !== null && _a !== void 0 ? _a : 0) > index) {
widgetsToRemove.push(widget);

@@ -584,11 +619,10 @@ }

}
async _saveWidgetWidth(widget) {
async _saveWidgetWidth(name, widget) {
if (widget instanceof ReactWidget) {
await widget.renderPromise;
}
const widgetName = Private.nameProperty.get(widget);
const widgetWidth = widget.hasClass(TOOLBAR_SPACER_CLASS)
? 2
: widget.node.clientWidth;
this._widgetWidths[widgetName] = widgetWidth;
this._widgetWidths.set(name, widgetWidth);
return widgetWidth;

@@ -598,3 +632,3 @@ }

const widgetName = Private.nameProperty.get(widget);
return this._widgetWidths[widgetName];
return this._widgetWidths.get(widgetName) || 0;
}

@@ -601,0 +635,0 @@ }

{
"name": "@jupyterlab/ui-components",
"version": "4.1.2",
"version": "4.1.3",
"description": "JupyterLab - UI components written in React",

@@ -46,6 +46,6 @@ "homepage": "https://github.com/jupyterlab/jupyterlab",

"@jupyter/web-components": "^0.15.2",
"@jupyterlab/coreutils": "^6.1.2",
"@jupyterlab/observables": "^5.1.2",
"@jupyterlab/rendermime-interfaces": "^3.9.2",
"@jupyterlab/translation": "^4.1.2",
"@jupyterlab/coreutils": "^6.1.3",
"@jupyterlab/observables": "^5.1.3",
"@jupyterlab/rendermime-interfaces": "^3.9.3",
"@jupyterlab/translation": "^4.1.3",
"@lumino/algorithm": "^2.0.1",

@@ -68,3 +68,3 @@ "@lumino/commands": "^2.2.0",

"devDependencies": {
"@jupyterlab/testing": "^4.1.2",
"@jupyterlab/testing": "^4.1.3",
"@types/jest": "^29.2.0",

@@ -71,0 +71,0 @@ "@types/react": "^18.0.26",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc