UNPKG

ngx-obelisco-example

Version:

Componentes funcionales y reutilizables para Angular.

101 lines (96 loc) 7.91 kB
import * as i0 from '@angular/core'; import { Component, Input, NgModule } from '@angular/core'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i2 from '@angular/router'; import { RouterModule } from '@angular/router'; class OButtonComponent { constructor() { this.type = 'primary'; this.isOutline = false; this.size = 'md'; this.isExpandable = false; this.hasIcon = false; this.hasSpinner = false; this.customClasses = ''; } getSpinnerType() { const spinnerTypeMappings = { primary: 'dark', link: 'info', danger: 'danger', success: 'success', secondary: 'secondary' }; if ((this.type === 'secondary' || this.type === 'danger' || this.type === 'success') && !this.isOutline) { return 'light'; } return spinnerTypeMappings[this.type]; } getClassNames() { const sizeClass = this.size !== 'md' ? ' btn-' + this.size : ''; const outlineClass = this.isOutline ? ' btn-outline-' + this.type : ' btn-' + this.type; const expandableClass = this.isExpandable ? ' btn-block' : ''; const iconClass = this.hasIcon ? ' btn-icon' : ''; const customClass = this.customClasses ? ' ' + this.customClasses : ''; return 'btn' + outlineClass + sizeClass + expandableClass + iconClass + customClass; } } OButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); OButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: OButtonComponent, selector: "o-button", inputs: { type: "type", isOutline: "isOutline", size: "size", isExpandable: "isExpandable", hasIcon: "hasIcon", hasSpinner: "hasSpinner", ariaLabel: "ariaLabel", customClasses: "customClasses", route: "route", link: "link", target: "target", download: "download", rel: "rel", isDisabled: "isDisabled", dataTarget: "dataTarget", dataToggle: "dataToggle", dataDismiss: "dataDismiss" }, ngImport: i0, template: "<ng-template #content><ng-content></ng-content></ng-template>\r\n<ng-container *ngIf=\"link || route || download || rel || target; else isButton\">\r\n <ng-container *ngIf=\"link || download || rel || target; else isRouterLink\">\r\n <a\r\n [ngClass]=\"getClassNames()\"\r\n [attr.aria-label]=\"ariaLabel\"\r\n [attr.download]=\"download\"\r\n [attr.rel]=\"rel ? rel : 'noreferrer'\"\r\n [attr.target]=\"target ? target : '_blank'\"\r\n [attr.href]=\"link ? link : '#'\"\r\n >\r\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\r\n </a>\r\n </ng-container>\r\n <ng-template #isRouterLink>\r\n <a [ngClass]=\"getClassNames()\" [attr.aria-label]=\"ariaLabel\" [routerLink]=\"route\">\r\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\r\n </a>\r\n </ng-template>\r\n</ng-container>\r\n\r\n<ng-template #isButton>\r\n <button\r\n type=\"button\"\r\n [ngClass]=\"getClassNames()\"\r\n [attr.aria-label]=\"ariaLabel\"\r\n [disabled]=\"isDisabled ? true : null\"\r\n [attr.data-target]=\"dataTarget ? '#' + dataTarget : null\"\r\n [attr.data-toggle]=\"dataToggle\"\r\n [attr.data-dismiss]=\"dataDismiss\"\r\n >\r\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\r\n </button>\r\n</ng-template>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OButtonComponent, decorators: [{ type: Component, args: [{ selector: 'o-button', template: "<ng-template #content><ng-content></ng-content></ng-template>\r\n<ng-container *ngIf=\"link || route || download || rel || target; else isButton\">\r\n <ng-container *ngIf=\"link || download || rel || target; else isRouterLink\">\r\n <a\r\n [ngClass]=\"getClassNames()\"\r\n [attr.aria-label]=\"ariaLabel\"\r\n [attr.download]=\"download\"\r\n [attr.rel]=\"rel ? rel : 'noreferrer'\"\r\n [attr.target]=\"target ? target : '_blank'\"\r\n [attr.href]=\"link ? link : '#'\"\r\n >\r\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\r\n </a>\r\n </ng-container>\r\n <ng-template #isRouterLink>\r\n <a [ngClass]=\"getClassNames()\" [attr.aria-label]=\"ariaLabel\" [routerLink]=\"route\">\r\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\r\n </a>\r\n </ng-template>\r\n</ng-container>\r\n\r\n<ng-template #isButton>\r\n <button\r\n type=\"button\"\r\n [ngClass]=\"getClassNames()\"\r\n [attr.aria-label]=\"ariaLabel\"\r\n [disabled]=\"isDisabled ? true : null\"\r\n [attr.data-target]=\"dataTarget ? '#' + dataTarget : null\"\r\n [attr.data-toggle]=\"dataToggle\"\r\n [attr.data-dismiss]=\"dataDismiss\"\r\n >\r\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\r\n </button>\r\n</ng-template>\r\n" }] }], propDecorators: { type: [{ type: Input }], isOutline: [{ type: Input }], size: [{ type: Input }], isExpandable: [{ type: Input }], hasIcon: [{ type: Input }], hasSpinner: [{ type: Input }], ariaLabel: [{ type: Input }], customClasses: [{ type: Input }], route: [{ type: Input }], link: [{ type: Input }], target: [{ type: Input }], download: [{ type: Input }], rel: [{ type: Input }], isDisabled: [{ type: Input }], dataTarget: [{ type: Input }], dataToggle: [{ type: Input }], dataDismiss: [{ type: Input }] } }); class OButtonModule { } OButtonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); OButtonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: OButtonModule, declarations: [OButtonComponent], imports: [CommonModule, RouterModule], exports: [OButtonComponent] }); OButtonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OButtonModule, imports: [CommonModule, RouterModule] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OButtonModule, decorators: [{ type: NgModule, args: [{ declarations: [OButtonComponent], imports: [CommonModule, RouterModule], exports: [OButtonComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { OButtonComponent, OButtonModule }; //# sourceMappingURL=ngx-obelisco-example-button.mjs.map