import { Container } from "golden-layout"; import { ComponentFactory } from "./types"; /** * Base class of Golden-layout component handlers for React components. * * This class has two subclasses: EagerReactComponentHandler (which is a * functionally equivalent version of the original React component handler * in Golden-layout, with bugfixes and some extra functionality) and * LazyReactComponentHandler (which delays mounting the component until it * becomes visible). */ export declare class ReactComponentHandler { private _container; private _isOpen; private _originalComponentDidUpdate; private _reactComponentFactory; private _reactComponent; private _reactRootElement; private _reactRoot; private _temporaryClassNameForContainer; private _waitingForContainerAddition; /** * Constructor. * * @param {lm.container.ItemContainer} container the container that * will contain the React component */ constructor(container: Container); /** * Returns the container that the handler is working with. */ protected get container(): Container; /** * Handler that is called internally when we were not able to create * the component factory from the data available to us in the layout * configuration. * * @param componentName name of the component that we have attempted to * create * @return an alternative component factory that should be used in place of * the normal mechanism, or undefined if we should not provide a * component for the user and throw an error instead */ protected handleComponentCreationFailure(_: string): ComponentFactory | undefined; /** * Event handler for the 'destroy' event; unmounts the component from the * DOM if it is still mounted. Also detaches from any relevant events of * the container that we were subscribed to. */ protected onDestroy(): void; /** * Event handler for the 'open' event; mounts the component in the DOM * if it is in a visible tab. */ protected onOpen(): void; /** * Returns whether the component should be mounted, given its current state. */ protected shouldBeMounted(): boolean; /** * Copies and extends the properties array and returns the React element * * @returns the React component instance that will be shown in the layout */ private _createReactComponent; /** * Retrieves the React class from GoldenLayout's registry * * @returns the React class whose instance will be shown in the layout */ private _getReactComponentFactory; /** * Mounts the component to the DOM tree if it should be mounted and it is * not mounted yet. */ private _mount; /** * Renders the component in the DOM tree or forces a re-rendering. * Does nothing if the container is not in the DOM tree. */ private _render; /** * Mounts the component to the DOM tree if it should be mounted and it is * not mounted yet, or unmounts the component if it should not be mounted * and it is mounted. */ protected mountOrUnmountIfNeeded(): void; /** * Callback that is called when the DOM node that will contain the * component itself is added to the DOM tree of the document. */ private _onContainerAdded; /** * Hooks into React's state management and applies the component state * to GoldenLayout * * @param prevProps the previous set of properties for the React component * @param prevState the previous state for the React component * @param snapshot the snapshot taken from the React component before the * current update */ private _onUpdate; private _setReactComponent; /** * Unmounts the component from the DOM tree. This method is called when * the component is hidden or destroyed. It is safe to call this method * even if the component is already unmounted; nothing will happen in this * case. */ private _unmount; /** * Asks the handler to start waiting for the given DOM node to be mounted * to the DOM tree of the document. */ private _waitForContainerAddition; }