hele
Version:
A front-end UI lib.
46 lines (45 loc) • 1.96 kB
TypeScript
import { Props, RawProps } from "./props";
import { Reference } from "./Reference";
export interface ComponentConstructor<P extends RawProps = RawProps, S = any, SS = any> {
new (props: P, context: any): Component<P, S, SS>;
defaultProps: RawProps;
}
export declare type ComponentFactory<P extends RawProps = RawProps> = (props: P, context: any) => any;
export declare type ComponentGetter<P extends RawProps = RawProps, S = any, SS = any> = ComponentConstructor<P, S, SS> | ComponentFactory<P>;
export declare type UpdateRequestCallback<S> = (state: S) => S | void;
export declare abstract class Component<P extends RawProps = RawProps, S = any, SS = any> {
readonly context: any;
constructor(props: P, context: any);
static defaultProps: RawProps;
props: Readonly<P & Props>;
state: S;
refs: Map<string, Reference<Node | Component<RawProps, any, any>>>;
updateRequestCallbacks: UpdateRequestCallback<S>[];
_forceUp: boolean;
abstract render(): any;
toElement(): any;
onWillMount(): void;
onDidMount(): void;
shouldUpdate(oldState: S, newState: S): boolean;
onWillUpdate(newState: S): SS;
onDidUpdate(snapShot: SS): void;
onWillUnmount(): void;
onDidUnmount(): void;
onCaughtError(error: Error): void;
createRef<T extends Node | Component = Node | Component>(name: string): Reference<T>;
requestUpdate(callback: UpdateRequestCallback<S>): this;
update(newState: S extends object ? Partial<S> : S): this;
forceUpdate(newState?: S extends object ? Partial<S> : S): this;
}
export interface FragmentProps {
children: any;
}
export declare const Fragment: ComponentFactory<FragmentProps>;
export interface ContextProps<V = any> {
value: V;
children: any;
}
export declare class Context<V = any> extends Component<ContextProps, V> {
constructor(props: ContextProps<V>, context: any);
render(): any[];
}