Files
owl/src/component/component.ts
T
2022-02-11 10:46:44 +01:00

43 lines
930 B
TypeScript

import type { ComponentNode } from "./component_node";
// -----------------------------------------------------------------------------
// Component Class
// -----------------------------------------------------------------------------
type Props = { [key: string]: any };
interface StaticComponentProperties {
template: string;
defaultProps?: any;
props?: any;
}
export type ComponentConstructor<P extends Props = any, E = any> = (new (
props: P,
env: E,
node: ComponentNode
) => Component<P, E>) &
StaticComponentProperties;
export class Component<Props = any, Env = any> {
static template: string = "";
static props?: any;
static defaultProps?: any;
props: Props;
env: Env;
__owl__: ComponentNode;
constructor(props: Props, env: Env, node: ComponentNode) {
this.props = props;
this.env = env;
this.__owl__ = node;
}
setup() {}
render() {
this.__owl__.render();
}
}