Files
owl/src/component/component.ts
T

43 lines
930 B
TypeScript
Raw Normal View History

2020-11-26 16:45:25 +01:00
import type { ComponentNode } from "./component_node";
2019-03-14 09:03:39 +01:00
2020-11-26 16:45:25 +01:00
// -----------------------------------------------------------------------------
// 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> {
2020-11-26 16:45:25 +01:00
static template: string = "";
2021-11-19 14:35:25 +01:00
static props?: any;
static defaultProps?: any;
2019-01-31 13:19:30 +01:00
props: Props;
env: Env;
2020-11-26 16:45:25 +01:00
__owl__: ComponentNode;
constructor(props: Props, env: Env, node: ComponentNode) {
2020-11-26 16:45:25 +01:00
this.props = props;
this.env = env;
this.__owl__ = node;
}
2019-01-16 13:19:58 +01:00
2020-10-30 09:33:49 +01:00
setup() {}
render() {
this.__owl__.render();
2020-10-27 14:41:09 +01:00
}
}