Skip to content

Commit

Permalink
feat: prepare for TS defs generation (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haprog committed May 13, 2020
1 parent e22f3a6 commit a53277e
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 8 deletions.
22 changes: 22 additions & 0 deletions @types/interfaces.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export type DialogResizableDirection = 'n' | 'e' | 's' | 'w' | 'nw' | 'ne' | 'se' | 'sw';

export type DialogResizeDimensions = {
width: string;
height: string;
contentWidth: string;
contentHeight: string;
};

export type DialogOverlayBounds = {
top: number;
left: number;
width: number;
height: number;
};

export type DialogOverlayBoundsParam = DialogOverlayBounds | {
top?: string | number;
left?: string | number;
width?: string | number;
height?: string | number;
};
8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
"dependencies": {
"polymer": "^2.0.0",
"iron-resizable-behavior": "^2.0.0",
"vaadin-overlay": "vaadin/vaadin-overlay#^3.4.0",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.5.2",
"vaadin-overlay": "vaadin/vaadin-overlay#^3.5.0",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.6.1",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.6.0",
"vaadin-material-styles": "vaadin/vaadin-material-styles#^1.3.2",
"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",
"iron-test-helpers": "^2.0.0",
"vaadin-button": "vaadin/vaadin-button#^2.3.0",
"vaadin-button": "vaadin/vaadin-button#^2.4.0-alpha1",
"webcomponentsjs": "^1.0.0",
"web-component-tester": "^6.1.5",
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.1.0-alpha1"
Expand Down
20 changes: 20 additions & 0 deletions gen-tsd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"excludeFiles": [
"wct.conf.js",
"index.html",
"demo/**/*",
"test/**/*",
"theme/**/*"
],
"autoImport": {
"@vaadin/vaadin-overlay/@types/interfaces": [
"OverlayRenderer"
],
"./@types/interfaces": [
"DialogResizableDirection",
"DialogResizeDimensions",
"DialogOverlayBounds",
"DialogOverlayBoundsParam"
]
}
}
11 changes: 11 additions & 0 deletions magi-p3-post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
files: [
'vaadin-dialog.js'
],
from: [
/import '\.\/theme\/lumo\/vaadin-(.+)\.js';/
],
to: [
`import './theme/lumo/vaadin-$1.js';\nexport * from './src/vaadin-$1.js';`
]
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
},
"homepage": "https://vaadin.com/components",
"files": [
"vaadin-*.d.ts",
"vaadin-*.js",
"@types",
"src",
"theme"
],
Expand Down
5 changes: 5 additions & 0 deletions src/vaadin-dialog-draggable-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
class VaadinDialogDraggableMixin extends superClass {
static get properties() {
return {
/** @private */
_touchDevice: {
type: Boolean,
value: TOUCH_DEVICE
}
};
}

/** @protected */
ready() {
super.ready();
this._originalBounds = {};
Expand All @@ -39,6 +41,7 @@
this.$.overlay.$.overlay.addEventListener('touchstart', this._startDrag);
}

/** @private */
_startDrag(e) {
if (this.draggable && (e.button === 0 || e.touches)) {
const resizerContainer = this.$.overlay.$.resizerContainer;
Expand All @@ -63,6 +66,7 @@
}
}

/** @private */
_drag(e) {
const event = this.__getMouseOrFirstTouchEvent(e);
if (this._eventInWindow(event) &&
Expand All @@ -73,6 +77,7 @@
}
}

/** @private */
_stopDrag() {
window.removeEventListener('mouseup', this._stopDrag);
window.removeEventListener('touchend', this._stopDrag);
Expand Down
20 changes: 20 additions & 0 deletions src/vaadin-dialog-resizable-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
*/
Vaadin.DialogResizableMixin = (superClass) =>
class VaadinDialogResizableMixin extends superClass {
/** @protected */
ready() {
super.ready();
this._originalBounds = {};
Expand All @@ -113,6 +114,7 @@
this._addResizeListeners();
}

/** @private */
_addResizeListeners() {
// Note: edge controls added before corners
['n', 'e', 's', 'w', 'nw', 'ne', 'se', 'sw'].forEach((direction) => {
Expand All @@ -131,6 +133,11 @@
});
}

/**
* @param {!MouseEvent | !TouchEvent} e
* @param {!DialogResizableDirection} direction
* @protected
*/
_startResize(e, direction) {
if (e.button === 0 || e.touches) {
e.preventDefault();
Expand All @@ -147,6 +154,11 @@
}
}

/**
* @param {!MouseEvent | !TouchEvent} e
* @param {!DialogResizableDirection} resizer
* @protected
*/
_resize(e, resizer) {
const event = this.__getMouseOrFirstTouchEvent(e);
if (this._eventInWindow(event) &&
Expand Down Expand Up @@ -190,6 +202,10 @@
}
}

/**
* @param {!DialogResizableDirection} direction
* @protected
*/
_stopResize(direction) {
window.removeEventListener('mousemove', this._resizeListeners.resize[direction]);
window.removeEventListener('touchmove', this._resizeListeners.resize[direction]);
Expand All @@ -198,6 +214,10 @@
this.dispatchEvent(new CustomEvent('resize', {detail: this._getResizeDimensions()}));
}

/**
* @return {!DialogResizeDimensions}
* @protected
*/
_getResizeDimensions() {
const {width, height} = getComputedStyle(this.$.overlay.$.overlay);
const content = this.$.overlay.$.content;
Expand Down
Loading

0 comments on commit a53277e

Please sign in to comment.