UNPKG

@voila-dashboards/jupyterlab-gridstack

Version:

A gridstack-based template for [![voila-gridstack](assets/voila.png)](https://github.com/voila-dashboards/voila).

146 lines (145 loc) 3.96 kB
import { Layout, Widget } from '@lumino/widgets'; import { ISignal } from '@lumino/signaling'; import { Message } from '@lumino/messaging'; import { GridStack, GridStackNode, GridItemHTMLElement } from 'gridstack'; import { GridStackItemWidget } from '../item'; import { DashboardView, DashboardCellView } from '../format'; /** * A gridstack layout to host the visible Notebook's Cells. */ export declare class GridStackLayout extends Layout { /** * Construct a `GridStackLayout`. * * @param info - The `DashboardView` metadata. */ constructor(info: DashboardView); get gridItemChanged(): ISignal<this, GridStackNode[]>; /** * Dispose of the resources held by the widget. */ dispose(): void; /** * Init the gridstack layout */ init(): void; /** * Handle `update-request` messages sent to the widget. */ protected onUpdateRequest(msg: Message): void; /** * Handle `resize-request` messages sent to the widget. */ protected onResize(msg: Message): void; /** * Handle `fit-request` messages sent to the widget. */ protected onFitRequest(msg: Message): void; /** * Create an iterator over the widgets in the layout. * * @returns A new iterator over the widgets in the layout. */ [Symbol.iterator](): IterableIterator<Widget>; /** * Remove a widget from the layout. * * @param widget - The `widget` to remove. */ removeWidget(widget: Widget): void; /** * Get gridstack's items margin. */ get margin(): number; /** * Change gridstack's items margin. * * @param margin - The new margin. */ set margin(margin: number); /** * Get gridstack's cell height. * * @param forcePixel - An optional boolean. */ get cellHeight(): number; /** * Change the gridstack's cell height. * * @param height - The new height. */ set cellHeight(height: number); /** * Get gridstack's number of columns. */ get columns(): number; /** * Change the gridstack's number of columns. * * @param columns - The new number of columns. */ set columns(columns: number); /** * Helper to get access to underlying GridStack object */ get grid(): GridStack; /** * Get the list of `GridStackItem` (Lumino widgets). */ get gridWidgets(): Array<GridStackItemWidget>; /** * Get the list of `GridItemHTMLElement`. */ get gridItems(): GridItemHTMLElement[]; /** * Add new cell to gridstack. * * @param id - The Cell id. * @param item - The cell widget. * @param info - The dashboard cell metadata parameters. */ addGridItem(id: string, item: GridStackItemWidget, info: DashboardCellView): void; /** * Update a cell from gridstack. * * @param id - The Cell id. * @param info - The dashboard cell metadata parameters. */ updateGridItem(id: string, info: DashboardCellView): void; /** * Remove a cell from gridstack. * * @param id - The Cell id. */ removeGridItem(id: string): void; /** * Handle change-event messages sent to from gridstack. */ private _onChange; /** * Handle remove event messages sent from gridstack. */ private _onRemoved; /** * Handle resize event messages sent from gridstack. */ private _onResize; /** * Handle resize-stop event messages in the layout. */ private _onResizeStops; /** * Update background size style to fit new grid parameters */ private _updateBackgroundSize; private _prepareGrid; private _margin; private _cellHeight; private _columns; private _gridHost; private _grid; private _gridItems; private _gridItemChanged; private _helperMessage; private _resizeTimeout; }