UNPKG

2.36 kBJavaScriptView Raw
1import { Directive, EventEmitter, HostBinding, Input, Output } from '@angular/core';
2import { TabsetComponent } from './tabset.component';
3export var TabDirective = (function () {
4 function TabDirective(tabset) {
5 /** fired when tab became active, $event:Tab equals to selected instance of Tab component */
6 this.select = new EventEmitter();
7 /** fired when tab became inactive, $event:Tab equals to deselected instance of Tab component */
8 this.deselect = new EventEmitter();
9 /** fired before tab will be removed */
10 this.removed = new EventEmitter();
11 this.addClass = true;
12 this.tabset = tabset;
13 this.tabset.addTab(this);
14 }
15 Object.defineProperty(TabDirective.prototype, "active", {
16 /** tab active state toggle */
17 get: function () {
18 return this._active;
19 },
20 set: function (active) {
21 var _this = this;
22 if (this.disabled && active || !active) {
23 if (!active) {
24 this._active = active;
25 }
26 this.deselect.emit(this);
27 return;
28 }
29 this._active = active;
30 this.select.emit(this);
31 this.tabset.tabs.forEach(function (tab) {
32 if (tab !== _this) {
33 tab.active = false;
34 }
35 });
36 },
37 enumerable: true,
38 configurable: true
39 });
40 TabDirective.prototype.ngOnInit = function () {
41 this.removable = this.removable;
42 };
43 TabDirective.decorators = [
44 { type: Directive, args: [{ selector: 'tab, [tab]' },] },
45 ];
46 /** @nocollapse */
47 TabDirective.ctorParameters = function () { return [
48 { type: TabsetComponent, },
49 ]; };
50 TabDirective.propDecorators = {
51 'heading': [{ type: Input },],
52 'disabled': [{ type: Input },],
53 'removable': [{ type: Input },],
54 'customClass': [{ type: Input },],
55 'active': [{ type: HostBinding, args: ['class.active',] }, { type: Input },],
56 'select': [{ type: Output },],
57 'deselect': [{ type: Output },],
58 'removed': [{ type: Output },],
59 'addClass': [{ type: HostBinding, args: ['class.tab-pane',] },],
60 };
61 return TabDirective;
62}());
63//# sourceMappingURL=tab.directive.js.map
\No newline at end of file