Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@lumino/widgets

Package Overview
Dependencies
Maintainers
6
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lumino/widgets - npm Package Compare versions

Comparing version 1.32.0 to 1.32.1

2

package.json
{
"name": "@lumino/widgets",
"version": "1.32.0",
"version": "1.32.1",
"description": "Lumino Widgets",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/jupyterlab/lumino",

@@ -139,2 +139,74 @@ // Copyright (c) Jupyter Development Team.

/**
* Compute the size of widgets in this panel on the title click event.
* On closing, the size of the widget is cached and we will try to expand
* the last opened widget.
* On opening, we will use the cached size if it is available to restore the
* widget.
* In both cases, if we can not compute the size of widgets, we will let
* `SplitLayout` decide.
*
* @param index - The index of widget to be opened of closed
*
* @returns Relative size of widgets in this panel, if this size can
* not be computed, return `undefined`
*/
private _computeWidgetSize(index: number): number[] | undefined {
const layout = this.layout as AccordionLayout;
const widget = layout.widgets[index];
if (!widget) {
return undefined;
}
const isHidden = widget.isHidden;
const widgetSizes = layout.absoluteSizes();
const delta = (isHidden ? -1 : 1) * this.spacing;
const totalSize = widgetSizes.reduce(
(prev: number, curr: number) => prev + curr
);
let newSize = [...widgetSizes];
if (!isHidden) {
// Hide the widget
const currentSize = widgetSizes[index];
this._widgetSizesCache.set(widget, currentSize);
newSize[index] = 0;
const widgetToCollapse = newSize.map(sz => sz > 0).lastIndexOf(true);
if (widgetToCollapse === -1) {
// All widget are closed, let the `SplitLayout` compute widget sizes.
return undefined;
}
newSize[widgetToCollapse] =
widgetSizes[widgetToCollapse] + currentSize + delta;
} else {
// Show the widget
const previousSize = this._widgetSizesCache.get(widget);
if (!previousSize) {
// Previous size is unavailable, let the `SplitLayout` compute widget sizes.
return undefined;
}
newSize[index] += previousSize;
const widgetToCollapse = newSize
.map(sz => sz - previousSize > 0)
.lastIndexOf(true);
if (widgetToCollapse === -1) {
// Can not reduce the size of one widget, reduce all opened widgets
// proportionally with its size.
newSize.forEach((_, idx) => {
if (idx !== index) {
newSize[idx] -=
(widgetSizes[idx] / totalSize) * (previousSize - delta);
}
});
} else {
newSize[widgetToCollapse] -= previousSize - delta;
}
}
return newSize.map(sz => sz / (totalSize + delta));
}
/**
* Handle the `'click'` event for the accordion panel

@@ -153,5 +225,10 @@ */

event.stopPropagation();
const title = this.titles[index];
const widget = (this.layout as AccordionLayout).widgets[index];
const newSize = this._computeWidgetSize(index);
if (newSize) {
this.setRelativeSizes(newSize, false);
}
if (widget.isHidden) {

@@ -223,2 +300,4 @@ title.classList.add('lm-mod-expanded');

}
private _widgetSizesCache: WeakMap<Widget, number> = new WeakMap();
}

@@ -225,0 +304,0 @@

@@ -161,2 +161,13 @@ // Copyright (c) Jupyter Development Team.

/**
* Get the absolute sizes of the widgets in the layout.
*
* @returns A new array of the absolute sizes of the widgets.
*
* This method **does not** measure the DOM nodes.
*/
absoluteSizes(): number[] {
return this._sizers.map(sizer => sizer.size);
}
/**
* Get the relative sizes of the widgets in the layout.

@@ -180,2 +191,4 @@ *

* @param sizes - The relative sizes for the widgets in the panel.
* @param update - Update the layout after setting relative sizes.
* Default is True.
*

@@ -187,3 +200,3 @@ * #### Notes

*/
setRelativeSizes(sizes: number[]): void {
setRelativeSizes(sizes: number[], update = true): void {
// Copy the sizes and pad with zeros as needed.

@@ -210,3 +223,3 @@ let n = this._sizers.length;

// Trigger an update of the parent widget.
if (this.parent) {
if (update && this.parent) {
this.parent.update();

@@ -213,0 +226,0 @@ }

@@ -148,2 +148,4 @@ // Copyright (c) Jupyter Development Team.

* @param sizes - The relative sizes for the widgets in the panel.
* @param update - Update the layout after setting relative sizes.
* Default is True.
*

@@ -155,4 +157,4 @@ * #### Notes

*/
setRelativeSizes(sizes: number[]): void {
(this.layout as SplitLayout).setRelativeSizes(sizes);
setRelativeSizes(sizes: number[], update = true): void {
(this.layout as SplitLayout).setRelativeSizes(sizes, update);
}

@@ -159,0 +161,0 @@

@@ -79,2 +79,17 @@ import { Message } from '@lumino/messaging';

/**
* Compute the size of widgets in this panel on the title click event.
* On closing, the size of the widget is cached and we will try to expand
* the last opened widget.
* On opening, we will use the cached size if it is available to restore the
* widget.
* In both cases, if we can not compute the size of widgets, we will let
* `SplitLayout` decide.
*
* @param index - The index of widget to be opened of closed
*
* @returns Relative size of widgets in this panel, if this size can
* not be computed, return `undefined`
*/
private _computeWidgetSize;
/**
* Handle the `'click'` event for the accordion panel

@@ -87,2 +102,3 @@ */

private _eventKeyDown;
private _widgetSizesCache;
}

@@ -89,0 +105,0 @@ /**

@@ -60,2 +60,10 @@ import { Message } from '@lumino/messaging';

/**
* Get the absolute sizes of the widgets in the layout.
*
* @returns A new array of the absolute sizes of the widgets.
*
* This method **does not** measure the DOM nodes.
*/
absoluteSizes(): number[];
/**
* Get the relative sizes of the widgets in the layout.

@@ -76,2 +84,4 @@ *

* @param sizes - The relative sizes for the widgets in the panel.
* @param update - Update the layout after setting relative sizes.
* Default is True.
*

@@ -83,3 +93,3 @@ * #### Notes

*/
setRelativeSizes(sizes: number[]): void;
setRelativeSizes(sizes: number[], update?: boolean): void;
/**

@@ -86,0 +96,0 @@ * Move the offset position of a split handle.

@@ -84,2 +84,4 @@ import { Message } from '@lumino/messaging';

* @param sizes - The relative sizes for the widgets in the panel.
* @param update - Update the layout after setting relative sizes.
* Default is True.
*

@@ -91,3 +93,3 @@ * #### Notes

*/
setRelativeSizes(sizes: number[]): void;
setRelativeSizes(sizes: number[], update?: boolean): void;
/**

@@ -94,0 +96,0 @@ * Handle the DOM events for the split panel.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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