ng2-material-dropdown
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -64,3 +64,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
__export(__webpack_require__(3)); | ||
__export(__webpack_require__(11)); | ||
__export(__webpack_require__(13)); | ||
@@ -86,3 +86,2 @@ | ||
var ng2_dropdown_state_1 = __webpack_require__(20); | ||
var styles = [__webpack_require__(21).toString()], template = __webpack_require__(23); | ||
var Ng2Dropdown = (function () { | ||
@@ -96,6 +95,5 @@ function Ng2Dropdown() { | ||
} | ||
Ng2Dropdown.prototype.toggleMenu = function (position, focus) { | ||
Ng2Dropdown.prototype.toggleMenu = function (position) { | ||
if (position === void 0) { position = this.button.getPosition(); } | ||
if (focus === void 0) { focus = true; } | ||
this.menu.state.isVisible ? this.hide() : this.show(position, focus); | ||
this.menu.state.isVisible ? this.hide() : this.show(position); | ||
}; | ||
@@ -106,6 +104,5 @@ Ng2Dropdown.prototype.hide = function () { | ||
}; | ||
Ng2Dropdown.prototype.show = function (position, focus) { | ||
Ng2Dropdown.prototype.show = function (position) { | ||
if (position === void 0) { position = this.button.getPosition(); } | ||
if (focus === void 0) { focus = true; } | ||
this.menu.show(focus); | ||
this.menu.show(); | ||
this.menu.updatePosition(position); | ||
@@ -156,6 +153,5 @@ this.onShow.emit(this); | ||
core_1.Component({ | ||
moduleId: module.id, | ||
selector: 'ng2-dropdown', | ||
styles: styles, | ||
template: template | ||
styles: [__webpack_require__(21).toString()], | ||
template: __webpack_require__(23) | ||
}), | ||
@@ -213,3 +209,2 @@ __metadata('design:paramtypes', []) | ||
core_1.Component({ | ||
moduleId: module.id, | ||
selector: 'ng2-dropdown-button', | ||
@@ -604,6 +599,6 @@ styles: [__webpack_require__(4).toString()], | ||
var core_1 = __webpack_require__(2); | ||
var ng2_menu_item_1 = __webpack_require__(11); | ||
var animations_1 = __webpack_require__(11); | ||
var actions_1 = __webpack_require__(12); | ||
var ng2_menu_item_1 = __webpack_require__(13); | ||
var ng2_dropdown_1 = __webpack_require__(1); | ||
var animations_1 = __webpack_require__(15); | ||
var actions_1 = __webpack_require__(16); | ||
var Ng2DropdownMenu = (function () { | ||
@@ -624,4 +619,3 @@ function Ng2DropdownMenu(dropdown, element, renderer) { | ||
} | ||
Ng2DropdownMenu.prototype.show = function (focus) { | ||
if (focus === void 0) { focus = true; } | ||
Ng2DropdownMenu.prototype.show = function () { | ||
this.renderer.setElementStyle(this.getMenuElement(), 'display', 'block'); | ||
@@ -632,5 +626,2 @@ this.state.isVisible = true; | ||
} | ||
if (focus) { | ||
this.focusMenuElement(); | ||
} | ||
}; | ||
@@ -649,2 +640,5 @@ Ng2DropdownMenu.prototype.hide = function () { | ||
Ng2DropdownMenu.prototype.handleKeypress = function ($event) { | ||
if (!this.state.isVisible) { | ||
return; | ||
} | ||
var key = $event.keyCode, items = this.items.toArray(), index = items.indexOf(this.dropdown.state.selectedItem); | ||
@@ -660,6 +654,2 @@ if (!actions_1.ACTIONS.hasOwnProperty(key)) { | ||
}; | ||
Ng2DropdownMenu.prototype.focusMenuElement = function (element) { | ||
if (element === void 0) { element = this.getMenuElement(); } | ||
this.renderer.invokeElementMethod(element, 'focus', []); | ||
}; | ||
Ng2DropdownMenu.prototype.calcPositionOffset = function (position) { | ||
@@ -678,4 +668,6 @@ var top = (position.top + window.scrollY - 15) + "px", left = (position.left + window.scrollX - 5) + "px"; | ||
Ng2DropdownMenu.prototype.ngOnInit = function () { | ||
var _this = this; | ||
var body = document.querySelector('body'); | ||
body.appendChild(this.element.nativeElement); | ||
this.renderer.listen(body, 'keyup', function ($event) { return _this.handleKeypress($event); }); | ||
}; | ||
@@ -700,3 +692,2 @@ __decorate([ | ||
core_1.Component({ | ||
moduleId: module.id, | ||
selector: 'ng2-dropdown-menu', | ||
@@ -720,2 +711,72 @@ styles: [__webpack_require__(17).toString()], | ||
"use strict"; | ||
var core_1 = __webpack_require__(2); | ||
exports.animations = [ | ||
core_1.trigger('fade', [ | ||
core_1.state('visible', core_1.style({ | ||
width: '100%', | ||
maxHeight: '350px', | ||
opacity: 1 | ||
})), | ||
core_1.state('hidden', core_1.style({ | ||
width: '0px', | ||
maxHeight: '0px', | ||
opacity: 0 | ||
})), | ||
core_1.transition('visible => hidden', [ | ||
core_1.animate('100ms ease-out') | ||
]), | ||
core_1.transition('hidden => visible', [ | ||
core_1.animate('150ms cubic-bezier(0.55, 0, 0.55, 0.2)') | ||
]) | ||
]) | ||
]; | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
var KEYS = { | ||
ENTER: 13, | ||
BACKSPACE: 9, | ||
PREV: 38, | ||
NEXT: 40 | ||
}; | ||
var onSwitchNext = function (index, items, state) { | ||
if (index < items.length - 1) { | ||
state.select(items[index + 1], true); | ||
} | ||
}; | ||
var onSwitchPrev = function (index, items, state) { | ||
if (index > 0) { | ||
state.select(items[index - 1], true); | ||
} | ||
}; | ||
var onBackspace = function (index, items, state) { | ||
if (index < items.length - 1) { | ||
state.select(items[index + 1], true); | ||
} | ||
else { | ||
state.select(items[0], true); | ||
} | ||
}; | ||
var onEnter = function (index, items, state) { | ||
state.onItemClicked.emit(state.selectedItem); | ||
}; | ||
exports.ACTIONS = (_a = {}, | ||
_a[KEYS.BACKSPACE] = onBackspace, | ||
_a[KEYS.PREV] = onSwitchPrev, | ||
_a[KEYS.NEXT] = onSwitchNext, | ||
_a[KEYS.ENTER] = onEnter, | ||
_a | ||
); | ||
var _a; | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -763,6 +824,5 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
core_1.Component({ | ||
moduleId: module.id, | ||
selector: 'ng2-menu-item', | ||
styles: [__webpack_require__(12).toString()], | ||
template: __webpack_require__(14) | ||
styles: [__webpack_require__(14).toString()], | ||
template: __webpack_require__(16) | ||
}), | ||
@@ -778,3 +838,3 @@ __param(0, core_1.Inject(core_1.forwardRef(function () { return ng2_dropdown_1.Ng2Dropdown; }))), | ||
/***/ }, | ||
/* 12 */ | ||
/* 14 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -785,3 +845,3 @@ | ||
// load the styles | ||
var content = __webpack_require__(13); | ||
var content = __webpack_require__(15); | ||
if(typeof content === 'string') content = [[module.id, content, '']]; | ||
@@ -806,3 +866,3 @@ // add the styles to the DOM | ||
/***/ }, | ||
/* 13 */ | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -821,3 +881,3 @@ | ||
/***/ }, | ||
/* 14 */ | ||
/* 16 */ | ||
/***/ function(module, exports) { | ||
@@ -828,72 +888,2 @@ | ||
/***/ }, | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var core_1 = __webpack_require__(2); | ||
exports.animations = [ | ||
core_1.trigger('fade', [ | ||
core_1.state('visible', core_1.style({ | ||
width: '100%', | ||
maxHeight: '350px', | ||
opacity: 1 | ||
})), | ||
core_1.state('hidden', core_1.style({ | ||
width: '0px', | ||
maxHeight: '0px', | ||
opacity: 0 | ||
})), | ||
core_1.transition('visible => hidden', [ | ||
core_1.animate('100ms ease-out') | ||
]), | ||
core_1.transition('hidden => visible', [ | ||
core_1.animate('150ms cubic-bezier(0.55, 0, 0.55, 0.2)') | ||
]) | ||
]) | ||
]; | ||
/***/ }, | ||
/* 16 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
var KEYS = { | ||
ENTER: 13, | ||
BACKSPACE: 9, | ||
PREV: 38, | ||
NEXT: 40 | ||
}; | ||
var onSwitchNext = function (index, items, state) { | ||
if (index < items.length - 1) { | ||
state.select(items[index + 1], true); | ||
} | ||
}; | ||
var onSwitchPrev = function (index, items, state) { | ||
if (index > 0) { | ||
state.select(items[index - 1], true); | ||
} | ||
}; | ||
var onBackspace = function (index, items, state) { | ||
if (index < items.length - 1) { | ||
state.select(items[index + 1], true); | ||
} | ||
else { | ||
state.select(items[0], true); | ||
} | ||
}; | ||
var onEnter = function (index, items, state) { | ||
state.onItemClicked.emit(state.selectedItem); | ||
}; | ||
exports.ACTIONS = (_a = {}, | ||
_a[KEYS.BACKSPACE] = onBackspace, | ||
_a[KEYS.PREV] = onSwitchPrev, | ||
_a[KEYS.NEXT] = onSwitchNext, | ||
_a[KEYS.ENTER] = onEnter, | ||
_a | ||
); | ||
var _a; | ||
/***/ }, | ||
/* 17 */ | ||
@@ -942,3 +932,3 @@ /***/ function(module, exports, __webpack_require__) { | ||
module.exports = "<!-- CONTAINER -->\n<div class=\"ng2-dropdown-menu-container ng2-dropdown-menu-container--{{ width }}\"\n [class.ng2-dropdown-menu-container--open]=\"state.isVisible\"\n tabindex=\"0\"\n (keyup)=\"handleKeypress($event)\">\n\n <!-- MENU -->\n <div class='ng2-dropdown-menu' @fade=\"state.toString()\">\n <ng-content></ng-content>\n </div>\n</div>\n\n<!-- BACKDROP -->\n<div class=\"ng2-dropdown-backdrop\" [hidden]=\"!state.isVisible\" (click)=\"hide()\"></div>\n"; | ||
module.exports = "<!-- CONTAINER -->\n<div class=\"ng2-dropdown-menu-container ng2-dropdown-menu-container--{{ width }}\"\n [class.ng2-dropdown-menu-container--open]=\"state.isVisible\"\n tabindex=\"0\">\n\n <!-- MENU -->\n <div class='ng2-dropdown-menu' @fade=\"state.toString()\">\n <ng-content></ng-content>\n </div>\n</div>\n\n<!-- BACKDROP -->\n<div class=\"ng2-dropdown-backdrop\" [hidden]=\"!state.isVisible\" (click)=\"hide()\"></div>\n"; | ||
@@ -945,0 +935,0 @@ /***/ }, |
@@ -1,6 +0,7 @@ | ||
export * from './src/typings/ng2-dropdown.d.ts'; | ||
export * from './src/typings/ng2-dropdown-menu.d.ts'; | ||
export * from './src/typings/ng2-dropdown-button.d.ts'; | ||
export * from './src/typings/ng2-menu-item.d.ts'; | ||
export * from './index.ts'; | ||
declare const Ng2Dropdown: any; | ||
declare const Ng2DropdownMenu: any; | ||
declare const Ng2MenuItem: any; | ||
declare const Ng2DropdownButton: any; | ||
export { Ng2Dropdown, Ng2DropdownMenu, Ng2DropdownButton, Ng2MenuItem }; | ||
declare const NG2_DROPDOWN_DIRECTIVES: any[]; | ||
export { NG2_DROPDOWN_DIRECTIVES }; |
{ | ||
"name": "ng2-material-dropdown", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Angular 2 material-like Dropdown Component", | ||
@@ -8,3 +8,3 @@ "scripts": { | ||
"postinstall": "npm run typings-install", | ||
"prepublish": "npm run build && ./node_modules/.bin/tsc -p tsconfig.json", | ||
"prepublish": "npm run build && ./node_modules/.bin/tsc", | ||
"build": "webpack --inline --colors --progress --display-error-details --display-cached", | ||
@@ -23,9 +23,9 @@ "watch": "npm run build -- --watch", | ||
"devDependencies": { | ||
"@angular/common": "2.0.0-rc.3", | ||
"@angular/compiler": "2.0.0-rc.3", | ||
"@angular/core": "2.0.0-rc.3", | ||
"@angular/http": "2.0.0-rc.3", | ||
"@angular/platform-browser": "2.0.0-rc.3", | ||
"@angular/platform-browser-dynamic": "2.0.0-rc.3", | ||
"@angular/platform-server": "2.0.0-rc.3", | ||
"@angular/common": "2.0.0-rc.5", | ||
"@angular/compiler": "2.0.0-rc.5", | ||
"@angular/core": "2.0.0-rc.5", | ||
"@angular/http": "2.0.0-rc.5", | ||
"@angular/platform-browser": "2.0.0-rc.5", | ||
"@angular/platform-browser-dynamic": "2.0.0-rc.5", | ||
"@angular/platform-server": "2.0.0-rc.5", | ||
"@angular/router": "2.0.0-rc.2", | ||
@@ -32,0 +32,0 @@ "autoprefixer": "^6.3.6", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
121814
34
1454