import Async from "typescene-async"; import Style from "../Style"; import Animation from "../Animation"; import { MouseEventSignal, KeyEventSignal, FocusEventSignal, DragEventSignal, MouseHandler, KeyHandler, FocusHandler, DragHandler } from "./DOMEvents"; import ComponentRenderOutput, { ComponentRenderSignal, RenderHandler } from "./ComponentRenderOutput"; import { ComponentFactory, ValueOrAsync } from "./ComponentFactory"; /** Component base class for every part of the user interface */ export declare abstract class Component extends Async.ObservableObject { /** Component factory/initializer, applies given (observable) values */ static with: (values: InitializerT) => ComponentFactory; /** Initializes an existing instance with given values; should *not* be used on classes that also contain a static property decorated with `@initializer`; returns this */ initializeWith: (values: Component.Initializer) => this; /** Create a new component (abstract, cannot be used directly) */ constructor(...arg: any[]); /** Force initialization of this component using the factory property marked with the `@initializer` decorator, if any; called automatically just before rendering, but can also be invoked manually at the end of a constructor if needed (e.g. if the initialized properties are required earlier); returns this */ initialize(): this; /** Identifier (optional), can be set on sub components to find them through .getComponentById(...) */ id: string; /** Unique component identifier */ readonly uid: string; /** Encapsulation of inline CSS style (observed) */ readonly style: Style; /** Set to true to hide this component (observed) */ hidden: boolean; /** Default class name(s), defined on class prototype; not observed */ protected _initialStyleClassName: string; /** Promise that resolves to the rendered output when ready */ private _renderedOut; private _resolve_renderedOut; /** Rendered output for this component (observable) */ readonly out: ComponentRenderOutput; /** [implementation] Flag that can be used for duck typing of renderable components */ readonly isRenderableComponent: boolean; /** Becomes true the first time this component is rendered (i.e. when .out is set; not observable, use Rendered signal instead) */ readonly isRendered: boolean; /** Animation(s) to be played during the lifetime of this component on screen */ animations: Component.Animations; /** Play given animation on this component; returns the animation control instance, which can be used to stop the animation manually */ animate(animation: Animation, continuous?: boolean): Animation.AnimationControl; /** Returns an array of directly contained UI components (observable) */ getChildren(): Component[]; /** Returns the nearest matching child element with given ID, if any */ getComponentById(id: string): Component | null; /** Returns all matching child elements of given class (recursively) */ getComponentsByType(componentClass: { new (...p: any[]): C; }): C[]; /** Returns an object containing all current values of input elements (observable) */ getFormValues(result?: {}): any; /** Sets all input values by element name (will not trigger observable) */ setFormValues(values: any): void; /** Observer for .hidden property, only observed when .out is observed */ private _observeHidden; /** Signal emitted after updating DOM (render) */ readonly Rendered: ComponentRenderSignal; /** Signal emitted on click (DOM) */ readonly Click: MouseEventSignal; /** Signal emitted on double-click (DOM) */ readonly DblClick: MouseEventSignal; /** Signal emitted on mouse-down (DOM) */ readonly Press: MouseEventSignal; /** Signal emitted on mouse-over (DOM) for this element or a child element */ readonly MouseOver: MouseEventSignal; /** Signal emitted on mouse-out (DOM) for this element or a child element */ readonly MouseOut: MouseEventSignal; /** Signal emitted when this element or a child element receives focus */ readonly Focus: FocusEventSignal; /** Signal emitted when this element or a child element loses focus */ readonly Blur: FocusEventSignal; /** Signal emitted when a key is pressed (while focused) */ readonly KeyDown: KeyEventSignal; /** Signal emitted when this element or a child element commences a drag operation (e.g following a call to Drag.start) */ readonly DragStart: DragEventSignal; /** Signal emitted when a drag operation hovers over this element or a child element */ readonly DragOver: DragEventSignal; /** Signal emitted when a drag operation leaves this element or a child element */ readonly DragOut: DragEventSignal; /** Signal emitted when this element or a child element is the target of a drop after a drag operation */ readonly DragDrop: DragEventSignal; } export declare namespace Component { /** Specification of which animations to play during the lifetime of a component on screen (can be extended for sub component types) */ interface Animations { /** Played when component is displayed or added to a displayed parent component */ appear?: Animation; /** Played when component is removed from the screen */ disappear?: Animation; /** Played when component is shown (using Style) */ show?: Animation; /** Played when component is hidden (using Style) */ hide?: Animation; [name: string]: Animation | undefined; } } export declare namespace Component { /** Initializer for .with({ ... }) */ interface Initializer { /** Identifier, used to add a component reference to the base component (on which .with(...) or .initializeWith(...) was called) as a property with given identifier */ id?: string; /** Property initializer */ style?: ValueOrAsync