import { Generic } from "cmf.core/src/core"; /** * Layout base definition. * Component data classes should extend from this */ export declare abstract class LayoutBaseDef { } /** * Layout base definition to save layouts */ export declare class InternalLayoutBaseDef { uniqueId: string; layout?: LayoutBaseDef; children?: InternalLayoutBaseDef[]; } /** * Handles events to load/save personalized layouts */ export interface OnLayout { /** * This is called if component has an available layout that should be loaded */ onLoadLayout(layoutDef: LayoutBaseDef): Promise; /** * This is called if component has an available layout to be saved */ onSaveLayout(): Promise; } /** * Allows extension of onLoadLayout and onSaveLayout operations * Use to override default behavior * (Exposes tree details such as uniqueId and children) */ export interface OnExtendedLayout { /** * This is called if component has an available layout that should be loaded * (If layoutDef is null, layout was reset or there is no layout to load) */ onLoadExtendedLayout(layoutDef: InternalLayoutBaseDef): Promise; /** * This is called if component has an available layout to be saved */ onSaveExtendedLayout(): Promise; } /** * (Internal) * Exposes getDefaultLayout */ export interface OnExtendedLayoutInternal extends OnExtendedLayout { /** * Get default layout object for current Layout */ getDefaultLayout(): InternalLayoutBaseDef; /** * True if component where directive is implements OnExtendedLayout * (Useful to know if recursive layout is needed) */ componentImplementsOnExtendedLayout(): boolean; } export declare const DEFAULT_NODE_NAME: string; /** * Layout model */ export declare class LayoutModel extends Generic { private _lastLayoutLoaded; /** * Last global layout loaded (e.g. UIPage layout) */ readonly lastLayoutLoaded: InternalLayoutBaseDef; /** * Layout directive instance */ directiveInstance: OnExtendedLayoutInternal; /** * Component that hosts this model */ component: OnLayout | OnExtendedLayout; /** * Model children */ children: LayoutModel[]; /** * Model parent */ parent?: LayoutModel; private static onSaveLayoutPrivate; /** * Merge array of child layouts into a parent layout * @param layouts Array of layouts to merge * @param parentLayout Parent layout that will contain layouts */ private static mergeLayouts; /** * Build tree node unique names in the form of path (e.g. {index}:{name}/{innerIndex}:{innerName}....) * NOTE: this should run only ONCE after ALL operations * @param tree Layout tree * @param idx Current index */ private static buildIndexes; /** * Build layout tree model for some instance * @param instance LayoutModel instance * @param getResults If true, it will get node current layouts (will call component onSaveLayout) */ private static buildLayoutModel; /** * Load layout for current layout model * @param instance Current layout model * @param layoutToLoad Layout to load */ private static onLoadLayoutPrivate; /** * Reset layout for current layout model * @param instance Current layout model */ private static onResetLayoutPrivate; /** * Recursively build call tree for load layout * @param layoutToLoad Layout data to load (from service) * @param currentLayout Current layout model data, to match node ids * @param instance Current layout model, to call loadLayout for each node */ private static loadNodes; /** * Recursively build call tree for reset layout * @param currentLayout Current layout model data, to match node ids * @param instance Current layout model, to call loadLayout(null) for each node */ private static resetNodes; /** * Layout to load and current layout might be different due to component re-ordering, * so this tries to match a load to load with a list of current existing nodes. * @param nodeToMatch Node to load * @param nodesToSearch Array of nodes to search (current layout) */ private static getMatchedNode; /** * Get unique name for node * @param node Node */ static getUniqueName(nodeUniqueId: string): string; private static getOwnModel; /** * Main instance onSaveLayout method that will call recursive tree nodes saveLayouts */ onSaveLayout(): Promise; /** * Main instance onLoadLayout method that will call recursive tree nodes loadLayouts */ onLoadLayout(layout: InternalLayoutBaseDef): Promise; /** * Get the OnLayout instance own layout model. * @param searchInstance Instance to search for */ getOwnModel(searchInstance: OnExtendedLayout): LayoutModel; }