From a6bcfac597a22ae3a26f1d528def45a9a0d36497 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 16 Sep 2021 15:58:48 +0200 Subject: [PATCH] rename UIView to IView --- src/platform/web/ui/general/BaseUpdateView.ts | 4 ++-- src/platform/web/ui/general/ListView.ts | 4 ++-- src/platform/web/ui/general/Popup.js | 2 +- src/platform/web/ui/general/TemplateView.ts | 14 +++++++------- src/platform/web/ui/general/types.ts | 2 +- src/platform/web/ui/general/utils.ts | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/platform/web/ui/general/BaseUpdateView.ts b/src/platform/web/ui/general/BaseUpdateView.ts index 623df99a..2eb4d40f 100644 --- a/src/platform/web/ui/general/BaseUpdateView.ts +++ b/src/platform/web/ui/general/BaseUpdateView.ts @@ -15,14 +15,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {IMountArgs, ViewNode, UIView} from "./types"; +import {IMountArgs, ViewNode, IView} from "./types"; export interface IObservableValue { on?(event: "change", handler: (props?: string[]) => void): void; off?(event: "change", handler: (props?: string[]) => void): void; } -export abstract class BaseUpdateView implements UIView { +export abstract class BaseUpdateView implements IView { protected _value: T protected _boundUpdateFromValue: ((props?: string[]) => void) | null diff --git a/src/platform/web/ui/general/ListView.ts b/src/platform/web/ui/general/ListView.ts index 316bb81c..cdfdbf76 100644 --- a/src/platform/web/ui/general/ListView.ts +++ b/src/platform/web/ui/general/ListView.ts @@ -17,7 +17,7 @@ limitations under the License. import {el} from "./html"; import {mountView, insertAt} from "./utils"; import {BaseObservableList as ObservableList} from "../../../../observable/list/BaseObservableList.js"; -import {UIView, IMountArgs} from "./types"; +import {IView, IMountArgs} from "./types"; interface IOptions { list: ObservableList, @@ -29,7 +29,7 @@ interface IOptions { type SubscriptionHandle = () => undefined; -export class ListView implements UIView { +export class ListView implements IView { private _onItemClick?: (childView: V, evt: UIEvent) => void; private _list: ObservableList; diff --git a/src/platform/web/ui/general/Popup.js b/src/platform/web/ui/general/Popup.js index ac5e3160..e630d398 100644 --- a/src/platform/web/ui/general/Popup.js +++ b/src/platform/web/ui/general/Popup.js @@ -169,7 +169,7 @@ export class Popup { return true; } - /* fake UIView api, so it can be tracked by a template view as a subview */ + /* fake IView api, so it can be tracked by a template view as a subview */ root() { return this._fakeRoot; } diff --git a/src/platform/web/ui/general/TemplateView.ts b/src/platform/web/ui/general/TemplateView.ts index 2fb17f86..93dc8172 100644 --- a/src/platform/web/ui/general/TemplateView.ts +++ b/src/platform/web/ui/general/TemplateView.ts @@ -18,7 +18,7 @@ limitations under the License. import { setAttribute, text, isChildren, classNames, TAG_NAMES, HTML_NS, ClassNames, Child} from "./html"; import {mountView} from "./utils"; import {BaseUpdateView, IObservableValue} from "./BaseUpdateView"; -import {IMountArgs, ViewNode, UIView} from "./types"; +import {IMountArgs, ViewNode, IView} from "./types"; function objHasFns(obj: ClassNames): obj is { [className: string]: boolean } { for(const value of Object.values(obj)) { @@ -58,7 +58,7 @@ export class TemplateView extends BaseUpdateView private _bindings?: (() => void)[] = undefined; private _root?: ViewNode = undefined; // public because used by TemplateBuilder - _subViews?: UIView[] = undefined; + _subViews?: IView[] = undefined; constructor(value: T, render?: RenderFn) { super(value); @@ -138,14 +138,14 @@ export class TemplateView extends BaseUpdateView this._bindings.push(bindingFn); } - addSubView(view: UIView): void { + addSubView(view: IView): void { if (!this._subViews) { this._subViews = []; } this._subViews.push(view); } - removeSubView(view: UIView): void { + removeSubView(view: IView): void { if (!this._subViews) { return; } const idx = this._subViews.indexOf(view); if (idx !== -1) { @@ -312,13 +312,13 @@ export class TemplateBuilder { // this inserts a view, and is not a view factory for `if`, so returns the root element to insert in the template // you should not call t.view() and not use the result (e.g. attach the result to the template DOM tree). - view(view: UIView, mountOptions?: IMountArgs): ViewNode { + view(view: IView, mountOptions?: IMountArgs): ViewNode { this._templateView.addSubView(view); return mountView(view, mountOptions); } // map a value to a view, every time the value changes - mapView(mapFn: (value: T) => R, viewCreator: (mapped: R) => UIView | null): ViewNode { + mapView(mapFn: (value: T) => R, viewCreator: (mapped: R) => IView | null): ViewNode { return this._addReplaceNodeBinding(mapFn, (prevNode) => { if (prevNode && prevNode.nodeType !== Node.COMMENT_NODE) { const subViews = this._templateView._subViews; @@ -356,7 +356,7 @@ export class TemplateBuilder { }); } - ifView(predicate: (value: T) => boolean, viewCreator: (value: T) => UIView): ViewNode { + ifView(predicate: (value: T) => boolean, viewCreator: (value: T) => IView): ViewNode { return this.mapView( value => !!predicate(value), enabled => enabled ? viewCreator(this._value) : null diff --git a/src/platform/web/ui/general/types.ts b/src/platform/web/ui/general/types.ts index f38c8a5e..1d9122aa 100644 --- a/src/platform/web/ui/general/types.ts +++ b/src/platform/web/ui/general/types.ts @@ -22,7 +22,7 @@ export interface IMountArgs { // Comment nodes can be used as temporary placeholders for Elements, like TemplateView does. export type ViewNode = Element | Comment; -export interface UIView { +export interface IView { mount(args?: IMountArgs): ViewNode; root(): ViewNode | undefined; // should only be called between mount() and unmount() unmount(): void; diff --git a/src/platform/web/ui/general/utils.ts b/src/platform/web/ui/general/utils.ts index cf1a2eb6..7eb1d7f9 100644 --- a/src/platform/web/ui/general/utils.ts +++ b/src/platform/web/ui/general/utils.ts @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {UIView, IMountArgs, ViewNode} from "./types"; +import {IView, IMountArgs, ViewNode} from "./types"; import {tag} from "./html"; -export function mountView(view: UIView, mountArgs?: IMountArgs): ViewNode { +export function mountView(view: IView, mountArgs?: IMountArgs): ViewNode { let node; try { node = view.mount(mountArgs);