mat-progress-buttons
Version:
Material Design Progress Buttons
212 lines (198 loc) • 7.69 kB
JavaScript
import { Component, Input, Output, HostListener, EventEmitter, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatButtonModule, MatProgressBarModule, MatProgressSpinnerModule, MatRippleModule, MatIconModule } from '@angular/material';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class MatSpinnerButtonComponent {
constructor() {
this.btnClick = new EventEmitter();
}
/**
* @param {?} event
* @return {?}
*/
onClick(event) {
if (!this.options.disabled && !this.options.active) {
this.btnClick.emit(event);
}
}
}
MatSpinnerButtonComponent.decorators = [
{ type: Component, args: [{
// tslint:disable-next-line:component-selector
selector: 'mat-spinner-button',
template: `
<button mat-button
[]="options.type"
[]="options.buttonColor"
[]="options.active"
[]="options.fullWidth"
[]="options.raised"
[]="options.stroked"
[]="options.flat"
[]="options.fab"
[]="options.customClass"
[]="options.active || options.disabled">
<ng-container
*ngIf="options.buttonIcon">
<mat-icon
class="mat-button-icon"
[]="!options.buttonIcon.fontSet"
[]="options.active && !options.disabled"
[]="options.buttonIcon.customClass"
[]="options.buttonIcon.fontSet"
[]="options.buttonIcon.fontIcon"
[]="options.buttonIcon.color"
[]="options.buttonIcon.svgIcon"
[]="options.buttonIcon.inline">
{{ options.buttonIcon.fontSet ? '' : options.buttonIcon.fontIcon }}
</mat-icon>
</ng-container>
<span
class="button-text"
*ngIf="!options.fab"
[]="options.active && !options.disabled">
{{ options.text }}
</span>
<ng-container
*ngIf="options.fab && options.icon">
<mat-icon
[]="options.icon.fontSet"
[]="options.icon.fontIcon"
[]="options.icon.color"
[]="options.icon.svgIcon"
[]="options.icon.inline">
{{ options.icon.fontSet ? '' : options.icon.fontIcon }}
</mat-icon>
</ng-container>
<mat-spinner class="spinner"
[]="options.fab ? 58 : options.spinnerSize"
[]="options.spinnerColor"
[]="options.mode"
[]="options.value"
[]="options.active && !options.disabled">
</mat-spinner>
</button>
`,
styles: [`
:host button{outline:none}:host button.active{cursor:not-allowed}:host button/deep/ .mat-button-wrapper{display:flex;align-items:center;justify-content:center}:host button.fullWidth{width:100%}:host button.mat-fab .spinner{margin-top:-15px}:host button .spinner{position:absolute;top:25%;opacity:0;transition:opacity .3s ease-in-out}:host button .spinner.active{opacity:1}:host button .button-text{opacity:1;transition:opacity .3s ease-in-out}:host button .button-text.active{opacity:0}:host button mat-icon.mat-button-icon{padding-right:5px;transition:opacity .3s ease-in-out}:host button mat-icon.mat-button-icon.is-mat-icon{font-size:18px;position:relative;top:3px}:host button mat-icon.mat-button-icon.active{opacity:0}
`]
},] },
];
MatSpinnerButtonComponent.propDecorators = {
options: [{ type: Input }],
btnClick: [{ type: Output }],
onClick: [{ type: HostListener, args: ['click', ['$event'],] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class MatBarButtonComponent {
constructor() {
this.btnClick = new EventEmitter();
}
/**
* @param {?} event
* @return {?}
*/
onClick(event) {
if (!this.options.disabled && !this.options.active) {
this.btnClick.emit(event);
}
}
}
MatBarButtonComponent.decorators = [
{ type: Component, args: [{
// tslint:disable-next-line:component-selector
selector: 'mat-bar-button',
template: `
<button mat-button
[]="options.type"
[]="options.buttonColor"
[]="options.active"
[]="options.raised"
[]="options.stroked"
[]="options.flat"
[]="options.fullWidth"
[]="options.customClass"
[]="options.active || options.disabled">
<ng-container
*ngIf="options.buttonIcon">
<mat-icon
[]="!options.buttonIcon.fontSet"
[]="options.buttonIcon.customClass"
[]="options.buttonIcon.fontSet"
[]="options.buttonIcon.fontIcon"
[]="options.buttonIcon.color"
[]="options.buttonIcon.svgIcon"
[]="options.buttonIcon.inline">
{{ options.buttonIcon.fontSet ? '' : options.buttonIcon.fontIcon }}
</mat-icon>
</ng-container>
<span>{{ options.text }}</span>
<mat-progress-bar
class="bar"
*ngIf="options.active && !options.disabled"
[]="options.barColor"
[]="options.mode"
[]="options.value">
</mat-progress-bar>
</button>
`,
styles: [`
:host button.active{cursor:not-allowed}:host button.fullWidth{width:100%}:host button .bar{position:absolute;top:0;left:0}:host button mat-icon{padding-right:5px}:host button mat-icon.is-mat-icon{font-size:18px;position:relative;top:3px}
`]
},] },
];
MatBarButtonComponent.propDecorators = {
options: [{ type: Input }],
btnClick: [{ type: Output }],
onClick: [{ type: HostListener, args: ['click', ['$event'],] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class MatProgressButtonsModule {
/**
* @return {?}
*/
static forRoot() {
return {
ngModule: MatProgressButtonsModule
};
}
}
MatProgressButtonsModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
MatButtonModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRippleModule,
MatIconModule
],
exports: [
MatSpinnerButtonComponent,
MatBarButtonComponent
],
declarations: [
MatSpinnerButtonComponent,
MatBarButtonComponent
]
},] },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { MatSpinnerButtonComponent, MatBarButtonComponent, MatProgressButtonsModule };
//# sourceMappingURL=mat-progress-buttons.js.map