import { DropInfo } from "./DropInfo"; import { Action } from "./Actions"; import { BorderSet } from "./BorderSet"; import { IBorderTabDirection, IJsonModel, ITabGroupType, ITabSetAttributes } from "./IJsonModel"; import { Node } from "./Node"; import { RowNode } from "./RowNode"; import { TabNode } from "./TabNode"; import { TabSetNode } from "./TabSetNode"; /** * A change listener that observes the model around each action. Register it with * `Model.addChangeListener`. Both callbacks are optional; `onBeforeAction` is called with the * action before the model applies it (useful for cheap snapshots), `onAfterAction` after it * has been applied. */ export interface ModelChangeListener { /** called with the action before the model applies it */ onBeforeAction?: (action: Action) => void; /** called with the action after the model has applied it */ onAfterAction?: (action: Action) => void; } /** * Class containing the Tree of Nodes used by the FlexLayout component */ export declare class Model { static MAIN_LAYOUT_ID: string; /** * Pairs the global attribute definitions with the node attribute definitions so that an * inherited node attribute can resolve its type/description/default from the global * attribute it maps to (and vice versa), e.g. tabEnableClose <-> enableClose. Idempotent; * called automatically when the definitions are accessed. */ static ensureAttributePairing(): void; /** * Update the node tree by performing the given action, * Actions should be generated via static methods on the Actions class * @param action the action to perform * @returns added Node for Actions.addTab, layoutId for createPopout */ doAction(action: Action): any; /** * Get the currently active tabset node */ getActiveTabset(layoutId?: string): TabSetNode | undefined; /** * Get the currently maximized tabset node */ getMaximizedTabset(layoutId?: string): TabSetNode | undefined; /** * Gets the root RowNode of the model * @returns {RowNode} */ getRootRow(layoutId?: string): RowNode | undefined; isRootOrientationVertical(): boolean; isEnableRotateBorderIcons(): boolean; getBorderLeftTabDirection(): IBorderTabDirection; getTabGroupType(): ITabGroupType; /** * Gets the * @returns {BorderSet|*} */ getBorderSet(): BorderSet; /** * Visits all the nodes in the model and calls the given function for each * @param fn a function that takes visited node and a integer level as parameters */ visitNodes(fn: (node: Node, level: number) => void): void; visitLayoutNodes(layoutId: string, fn: (node: Node, level: number) => void): void; /** * Gets a node by its id * @param id the id to find */ getNodeById(id: string): Node | undefined; /** * Finds the first/top left tab set of the given node. * @param node The top node you want to begin searching from, deafults to the root node * @returns The first Tab Set */ getFirstTabSet(node?: Node | undefined): TabSetNode | undefined; /** * Load a model from JSON. * @param previousModel optional; when given, matching tabs adopt its view state (no remount). */ static fromJson(json: IJsonModel, previousModel?: Model): Model; /** * Converts the model to a json object * @returns {IJsonModel} json object that represents this model */ toJson(): IJsonModel; getSplitterSize(): number | undefined; isEnableEdgeDock(): boolean; isEnableEdgeDockIndicators(): boolean; /** * Sets a function to allow/deny dropping a node * @param onAllowDrop function that takes the drag node and DropInfo and returns true if the drop is allowed */ setOnAllowDrop(onAllowDrop: (dragNode: Node, dropInfo: DropInfo) => boolean): void; /** * set callback called when a new TabSet is created. * The tabNode can be undefined if it's the auto created first tabset in the root row (when the last * tab is deleted, the root tabset can be recreated) * @param onCreateTabSet */ setOnCreateTabSet(onCreateTabSet: (tabNode?: TabNode) => ITabSetAttributes): void; /** * Register a change listener (ModelChangeListener or legacy function). * Fires for every action, including direct `model.doAction` calls. */ addChangeListener(listener: ModelChangeListener | ((action: Action) => void)): void; /** * Removes a listener previously registered with `addChangeListener` (either a function or a * `ModelChangeListener` object) * @param listener the listener to remove */ removeChangeListener(listener: ModelChangeListener | ((action: Action) => void)): void; toString(): string; }