##// END OF EJS Templates
implemented @on("event-name") decorator for event handlers
implemented @on("event-name") decorator for event handlers

File last commit:

r73:fdde09e66c00 v1.2.0 default
r73:fdde09e66c00 v1.2.0 default
Show More
MyWidget.tsx
70 lines | 1.7 KiB | text/x-typescript | TypeScriptLexer
/ djx / src / test / ts / view / MyWidget.tsx
cin
Converted to subproject djx, removed dojo-typings
r65 import { djbase, djclass, bind, prototype, AbstractConstructor } from "../declare";
import { DjxWidgetBase } from "../tsx/DjxWidgetBase";
import { createElement } from "../tsx";
cin
implemented @on("event-name") decorator for event handlers
r73 import { on } from "../tsx/traits";
cin
Converted to subproject djx, removed dojo-typings
r65
interface MyWidgetAttrs {
title: string;
counter: number;
}
interface MyWidgetEvents {
cin
Switched to @implab/dojo-typings
r71 "count-inc": Event & {
detail: number;
};
cin
Converted to subproject djx, removed dojo-typings
r65
cin
Switched to @implab/dojo-typings
r71 "count-dec": Event & {
detail: number;
};
cin
Converted to subproject djx, removed dojo-typings
r65 }
@djclass
export class MyWidget extends djbase(DjxWidgetBase as AbstractConstructor<DjxWidgetBase<MyWidgetAttrs, MyWidgetEvents>>) {
@bind({ node: "titleNode", type: "innerHTML" })
title = "";
@prototype()
counter = 0;
render() {
const Frame = (props: any) => <div>{props.children}</div>;
return <div className="myWidget" onsubmit={e => this._onSubmit(e)} tabIndex={3} style={{ alignContent: "center", border: "1px solid" }} >
<h1 data-dojo-attach-point="titleNode"></h1>
<Frame>
<span class="up-button" onclick={e => this._onIncClick(e)}>[+]</span>
<span class="down-button" onclick={() => this._onDecClick()}>[-]</span>
</Frame>
</div>;
}
cin
temp commit, working on @on() decorator
r72 postCreate() {
super.postCreate();
this.on("click", () => {});
}
cin
Converted to subproject djx, removed dojo-typings
r65 _onSubmit(e: Event) {
}
_onIncClick(e: MouseEvent) {
cin
temp commit, working on @on() decorator
r72 this.set("counter", this.counter + 1);
cin
Switched to @implab/dojo-typings
r71
cin
Converted to subproject djx, removed dojo-typings
r65 this.emit("count-inc", { bubbles: false });
}
_onDecClick() {
cin
Switched to @implab/dojo-typings
r71 this.emit("count-dec", { bubbles: false, detail: this.counter });
cin
Converted to subproject djx, removed dojo-typings
r65 }
cin
temp commit, working on @on() decorator
r72
@on("count-inc")
cin
implemented @on("event-name") decorator for event handlers
r73 _onCounterInc(evt: Event & { detail: number; x?: number; }) {
}
@on("click")
_onClick() {
cin
temp commit, working on @on() decorator
r72
}
cin
implemented @on("event-name") decorator for event handlers
r73 }