import { ComponentConstructor, FallbackHandler, HigherOrderComponent } from "./types"; import * as GoldenLayout from "golden-layout"; import * as React from "react"; /** * Class that manages an association between string identifiers and the * corresponding React components or component factory functions. * * This is used by the workbench so that it can refer to components with * symbolic names (strings) instead of serializing the components themselves * in state objects. */ export declare class ComponentRegistry { private _data; /** * Fallback component or function that is used to resolve errors when the * user tries to create a component that is not registered in the registry. * The function will be called with the registered name of the component that * the user tried to create and its props, and it must return a React node * to render as fallback. */ fallback: FallbackHandler | undefined; /** * Constructor. Creates a registry with the default registrations that are * needed for Golden-Layout to work. * * @param fallback fallback component handler that creates a component * when the original component handler fails */ constructor(); /** * Returns the React component or factory function corresponding to the * given name in the registry. * * @param name the name whose corresponding React component or factory * function is being searched * @return the factory function or React component that was registered with * the given name, or undefined if the given name does not correspond * to a factory function or React component */ find(name: string): ComponentConstructor | React.ComponentType | undefined; /** * Returns the registered name of the given function or React component in * the registry. * * @param factory the factory function or React component whose registered * name is to be retrieved * @return the name corresponding to the input or undefined if * there is no such function or React component */ findRegisteredNameFor(factory: ComponentConstructor | React.ComponentType): string | undefined; /** * Returns the registered factory function for the given name. * * @param name the name whose corresponding factory function is being * searched * @return the factory function that was registered with the given name, or * undefined if the given name does not correspond to a factory * function */ findRegisteredFactoryFor(name: string): ComponentConstructor | undefined; /** * Returns the registered React component for the given name. * * @param name the name whose corresponding React component is being * searched * @return the React component that was registered with the given name, or * undefined if the given name does not correspond to a React * component */ findRegisteredReactComponentFor(name: string): React.ComponentType | undefined; /** * Returns whether a plain component factory or a React component is registered * with the given name. */ isRegistered(name: string): boolean; /** * Returns whether a React component is registered with the given name. */ isRegisteredAsReact(name: string): boolean; /** * Registers a new plain component factory in the registry with the given * name. * * Chances are that you need this function only if you are not using React. * For React components, use registerComponent() instead. * * In case you wonder: the two functions cannot be unified because React * functional components cannot be distinguished from factory functions. * * @param name the name of the factory to register. Can be omitted. * @param factory the factory function to register. It will be invoked with * the layout container and the state object of the component * and must update the contents of the container. * @return the name that the factory function was registered for */ register(name: string, factory?: undefined): (newFactory: ComponentConstructor) => void; register(factory: ComponentConstructor): string; register(name: string, factory: ComponentConstructor): string; /** * Registers a new React component for the workbench with the given name. * * @param name the name of the component that the React component will be * known as. This can be omitted; defaults to the actual name * of the component. * @param component the React component class or stateless functional * component to register. Its props will be set to the * props specified in the golden-layout * configuration object. * @return the name that the component was registered for */ registerComponent(name: string, component?: undefined): (newComponent: React.ComponentType) => string; registerComponent(component: React.ComponentType): string; registerComponent(name: string, component: React.ComponentType): string; /** * Prepares a GoldenLayout layout object such that it knows about all the * components registered in this registry. * * @param layout the layout object to prepare * @param hoc an optional higher-order component that will be called on * all the React components being registered; it can be used to * provide context or default props to all registered components */ prepareLayout(layout: GoldenLayout, hoc?: HigherOrderComponent): void; /** * Handles the case when a component in the workbench cannot be created * for any reason (for instance, missing component registration). */ private _handleComponentCreationFailure; }