react-mosaic-component2
Version:
A React Tiling Window Manager
55 lines (52 loc) • 1.74 kB
TypeScript
import { Spec } from 'immutability-helper';
/**
* Valid node types
* @see React.Key
*/
type MosaicKey = string | number;
/**
* Base type for the Mosaic binary tree
*/
type MosaicNode<T extends MosaicKey> = MosaicParent<T> | T;
/**
* Row means each window is side-by-side
*/
type MosaicDirection = 'row' | 'column';
interface MosaicParent<T extends MosaicKey> {
direction: MosaicDirection;
first: MosaicNode<T>;
second: MosaicNode<T>;
splitPercentage?: number;
}
type MosaicBranch = 'first' | 'second';
type MosaicPath = MosaicBranch[];
/**
* Used by many utility methods to update the tree.
* spec will be passed to https://github.com/kolodny/immutability-helper
*/
type MosaicUpdateSpec<T extends MosaicKey> = Spec<MosaicNode<T>>;
interface MosaicUpdate<T extends MosaicKey> {
path: MosaicPath;
spec: MosaicUpdateSpec<T>;
}
/**
* Mosaic needs a way to resolve `MosaicKey` into react elements for display.
* This provides a way to render them.
*/
type TileRenderer<T extends MosaicKey> = (t: T, path: MosaicBranch[]) => JSX.Element;
/**
* Function that provides a new node to put into the tree
*/
type CreateNode<T extends MosaicKey> = (...args: any[]) => Promise<MosaicNode<T>> | MosaicNode<T>;
/**
* Used by `react-dnd`
* @type {{WINDOW: string}}
*/
declare const MosaicDragType: {
WINDOW: string;
};
interface EnabledResizeOptions {
minimumPaneSizePercentage?: number;
}
type ResizeOptions = 'DISABLED' | EnabledResizeOptions;
export { type CreateNode, type EnabledResizeOptions, type MosaicBranch, type MosaicDirection, MosaicDragType, type MosaicKey, type MosaicNode, type MosaicParent, type MosaicPath, type MosaicUpdate, type MosaicUpdateSpec, type ResizeOptions, type TileRenderer };