@angular-mdc/web
Version:
260 lines (256 loc) • 7.75 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, ElementRef, Input, ContentChild, Directive, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { MdcRipple } from '@angular-mdc/web/ripple';
import { MdcIcon } from '@angular-mdc/web/icon';
/**
* @fileoverview added by tsickle
* Generated from: button/button.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MdcButtonLabel = /** @class */ (function () {
function MdcButtonLabel() {
}
MdcButtonLabel.decorators = [
{ type: Directive, args: [{
selector: 'mdc-button-label, [mdcButtonLabel]',
exportAs: 'mdcButtonLabel',
host: { 'class': 'mdc-button__label' }
},] },
];
return MdcButtonLabel;
}());
var MdcButton = /** @class */ (function () {
function MdcButton(elementRef, _ripple) {
this.elementRef = elementRef;
this._ripple = _ripple;
this._raised = false;
this._unelevated = false;
this._outlined = false;
this._touch = false;
this._disabled = false;
this._ripple = new MdcRipple(this.elementRef);
this._ripple.init();
}
Object.defineProperty(MdcButton.prototype, "raised", {
get: /**
* @return {?}
*/
function () {
return this._raised;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._raised = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcButton.prototype, "unelevated", {
get: /**
* @return {?}
*/
function () {
return this._unelevated;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._unelevated = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcButton.prototype, "outlined", {
get: /**
* @return {?}
*/
function () {
return this._outlined;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._outlined = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcButton.prototype, "touch", {
get: /**
* @return {?}
*/
function () {
return this._touch;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._touch = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MdcButton.prototype, "disabled", {
get: /**
* @return {?}
*/
function () {
return this._disabled;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this.setDisabled(value);
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
MdcButton.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if (this._icon) {
this._icon.elementRef.nativeElement.classList.add('mdc-button__icon');
}
};
/**
* @return {?}
*/
MdcButton.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this._ripple.destroy();
};
/**
* @param {?} disabled
* @return {?}
*/
MdcButton.prototype.setDisabled = /**
* @param {?} disabled
* @return {?}
*/
function (disabled) {
this._disabled = coerceBooleanProperty(disabled);
if (this._disabled) {
this.getHostElement().setAttribute('disabled', 'true');
this.getHostElement().setAttribute('aria-disabled', 'true');
}
else {
this.getHostElement().removeAttribute('disabled');
this.getHostElement().removeAttribute('aria-disabled');
}
};
/** Focuses the button. */
/**
* Focuses the button.
* @return {?}
*/
MdcButton.prototype.focus = /**
* Focuses the button.
* @return {?}
*/
function () {
this.getHostElement().focus();
};
/**
* @return {?}
*/
MdcButton.prototype.getHostElement = /**
* @return {?}
*/
function () {
return this.elementRef.nativeElement;
};
/**
* @param {?} event
* @return {?}
*/
MdcButton.prototype.onClick = /**
* @param {?} event
* @return {?}
*/
function (event) {
// A disabled button shouldn't apply any actions
if (this.disabled) {
event.preventDefault();
event.stopImmediatePropagation();
}
};
MdcButton.decorators = [
{ type: Component, args: [{exportAs: 'mdcButton',
selector: 'button[mdc-button], a[mdc-button]',
host: {
'[tabIndex]': 'disabled ? -1 : 0',
'class': 'mdc-button',
'[class.mdc-button--raised]': 'raised',
'[class.mdc-button--unelevated]': 'unelevated',
'[class.mdc-button--outlined]': 'outlined',
'[class.mdc-button--touch]': 'touch',
'(click)': 'onClick($event)'
},
template: "\n <div class=\"mdc-button__ripple\"></div>\n <mdc-button-label *ngIf=\"label\">{{label}}</mdc-button-label>\n <div class=\"mdc-button__touch\" *ngIf=\"touch\"></div>\n <ng-content></ng-content>\n ",
providers: [MdcRipple],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
MdcButton.ctorParameters = function () { return [
{ type: ElementRef },
{ type: MdcRipple }
]; };
MdcButton.propDecorators = {
raised: [{ type: Input }],
unelevated: [{ type: Input }],
outlined: [{ type: Input }],
touch: [{ type: Input }],
disabled: [{ type: Input }],
_icon: [{ type: ContentChild, args: [MdcIcon, { static: true },] }],
label: [{ type: Input }]
};
return MdcButton;
}());
/**
* @fileoverview added by tsickle
* Generated from: button/module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MdcButtonModule = /** @class */ (function () {
function MdcButtonModule() {
}
MdcButtonModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule
],
exports: [MdcButton, MdcButtonLabel],
declarations: [MdcButton, MdcButtonLabel]
},] },
];
return MdcButtonModule;
}());
export { MdcButton, MdcButtonLabel, MdcButtonModule };
//# sourceMappingURL=button.es5.js.map