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
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2019-05-08 11:23:48 +02:00
|
|
|
|
2022-01-27 14:28:01 +01:00
|
|
|
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;
|
|
|
|
|
|
2022-01-17 10:18:45 +01:00
|
|
|
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;
|
2022-01-27 14:28:01 +01:00
|
|
|
static defaultProps?: any;
|
2019-01-31 13:19:30 +01:00
|
|
|
|
2022-01-17 10:18:45 +01:00
|
|
|
props: Props;
|
2021-11-15 13:10:09 +01:00
|
|
|
env: Env;
|
2020-11-26 16:45:25 +01:00
|
|
|
__owl__: ComponentNode;
|
2019-11-28 12:11:57 +01:00
|
|
|
|
2022-01-17 10:18:45 +01:00
|
|
|
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-26 08:40:09 +01:00
|
|
|
}
|
2019-01-16 13:19:58 +01:00
|
|
|
|
2020-10-30 09:33:49 +01:00
|
|
|
setup() {}
|
|
|
|
|
|
2021-11-29 16:02:51 +01:00
|
|
|
render() {
|
|
|
|
|
this.__owl__.render();
|
2020-10-27 14:41:09 +01:00
|
|
|
}
|
|
|
|
|
}
|