From 2921654e92fccc1d687d2836d5c720926781d682 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Fri, 15 May 2020 11:01:52 +0300 Subject: [PATCH] feat: prepare for TS defs generation (#144) --- @types/interfaces.d.ts | 1 + bower.json | 4 ++-- gen-tsd.json | 14 ++++++++++++++ magi-p3-post.js | 11 +++++++++++ package.json | 2 ++ src/vaadin-split-layout.html | 21 +++++++++++++++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 @types/interfaces.d.ts create mode 100644 gen-tsd.json create mode 100644 magi-p3-post.js diff --git a/@types/interfaces.d.ts b/@types/interfaces.d.ts new file mode 100644 index 0000000..1f0caa5 --- /dev/null +++ b/@types/interfaces.d.ts @@ -0,0 +1 @@ +export type SplitLayoutOrientation = 'horizontal' | 'vertical'; diff --git a/bower.json b/bower.json index 970ac86..85117f9 100644 --- a/bower.json +++ b/bower.json @@ -32,10 +32,10 @@ "dependencies": { "polymer": "^2.0.0", "iron-resizable-behavior": "^2.0.0", - "vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.2.1", + "vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.6.1", "vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.1.0", "vaadin-material-styles": "vaadin/vaadin-material-styles#^1.1.0", - "vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.3.0" + "vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.4.1" }, "devDependencies": { "iron-component-page": "^3.0.0", diff --git a/gen-tsd.json b/gen-tsd.json new file mode 100644 index 0000000..04902e2 --- /dev/null +++ b/gen-tsd.json @@ -0,0 +1,14 @@ +{ + "excludeFiles": [ + "wct.conf.js", + "index.html", + "demo/**/*", + "test/**/*", + "theme/**/*" + ], + "autoImport": { + "./@types/interfaces": [ + "SplitLayoutOrientation" + ] + } +} diff --git a/magi-p3-post.js b/magi-p3-post.js new file mode 100644 index 0000000..bde260b --- /dev/null +++ b/magi-p3-post.js @@ -0,0 +1,11 @@ +module.exports = { + files: [ + 'vaadin-split-layout.js' + ], + from: [ + /import '\.\/theme\/lumo\/vaadin-(.+)\.js';/ + ], + to: [ + `import './theme/lumo/vaadin-$1.js';\nexport * from './src/vaadin-$1.js';` + ] +}; diff --git a/package.json b/package.json index 50e04ee..9b45c99 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,9 @@ }, "homepage": "https://vaadin.com/components", "files": [ + "vaadin-*.d.ts", "vaadin-*.js", + "@types", "src", "theme" ], diff --git a/src/vaadin-split-layout.html b/src/vaadin-split-layout.html index e80f1e4..cf7c33b 100644 --- a/src/vaadin-split-layout.html +++ b/src/vaadin-split-layout.html @@ -218,6 +218,7 @@ * See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki) * * @memberof Vaadin + * @mixes Vaadin.ElementMixin * @mixes Vaadin.ThemableMixin * @mixes Polymer.GestureEventListeners * @demo demo/index.html @@ -240,6 +241,7 @@ return { /** * The split layout's orientation. Possible values are: `horizontal|vertical`. + * @type {!SplitLayoutOrientation} */ orientation: { type: String, @@ -247,16 +249,21 @@ value: 'horizontal' }, + /** @private */ _previousPrimaryPointerEvents: String, + + /** @private */ _previousSecondaryPointerEvents: String }; } + /** @protected */ ready() { super.ready(); new Polymer.FlattenedNodesObserver(this, this._processChildren); } + /** @private */ _processChildren() { this.getEffectiveChildren().forEach((child, i) => { if (i === 0) { @@ -271,6 +278,7 @@ }); } + /** @private */ _setFlexBasis(element, flexBasis, containerSize) { flexBasis = Math.max(0, Math.min(flexBasis, containerSize)); if (flexBasis === 0) { @@ -280,6 +288,7 @@ element.style.flex = '1 1 ' + flexBasis + 'px'; } + /** @private */ _setPointerEventsNone(event) { if (!this._primaryChild || !this._secondaryChild) { return; @@ -292,6 +301,7 @@ event.preventDefault(); } + /** @private */ _restorePointerEvents() { if (!this._primaryChild || !this._secondaryChild) { return; @@ -300,6 +310,7 @@ this._secondaryChild.style.pointerEvents = this._previousSecondaryPointerEvents; } + /** @private */ _onHandleTrack(event) { if (!this._primaryChild || !this._secondaryChild) { return; @@ -332,6 +343,16 @@ } } + /** + * Can be called to manually notify a resizable and its descendant + * resizables of a resize change. + */ + notifyResize() { + // NOTE: we have this method here to include it to TypeScript definitions. + // gen-typescript-declarations does not generate types for `mixinBehaviors` + super.notifyResize(); + } + /** * Fired when the splitter is dragged. Non-bubbling. Fired for the splitter * element and any nested elements with `IronResizableBehavior`.