import { djbase, djclass, bind, prototype, AbstractConstructor } from "../declare"; import { DjxWidgetBase } from "../tsx/DjxWidgetBase"; import { createElement, on } from "../tsx"; import { argumentNotNull } from "@implab/core-amd/safe"; interface MyWidgetAttrs { title: string; counter: number; } interface MyWidgetEvents { "count-inc": Event & { detail: number; }; "count-dec": Event & { detail: number; }; } interface FrameProps { ref?: JSX.Ref; children?: unknown[]; } const Frame = ({children, ref}: FrameProps) =>
{children}
; @djclass export class MyWidget extends djbase(DjxWidgetBase as AbstractConstructor>) { @bind({ node: "titleNode", type: "innerHTML" }) title = ""; @prototype(0) counter = 0; frameNode?: HTMLDivElement; render() { return

[+] this._onDecClick()}>[-]
; } private readonly _setFrameElement = (node?: HTMLDivElement) => { this.frameNode = node; }; postCreate() { super.postCreate(); this.on("click", () => {}); } private readonly _onSubmit = (evt: Event) => { argumentNotNull(evt, "evt"); }; private readonly _onIncClick = (evt: MouseEvent) => { argumentNotNull(evt, "evt"); this.set("counter", this.counter + 1); this.emit("count-inc", { bubbles: false }); }; _onDecClick() { this.emit("count-dec", { bubbles: false, detail: this.counter }); } @on("count-inc") protected _onCounterInc(evt: Event & { detail: number; x?: number; }) { argumentNotNull(evt, "evt"); } @on("click", "keydown") protected _onClick(evt: MouseEvent | KeyboardEvent) { argumentNotNull(evt, "evt"); } }