mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
rename base_widget -> component
This commit is contained in:
@@ -23,8 +23,8 @@ interface Meta<T extends WEnv> {
|
|||||||
isStarted: boolean;
|
isStarted: boolean;
|
||||||
isMounted: boolean;
|
isMounted: boolean;
|
||||||
isDestroyed: boolean;
|
isDestroyed: boolean;
|
||||||
parent: BaseWidget<T, any, any> | null;
|
parent: Component<T, any, any> | null;
|
||||||
children: { [key: number]: BaseWidget<T, any, any> };
|
children: { [key: number]: Component<T, any, any> };
|
||||||
// children mapping: from templateID to widgetID
|
// children mapping: from templateID to widgetID
|
||||||
// should it be a map number => Widget?
|
// should it be a map number => Widget?
|
||||||
cmap: { [key: number]: number };
|
cmap: { [key: number]: number };
|
||||||
@@ -40,7 +40,7 @@ export interface Type<T> extends Function {
|
|||||||
// Widget
|
// Widget
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
export class BaseWidget<
|
export class Component<
|
||||||
T extends WEnv,
|
T extends WEnv,
|
||||||
Props,
|
Props,
|
||||||
State extends {}
|
State extends {}
|
||||||
@@ -57,14 +57,14 @@ export class BaseWidget<
|
|||||||
state: State = <State>{};
|
state: State = <State>{};
|
||||||
props: Props;
|
props: Props;
|
||||||
refs: {
|
refs: {
|
||||||
[key: string]: BaseWidget<T, any, any> | HTMLElement | undefined;
|
[key: string]: Component<T, any, any> | HTMLElement | undefined;
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
constructor(parent: BaseWidget<T, any, any> | T, props?: Props) {
|
constructor(parent: Component<T, any, any> | T, props?: Props) {
|
||||||
super();
|
super();
|
||||||
wl.push(this);
|
wl.push(this);
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ export class BaseWidget<
|
|||||||
// Pro: but creating widget (by a template) is always unsafe anyway
|
// Pro: but creating widget (by a template) is always unsafe anyway
|
||||||
this.props = <Props>props;
|
this.props = <Props>props;
|
||||||
let id: number;
|
let id: number;
|
||||||
let p: BaseWidget<T, any, any> | null = null;
|
let p: Component<T, any, any> | null = null;
|
||||||
if (parent instanceof BaseWidget) {
|
if (parent instanceof Component) {
|
||||||
p = parent;
|
p = parent;
|
||||||
this.env = parent.env;
|
this.env = parent.env;
|
||||||
id = this.env.getID();
|
id = this.env.getID();
|
||||||
@@ -259,7 +259,7 @@ export class BaseWidget<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private visitSubTree(callback: (w: BaseWidget<T, any, any>) => boolean) {
|
private visitSubTree(callback: (w: Component<T, any, any>) => boolean) {
|
||||||
const shouldVisitChildren = callback(this);
|
const shouldVisitChildren = callback(this);
|
||||||
if (shouldVisitChildren) {
|
if (shouldVisitChildren) {
|
||||||
const children = this.__widget__.children;
|
const children = this.__widget__.children;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Ajax, IAjax } from "./core/ajax";
|
import { Ajax, IAjax } from "./core/ajax";
|
||||||
import { WEnv } from "./core/base_widget";
|
import { WEnv } from "./core/component";
|
||||||
import {
|
import {
|
||||||
INotificationManager,
|
INotificationManager,
|
||||||
NotificationManager
|
NotificationManager
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Type } from "../core/base_widget";
|
import { Type } from "../core/component";
|
||||||
import { EventBus } from "../core/event_bus";
|
import { EventBus } from "../core/event_bus";
|
||||||
import { Registry } from "../core/registry";
|
import { Registry } from "../core/registry";
|
||||||
import { Widget } from "../widgets/widget";
|
import { Widget } from "../widgets/widget";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BaseWidget } from "../core/base_widget";
|
import { Component } from "../core/component";
|
||||||
import { Env } from "../env";
|
import { Env } from "../env";
|
||||||
|
|
||||||
export class Widget<Props, State> extends BaseWidget<Env, Props, State> {}
|
export class Widget<Props, State> extends Component<Env, Props, State> {}
|
||||||
|
|
||||||
// TODO: move this to PureComponent in core
|
// TODO: move this to PureComponent in core
|
||||||
export class PureWidget<Props, State> extends Widget<Props, State> {
|
export class PureWidget<Props, State> extends Widget<Props, State> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BaseWidget, WEnv } from "../../src/ts/core/base_widget";
|
import { Component, WEnv } from "../../src/ts/core/component";
|
||||||
import { makeTestFixture, makeTestWEnv, normalize } from "../helpers";
|
import { makeTestFixture, makeTestWEnv, normalize } from "../helpers";
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -33,7 +33,7 @@ function nextTick(): Promise<void> {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Widget extends BaseWidget<WEnv, {}, {}> {}
|
class Widget extends Component<WEnv, {}, {}> {}
|
||||||
|
|
||||||
function children(w: Widget): Widget[] {
|
function children(w: Widget): Widget[] {
|
||||||
const childrenMap = w.__widget__.children;
|
const childrenMap = w.__widget__.children;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { QWeb } from "../src/ts/core/qweb_vdom";
|
import { QWeb } from "../src/ts/core/qweb_vdom";
|
||||||
import { idGenerator } from "../src/ts/core/utils";
|
import { idGenerator } from "../src/ts/core/utils";
|
||||||
import { WEnv } from "../src/ts/core/base_widget";
|
import { WEnv } from "../src/ts/core/component";
|
||||||
import { Env } from "../src/ts/env";
|
import { Env } from "../src/ts/env";
|
||||||
import { IAjax, RPCQuery } from "../src/ts/core/ajax";
|
import { IAjax, RPCQuery } from "../src/ts/core/ajax";
|
||||||
import { Registry } from "../src/ts/core/registry";
|
import { Registry } from "../src/ts/core/registry";
|
||||||
|
|||||||
Reference in New Issue
Block a user