@angular-mdc/web
Version:
293 lines (289 loc) • 8.55 kB
JavaScript
/**
* @license
* Copyright (c) Dominic Carretto
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE
*/
import { Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, Input, ContentChild, Directive, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MdcIcon, MdcIconModule } from '@angular-mdc/web/icon';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { MdcRipple } from '@angular-mdc/web/ripple';
/**
* @fileoverview added by tsickle
* Generated from: fab/fab.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MdcFabLabel = /** @class */ (function () {
function MdcFabLabel() {
}
MdcFabLabel.decorators = [
{ type: Directive, args: [{
selector: 'mdc-fab-label, [mdcFabLabel]',
host: { 'class': 'mdc-fab__label' }
},] },
];
return MdcFabLabel;
}());
var MdcFab = /** @class */ (function () {
function MdcFab(_changeDetectionRef, elementRef, _ripple) {
this._changeDetectionRef = _changeDetectionRef;
this.elementRef = elementRef;
this._ripple = _ripple;
this._mini = false;
this._touch = false;
this._exited = false;
this._extended = false;
this._fluid = false;
this._position = null;
}
Object.defineProperty(MdcFab.prototype, "mini", {
get: /**
* @return {?}
*/
function () {
return this._mini;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._mini = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcFab.prototype, "touch", {
get: /**
* @return {?}
*/
function () {
return this._touch;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._touch = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcFab.prototype, "exited", {
get: /**
* @return {?}
*/
function () {
return this._exited;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._exited = coerceBooleanProperty(value);
this._changeDetectionRef.markForCheck();
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcFab.prototype, "extended", {
get: /**
* @return {?}
*/
function () {
return this._extended;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._extended = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcFab.prototype, "fluid", {
get: /**
* @return {?}
*/
function () {
return this._fluid;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._fluid = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcFab.prototype, "position", {
get: /**
* @return {?}
*/
function () {
return this._position;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (this._position) {
this._getHostElement().classList.remove("ngx-mdc-fab--" + this._convertPosition(this._position));
}
if (value) {
this._getHostElement().classList.add("ngx-mdc-fab--" + this._convertPosition(value));
}
this._position = value;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
MdcFab.prototype.ngAfterContentInit = /**
* @return {?}
*/
function () {
if (this.fabIcon) {
this.fabIcon.elementRef.nativeElement.classList.add('mdc-fab__icon');
}
this._ripple = new MdcRipple(this.elementRef);
this._ripple.init();
};
/**
* @private
* @param {?} position
* @return {?}
*/
MdcFab.prototype._convertPosition = /**
* @private
* @param {?} position
* @return {?}
*/
function (position) {
switch (position) {
case 'bottomLeft': {
return 'bottom-left';
}
case 'bottomRight': {
return 'bottom-right';
}
default: {
return null;
}
}
};
/**
* @return {?}
*/
MdcFab.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this._ripple.destroy();
};
/**
* @param {?=} exited
* @return {?}
*/
MdcFab.prototype.toggleExited = /**
* @param {?=} exited
* @return {?}
*/
function (exited) {
this._exited = exited ? exited : !this._exited;
};
/** Focuses the button. */
/**
* Focuses the button.
* @return {?}
*/
MdcFab.prototype.focus = /**
* Focuses the button.
* @return {?}
*/
function () {
this._getHostElement().focus();
};
/**
* @private
* @return {?}
*/
MdcFab.prototype._getHostElement = /**
* @private
* @return {?}
*/
function () {
return this.elementRef.nativeElement;
};
MdcFab.decorators = [
{ type: Component, args: [{selector: 'button[mdc-fab], a[mdc-fab]',
host: {
'[attr.tabindex]': 'exited ? -1 : 0',
'class': 'mdc-fab',
'[class.mdc-fab--mini]': 'mini',
'[class.mdc-fab--exited]': 'exited',
'[class.mdc-fab--extended]': 'extended',
'[class.ngx-mdc-fab-extended--fluid]': 'fluid',
'[class.mdc-fab--touch]': 'touch && mini',
},
template: "\n <div class=\"mdc-fab__ripple\"></div>\n <ng-content></ng-content>\n <mdc-icon class=\"mdc-fab__icon\" *ngIf=\"icon\">{{icon}}</mdc-icon>\n <span class=\"mdc-fab__label\" *ngIf=\"label\">{{label}}</span>\n <div class=\"mdc-fab__touch\" *ngIf=\"touch && mini\"></div>",
providers: [MdcRipple],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
MdcFab.ctorParameters = function () { return [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: MdcRipple }
]; };
MdcFab.propDecorators = {
mini: [{ type: Input }],
touch: [{ type: Input }],
exited: [{ type: Input }],
extended: [{ type: Input }],
fluid: [{ type: Input }],
position: [{ type: Input }],
label: [{ type: Input }],
icon: [{ type: Input }],
fabIcon: [{ type: ContentChild, args: [MdcIcon, { static: false },] }]
};
return MdcFab;
}());
/**
* @fileoverview added by tsickle
* Generated from: fab/module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MdcFabModule = /** @class */ (function () {
function MdcFabModule() {
}
MdcFabModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
MdcIconModule
],
exports: [
MdcFab,
MdcFabLabel
],
declarations: [MdcFab, MdcFabLabel]
},] },
];
return MdcFabModule;
}());
export { MdcFab, MdcFabLabel, MdcFabModule };
//# sourceMappingURL=fab.es5.js.map