diff --git a/package-lock.json b/package-lock.json --- a/package-lock.json +++ b/package-lock.json @@ -58,9 +58,9 @@ "dev": true }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true }, "acorn-jsx": { @@ -697,9 +697,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "dev": true }, "mimic-fn": { @@ -717,19 +717,21 @@ "brace-expansion": "^1.1.7" } }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" + }, + "dependencies": { + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + } } }, "ms": { @@ -858,9 +860,9 @@ "dev": true }, "resolve": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", - "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1086,9 +1088,9 @@ "dev": true }, "tslint": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.0.0.tgz", - "integrity": "sha512-9nLya8GBtlFmmFMW7oXXwoXS1NkrccqTqAtwXzdPV9e2mqSEvCki6iHL/Fbzi5oqbugshzgGPk7KBb2qNP1DSA==", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", + "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -1099,10 +1101,10 @@ "glob": "^7.1.1", "js-yaml": "^3.13.1", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", + "mkdirp": "^0.5.3", "resolve": "^1.3.2", "semver": "^5.3.0", - "tslib": "^1.10.0", + "tslib": "^1.13.0", "tsutils": "^2.29.0" }, "dependencies": { @@ -1111,6 +1113,12 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true + }, + "tslib": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", + "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", + "dev": true } } }, @@ -1145,9 +1153,9 @@ "dev": true }, "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz", + "integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==", "dev": true }, "uri-js": { diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -19,16 +19,16 @@ "@implab/core-amd": "^1.3.2" }, "devDependencies": { + "@implab/core-amd": "^1.3.2", + "@types/chai": "4.1.3", "@types/requirejs": "2.1.31", - "dojo": "1.16.0", - "typescript": "~3.8.3", - "eslint": "6.8.0", - "tslint": "6.0.0", - "@implab/core-amd": "^1.3.2", - "yaml": "~1.7.2", "@types/yaml": "1.2.0", "chai": "4.2.0", - "@types/chai": "4.1.3", - "dojo-typings": "~1.11.9" + "dojo": "1.16.0", + "dojo-typings": "~1.11.9", + "eslint": "6.8.0", + "tslint": "^6.1.3", + "typescript": "4.0.2", + "yaml": "~1.7.2" } } diff --git a/src/main/ts/declare.ts b/src/main/ts/declare.ts --- a/src/main/ts/declare.ts +++ b/src/main/ts/declare.ts @@ -240,7 +240,7 @@ export function bind(params: NodeBindSpe } } -/** Создает в прототипе указанное свойство со значение `undefined`, данный +/** Создает в прототипе указанное свойство со значение `undefined`, данный * декоратор следует использовать для свойств, у которых нет значения по-умолчанию * и они не могут быть `null | undefined` */ diff --git a/src/main/ts/tsx/DjxWidgetBase.ts b/src/main/ts/tsx/DjxWidgetBase.ts --- a/src/main/ts/tsx/DjxWidgetBase.ts +++ b/src/main/ts/tsx/DjxWidgetBase.ts @@ -6,8 +6,26 @@ import registry = require("dijit/registr // type Handle = dojo.Handle; +export interface EventArgs { + bubbles?: boolean; + + cancelable?: boolean; + + composed?: boolean; +} + +export interface DjxWidgetBase { + set(key: K, value: Attrs[K]): this; + set(props: Partial): this; + get(key: K): Attrs[K]; + + on(eventName: K, cb: (evt: Events[K]) => void): dojo.WatchHandle; + + emit(eventName: K, evt: Omit & EventArgs ): void; +} + @djclass -export abstract class DjxWidgetBase extends djbase(_WidgetBase, _AttachMixin) { +export abstract class DjxWidgetBase extends djbase(_WidgetBase, _AttachMixin) { buildRendering() { this.domNode = this.render().getDomNode(); diff --git a/src/main/typings/index.d.ts b/src/main/typings/index.d.ts --- a/src/main/typings/index.d.ts +++ b/src/main/typings/index.d.ts @@ -8,3 +8,18 @@ declare namespace JSX { [name: string]: any; } } + +declare namespace dijit { + interface _WidgetBase { + + _started?: boolean; + + _set(key: K, value: this[K]): void; + } + + interface TooltipDialog { + + content: any; + + } +} \ No newline at end of file diff --git a/src/test/ts/view/MyWidget.tsx b/src/test/ts/view/MyWidget.tsx --- a/src/test/ts/view/MyWidget.tsx +++ b/src/test/ts/view/MyWidget.tsx @@ -1,11 +1,23 @@ -import { djbase, djclass, bind, prototype } from "../declare"; +import { djbase, djclass, bind, prototype, AbstractConstructor } from "../declare"; import { DjxWidgetBase } from "../tsx/DjxWidgetBase"; import { createElement } from "../tsx"; +interface MyWidgetAttrs { + title: string; + + counter: number; +} + +interface MyWidgetEvents { + "count-inc": Event; + + "count-dec": Event; +} + @djclass -export class MyWidget extends djbase(DjxWidgetBase) { +export class MyWidget extends djbase(DjxWidgetBase as AbstractConstructor>) { @bind({node: "titleNode", type:"innerHTML"}) title = ""; @@ -16,7 +28,16 @@ export class MyWidget extends djbase(Djx render() { return

+ this._onIncClick()}>[+] + this._onDecClick()}>[-]
; } + _onIncClick() { + this.emit("count-inc", { bubbles: false } ); + } + + _onDecClick() { + this.emit("count-dec", { bubbles: false } ); + } }