@duoduo-oba/ng-devui
Version:
DevUI components based on Angular
153 lines (147 loc) • 11.9 kB
JavaScript
import { CommonModule } from '@angular/common';
import { EventEmitter, Component, Input, Output, ViewChild, Directive, ElementRef, NgModule } from '@angular/core';
import { LoadingModule } from '@duoduo-oba/ng-devui/loading';
/**
* @fileoverview added by tsickle
* Generated from: button.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class ButtonComponent {
constructor() {
this.type = 'button';
this.bsStyle = 'primary';
this.bsSize = 'md';
this.disabled = false;
this.showLoading = false;
this.autofocus = false;
this.btnClick = new EventEmitter();
}
// 新增click事件,解决直接在host上使用click,IE在disabled状态下还能触发事件
/**
* @param {?} event
* @return {?}
*/
onClick(event) {
this.btnClick.emit(event);
}
/**
* @return {?}
*/
hasContent() {
return !!this.buttonContent && this.buttonContent.nativeElement && this.buttonContent.nativeElement.innerHTML.trim();
}
}
ButtonComponent.decorators = [
{ type: Component, args: [{
selector: 'd-button',
template: "<button\r\n [attr.id]=\"id\"\r\n d-btn\r\n class=\"devui-btn devui-btn-{{ bsStyle }} devui-btn-{{ bsSize }}\"\r\n [type]=\"type\"\r\n [disabled]=\"disabled\"\r\n [class.bordered]=\"bordered\"\r\n [class.devui-loading]=\"showLoading\"\r\n [showLoading]=\"showLoading\"\r\n [loadingTemplateRef]=\"buttonWithLoading\"\r\n [backdrop]=\"true\"\r\n dLoading\r\n [ngStyle]=\"{ width: width }\"\r\n [dBtnAutofocus]=\"autofocus\"\r\n (click)=\"onClick($event)\"\r\n [ngClass]=\"{ 'd-btn-icon': !!icon && !hasContent() }\"\r\n>\r\n <span *ngIf=\"!!icon\" class=\"devui-icon-fix icon {{ icon }}\"></span\r\n ><!--\r\n --><span class=\"button-content\" #buttonContent><ng-content></ng-content></span>\r\n</button>\r\n\r\n<ng-template #buttonWithLoading>\r\n <div class=\"devui-loading-spinner-wrapper\">\r\n <div class=\"devui-loading-default-spinner\">\r\n <div class=\"bar1\"></div>\r\n <div class=\"bar2\"></div>\r\n <div class=\"bar3\"></div>\r\n <div class=\"bar4\"></div>\r\n <div class=\"bar5\"></div>\r\n <div class=\"bar6\"></div>\r\n <div class=\"bar7\"></div>\r\n <div class=\"bar8\"></div>\r\n <div class=\"bar9\"></div>\r\n <div class=\"bar10\"></div>\r\n <div class=\"bar11\"></div>\r\n <div class=\"bar12\"></div>\r\n </div>\r\n </div>\r\n</ng-template>\r\n",
styles: [".devui-btn{padding:5px 20px;font-size:14px;height:32px;line-height:20px;border-radius:1px;background-color:transparent;-webkit-transition:.2s;transition:.2s;white-space:nowrap;border:1px solid transparent}.devui-btn.devui-btn-text{color:#5e7ce0;padding:0}.devui-btn.devui-btn-text-dark{color:#252b3a;padding:0}.devui-btn.devui-btn-common{color:#252b3a;min-width:80px;background-color:#fff;border-color:#adb0b8}.devui-btn.devui-btn-primary,.devui-btn.devui-btn-stress{color:#fff;min-width:80px;background-color:#5e7ce0}.devui-btn.devui-btn-xs{padding:1px 5px;height:28px;font-size:12px}.devui-btn.devui-btn-sm{padding:5px 10px;height:30px;font-size:12px}.devui-btn.devui-btn-lg{padding:10px 16px;height:46px;font-size:18px}.devui-btn.devui-btn-text-dark:active,.devui-btn.devui-btn-text-dark:focus,.devui-btn.devui-btn-text-dark:hover,.devui-btn.devui-btn-text:active,.devui-btn.devui-btn-text:focus,.devui-btn.devui-btn-text:hover{background-color:transparent;color:#344899}.devui-btn.devui-btn-common:active,.devui-btn.devui-btn-common:focus,.devui-btn.devui-btn-common:hover{border-color:#344899}.devui-btn.devui-btn-primary:active,.devui-btn.devui-btn-primary:focus,.devui-btn.devui-btn-primary:hover,.devui-btn.devui-btn-stress:active,.devui-btn.devui-btn-stress:focus,.devui-btn.devui-btn-stress:hover{background-color:#344899}.devui-btn.devui-btn-common:disabled{color:#252b3a;opacity:.3;background:#fff;border:1px solid #adb0b8}.devui-btn.devui-btn-primary:disabled{color:#252b3a;background:#fff;border:1px solid #adb0b8}.devui-btn.devui-btn-text-dark:disabled{color:#252b3a;background:#fff}.devui-btn.bordered.devui-btn-common{color:#252b3a;border-color:transparent}.devui-btn.bordered.devui-btn-common:active,.devui-btn.bordered.devui-btn-common:focus,.devui-btn.bordered.devui-btn-common:hover{border-color:#344899}.devui-btn.bordered.devui-btn-primary,.devui-btn.bordered.devui-btn-stress{border-color:#5e7ce0;color:#5e7ce0;background-color:#fff}.devui-btn.bordered.devui-btn-success{border-color:#50d4ab;color:#50d4ab;background-color:#fff}.devui-btn.bordered.devui-btn-warning{border-color:#fac20a;color:#fac20a;background-color:#fff}.devui-btn.bordered.devui-btn-danger{border-color:#f66f6a;color:#f66f6a;background-color:#fff}.devui-btn.d-btn-icon:focus,.devui-btn.d-btn-icon:hover{border:1px solid #f2f5fc;background-color:#f2f5fc}.devui-btn.d-btn-icon:disabled{background-color:#fff}:host{display:inline-block}.devui-btn:disabled,.devui-btn[disabled]{cursor:not-allowed;opacity:.3}.devui-btn.d-btn-icon{padding:7px 8px;line-height:1em;border:1px solid transparent}.devui-btn:not(.d-btn-icon) .icon-fix{font-size:16px}.devui-loading .devui-loading-spinner-wrapper{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:1001}.devui-loading .devui-loading-default-spinner{position:relative;display:inline-block;vertical-align:middle;width:20px;height:20px}.devui-loading .devui-loading-default-spinner div{background-color:#252b3a;position:absolute;left:44.5%;top:37%;width:10%;height:26%;border-radius:50px;opacity:0;-webkit-animation:1s linear infinite spinner-anim;animation:1s linear infinite spinner-anim}.devui-loading .devui-loading-default-spinner .bar1{-webkit-transform:rotate(0) translate(0,-142%);transform:rotate(0) translate(0,-142%);-webkit-animation-delay:-1s;animation-delay:-1s}.devui-loading .devui-loading-default-spinner .bar2{-webkit-transform:rotate(30deg) translate(0,-142%);transform:rotate(30deg) translate(0,-142%);-webkit-animation-delay:-.91667s;animation-delay:-.91667s}.devui-loading .devui-loading-default-spinner .bar3{-webkit-transform:rotate(60deg) translate(0,-142%);transform:rotate(60deg) translate(0,-142%);-webkit-animation-delay:-.83333s;animation-delay:-.83333s}.devui-loading .devui-loading-default-spinner .bar4{-webkit-transform:rotate(90deg) translate(0,-142%);transform:rotate(90deg) translate(0,-142%);-webkit-animation-delay:-.75s;animation-delay:-.75s}.devui-loading .devui-loading-default-spinner .bar5{-webkit-transform:rotate(120deg) translate(0,-142%);transform:rotate(120deg) translate(0,-142%);-webkit-animation-delay:-.66667s;animation-delay:-.66667s}.devui-loading .devui-loading-default-spinner .bar6{-webkit-transform:rotate(150deg) translate(0,-142%);transform:rotate(150deg) translate(0,-142%);-webkit-animation-delay:-.58333s;animation-delay:-.58333s}.devui-loading .devui-loading-default-spinner .bar7{-webkit-transform:rotate(180deg) translate(0,-142%);transform:rotate(180deg) translate(0,-142%);-webkit-animation-delay:-.5s;animation-delay:-.5s}.devui-loading .devui-loading-default-spinner .bar8{-webkit-transform:rotate(210deg) translate(0,-142%);transform:rotate(210deg) translate(0,-142%);-webkit-animation-delay:-.41667s;animation-delay:-.41667s}.devui-loading .devui-loading-default-spinner .bar9{-webkit-transform:rotate(240deg) translate(0,-142%);transform:rotate(240deg) translate(0,-142%);-webkit-animation-delay:-.33333s;animation-delay:-.33333s}.devui-loading .devui-loading-default-spinner .bar10{-webkit-transform:rotate(270deg) translate(0,-142%);transform:rotate(270deg) translate(0,-142%);-webkit-animation-delay:-.25s;animation-delay:-.25s}.devui-loading .devui-loading-default-spinner .bar11{-webkit-transform:rotate(300deg) translate(0,-142%);transform:rotate(300deg) translate(0,-142%);-webkit-animation-delay:-.16667s;animation-delay:-.16667s}.devui-loading .devui-loading-default-spinner .bar12{-webkit-transform:rotate(330deg) translate(0,-142%);transform:rotate(330deg) translate(0,-142%);-webkit-animation-delay:-83.33ms;animation-delay:-83.33ms}.devui-loading .devui-loading-default-text{display:inline-block;margin-left:6px;max-width:400px}@-webkit-keyframes spinner-anim{from{opacity:1}to{opacity:.25}}@keyframes spinner-anim{from{opacity:1}to{opacity:.25}}.devui-icon-fix{position:relative;top:2px}.button-content{display:inline-block;vertical-align:top}"]
}] }
];
/** @nocollapse */
ButtonComponent.ctorParameters = () => [];
ButtonComponent.propDecorators = {
id: [{ type: Input }],
type: [{ type: Input }],
bsStyle: [{ type: Input }],
bsSize: [{ type: Input }],
bordered: [{ type: Input }],
icon: [{ type: Input }],
disabled: [{ type: Input }],
showLoading: [{ type: Input }],
width: [{ type: Input }],
autofocus: [{ type: Input }],
btnClick: [{ type: Output }],
buttonContent: [{ type: ViewChild, args: ['buttonContent', { static: true },] }]
};
if (false) {
/** @type {?} */
ButtonComponent.prototype.id;
/** @type {?} */
ButtonComponent.prototype.type;
/** @type {?} */
ButtonComponent.prototype.bsStyle;
/** @type {?} */
ButtonComponent.prototype.bsSize;
/** @type {?} */
ButtonComponent.prototype.bordered;
/** @type {?} */
ButtonComponent.prototype.icon;
/** @type {?} */
ButtonComponent.prototype.disabled;
/** @type {?} */
ButtonComponent.prototype.showLoading;
/** @type {?} */
ButtonComponent.prototype.width;
/** @type {?} */
ButtonComponent.prototype.autofocus;
/** @type {?} */
ButtonComponent.prototype.btnClick;
/** @type {?} */
ButtonComponent.prototype.buttonContent;
}
class BtnAutoFocusDirective {
/**
* @param {?} element
*/
constructor(element) {
this.element = element;
this.dBtnAutofocus = false;
}
/**
* @return {?}
*/
ngOnInit() {
if (this.dBtnAutofocus) {
this.element.nativeElement.focus();
}
}
}
BtnAutoFocusDirective.decorators = [
{ type: Directive, args: [{
selector: '[dBtnAutofocus]',
},] }
];
/** @nocollapse */
BtnAutoFocusDirective.ctorParameters = () => [
{ type: ElementRef }
];
BtnAutoFocusDirective.propDecorators = {
dBtnAutofocus: [{ type: Input }]
};
if (false) {
/** @type {?} */
BtnAutoFocusDirective.prototype.dBtnAutofocus;
/**
* @type {?}
* @private
*/
BtnAutoFocusDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* Generated from: button.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class ButtonModule {
}
ButtonModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule, LoadingModule],
exports: [ButtonComponent],
declarations: [ButtonComponent, BtnAutoFocusDirective],
providers: [],
},] }
];
/**
* @fileoverview added by tsickle
* Generated from: public-api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: ng-devui-button.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { BtnAutoFocusDirective, ButtonComponent, ButtonModule };
//# sourceMappingURL=ng-devui-button.js.map