@angular-mdc/web
Version:
266 lines (260 loc) • 9.47 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
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/cdk/coercion'), require('@angular-mdc/web/ripple'), require('@angular-mdc/web/icon')) :
typeof define === 'function' && define.amd ? define('@angular-mdc/web/button', ['exports', '@angular/core', '@angular/common', '@angular/cdk/coercion', '@angular-mdc/web/ripple', '@angular-mdc/web/icon'], factory) :
(global = global || self, factory((global.ng = global.ng || {}, global.ng.web = global.ng.web || {}, global.ng.web.button = {}), global.ng.core, global.ng.common, global.ng.cdk.coercion, global.ng.web.ripple, global.ng.web.icon));
}(this, (function (exports, core, common, coercion, ripple, icon) { 'use strict';
/**
* @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: core.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 ripple.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 = coercion.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 = coercion.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 = coercion.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 = coercion.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 = coercion.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: core.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: [ripple.MdcRipple],
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
MdcButton.ctorParameters = function () { return [
{ type: core.ElementRef },
{ type: ripple.MdcRipple }
]; };
MdcButton.propDecorators = {
raised: [{ type: core.Input }],
unelevated: [{ type: core.Input }],
outlined: [{ type: core.Input }],
touch: [{ type: core.Input }],
disabled: [{ type: core.Input }],
_icon: [{ type: core.ContentChild, args: [icon.MdcIcon, { static: true },] }],
label: [{ type: core.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: core.NgModule, args: [{
imports: [
common.CommonModule
],
exports: [MdcButton, MdcButtonLabel],
declarations: [MdcButton, MdcButtonLabel]
},] },
];
return MdcButtonModule;
}());
exports.MdcButton = MdcButton;
exports.MdcButtonLabel = MdcButtonLabel;
exports.MdcButtonModule = MdcButtonModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=web-button.umd.js.map