import Async from "typescene-async"; import Component from "./Component"; import TextLabelFactory from "./TextLabelFactory"; import Binding from "./Binding"; export declare type ValueOrAsync = T | Async.ObservableValue | PromiseLike | Binding; /** Component factory class: constructor creates and initializes a Component */ export interface ComponentFactory { /** UI component class that this factory was created from*/ target: { new (...args: any[]): T; } & typeof Component; /** Contruct the component with all data contained in this factory */ new (): T; /** Initializes more properties using given values; returns this */ with(initializer: any): this; /** Registers a callback to be invoked for every instance after initialization; callbacks are invoked with the created UI component as its first argument, and a base component (on which .with(...) or .initializeWith(...) was called) as its second argument; returns this */ afterEach(callback: (component: T, factoryBase: Component) => void): this; /** Creates an instance (same as using constructor, but can be chained) */ create(): T; } export declare namespace ComponentFactory { /** A factory initializer element (e.g. control element) */ type SpecElt = ValueOrAsync | TextLabelFactory | Component | typeof Component>; /** A factory initializer element (e.g. control element) or table content */ type SpecEltTCol = ValueOrAsync | TextLabelFactory | Component | typeof Component | string | number>; /** A list of factory initializer elements (e.g. row) */ type SpecList = ValueOrAsync<(SpecElt | null)[]>; /** A list of factory initializer elements (e.g. row) or table content */ type SpecListTCol = ValueOrAsync<(SpecEltTCol | null)[]>; /** A list of factory initializer elements, or a single element */ type SpecEltOrList = ValueOrAsync; /** A list of factory initializer elements, or a single element; or table content */ type SpecEltOrListTCol = ValueOrAsync; /** A list of (lists of) factory initializer elements */ type SpecList2 = ValueOrAsync<(SpecEltOrList | null)[]>; /** A list of (lists of) factory initializer elements or table content */ type SpecList2TCol = ValueOrAsync<(SpecEltOrListTCol | null)[]>; /** Class decorator that uses given initializer specification to initialize every component instance asynchronously (after running the component constructor) */ interface Decorator { (initializer: InitializerT): { (target: { with(initializer: any): ComponentFactory; }): void; }; } } /** *Property/accessor decorator*, designates a static property that contains a factory to be used to initialize every Component instance (through its `.initialize()` method, or automatically just before rendering); the property must be of a ComponentFactory type, i.e. the result of static `.with*(...)` method(s) [decorator] */ export declare function initializer(target: typeof Component, key: string, descriptor?: TypedPropertyDescriptor>): any; export default ComponentFactory;