UNPKG

dockview

Version:

Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support

124 lines (123 loc) 4.66 kB
import { ISplitviewStyles, LayoutPriority, Orientation, Sizing } from '../splitview/core/splitview'; import { Position } from '../dnd/droptarget'; import { LeafNode } from './leafNode'; import { Node } from './types'; import { Event } from '../events'; import { IDisposable } from '../lifecycle'; export declare function indexInParent(element: HTMLElement): number; /** * Find the grid location of a specific DOM element by traversing the parent * chain and finding each child index on the way. * * This will break as soon as DOM structures of the Splitview or Gridview change. */ export declare function getGridLocation(element: HTMLElement): number[]; export declare function getRelativeLocation(rootOrientation: Orientation, location: number[], direction: Position): number[]; export declare function getDirectionOrientation(direction: Position): Orientation; export declare function getLocationOrientation(rootOrientation: Orientation, location: number[]): Orientation; export interface IViewSize { width?: number; height?: number; } export interface IGridView { readonly onDidChange: Event<IViewSize | undefined>; readonly element: HTMLElement; readonly minimumWidth: number; readonly maximumWidth: number; readonly minimumHeight: number; readonly maximumHeight: number; priority?: LayoutPriority; layout(width: number, height: number): void; toJSON(): object; fromJSON?(json: object): void; snap?: boolean; setVisible?(visible: boolean): void; } export declare const orthogonal: (orientation: Orientation) => Orientation; export interface GridLeafNode<T extends IGridView> { readonly view: T; readonly cachedVisibleSize: number | undefined; readonly box: { width: number; height: number; }; } export interface GridBranchNode<T extends IGridView> { readonly children: GridNode<T>[]; readonly box: { width: number; height: number; }; } export declare type GridNode<T extends IGridView> = GridLeafNode<T> | GridBranchNode<T>; export declare function isGridBranchNode<T extends IGridView>(node: GridNode<T>): node is GridBranchNode<T>; export interface SerializedGridObject<T> { type: 'leaf' | 'branch'; data: T | SerializedGridObject<T>[]; size?: number; visible?: boolean; } export interface ISerializedLeafNode { type: 'leaf'; data: any; size: number; visible?: boolean; } export interface ISerializedBranchNode { type: 'branch'; data: ISerializedNode[]; size: number; } export declare type ISerializedNode = ISerializedLeafNode | ISerializedBranchNode; export interface INodeDescriptor { node: Node; visible?: boolean; } export interface IViewDeserializer { fromJSON: (data: ISerializedLeafNode) => IGridView; } export declare class Gridview implements IDisposable { readonly proportionalLayout: boolean; readonly styles: ISplitviewStyles | undefined; private _root; readonly element: HTMLElement; private disposable; private readonly _onDidChange; readonly onDidChange: Event<number | undefined>; serialize(): { root: SerializedGridObject<any>; width: number; height: number; orientation: Orientation; }; dispose(): void; clear(): void; deserialize(json: any, deserializer: IViewDeserializer): void; private _deserialize; private _deserializeNode; get orientation(): Orientation; set orientation(orientation: Orientation); private get root(); private set root(value); next(location: number[]): LeafNode; previous(location: number[]): LeafNode; getView(): GridBranchNode<IGridView>; getView(location?: number[]): GridNode<IGridView>; private _getViews; private progmaticSelect; get width(): number; get height(): number; get minimumWidth(): number; get minimumHeight(): number; get maximumWidth(): number; get maximumHeight(): number; constructor(proportionalLayout: boolean, styles: ISplitviewStyles | undefined, orientation: Orientation); isViewVisible(location: number[]): boolean; setViewVisible(location: number[], visible: boolean): void; moveView(parentLocation: number[], from: number, to: number): void; addView(view: IGridView, size: number | Sizing, location: number[]): void; remove(view: IGridView, sizing?: Sizing): IGridView; removeView(location: number[], sizing?: Sizing): IGridView; layout(width: number, height: number): void; private getNode; }