UNPKG

ngx-obelisco-example

Version:

Componentes funcionales y reutilizables para Angular.

80 lines (75 loc) 5.36 kB
import * as i0 from '@angular/core'; import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; class OSwitchComponent { constructor() { this.isDark = false; this.isDisabled = false; this.isSmall = false; this.isFixed = false; this.customClasses = ''; this.customClassesLabel = ''; this._switchValue = false; this.switchValueChange = new EventEmitter(); } set switchValue(value) { this._switchValue = this.isFixed ? true : value; } get switchValue() { return this._switchValue; } onSwitchChange() { if (this.isFixed) { return; } this.switchValue = !this.switchValue; this.switchValueChange.emit(this.switchValue); } } OSwitchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OSwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); OSwitchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: OSwitchComponent, selector: "o-switch", inputs: { id: "id", labelOn: "labelOn", labelOff: "labelOff", isDark: "isDark", isDisabled: "isDisabled", isSmall: "isSmall", isFixed: "isFixed", customClasses: "customClasses", customClassesLabel: "customClassesLabel", switchValue: "switchValue" }, outputs: { switchValueChange: "switchValueChange" }, ngImport: i0, template: "<label\r\n class=\"switch\"\r\n [class.switch-dark]=\"isDark\"\r\n [class.switch-sm]=\"isSmall\"\r\n [style.pointerEvents]=\"isFixed ? 'none' : null\"\r\n [ngClass]=\"customClasses\"\r\n [attr.for]=\"id\"\r\n>\r\n <input type=\"checkbox\" [attr.id]=\"id\" [disabled]=\"isDisabled\" [checked]=\"switchValue\" (change)=\"onSwitchChange()\" />\r\n <span class=\"slider\"></span>\r\n <span\r\n class=\"switch-label\"\r\n [class.on]=\"switchValue\"\r\n [class.off]=\"!switchValue\"\r\n [attr.disabled]=\"isDisabled ? true : null\"\r\n [ngClass]=\"customClassesLabel\"\r\n [attr.aria-label]=\"!labelOn && !labelOff ? (switchValue ? 'Prendido' : 'Apagado') : null\"\r\n >\r\n {{ switchValue ? labelOn : labelOff }}\r\n </span>\r\n</label>\r\n", styles: ["label.switch-label[disabled=true]{cursor:not-allowed}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OSwitchComponent, decorators: [{ type: Component, args: [{ selector: 'o-switch', template: "<label\r\n class=\"switch\"\r\n [class.switch-dark]=\"isDark\"\r\n [class.switch-sm]=\"isSmall\"\r\n [style.pointerEvents]=\"isFixed ? 'none' : null\"\r\n [ngClass]=\"customClasses\"\r\n [attr.for]=\"id\"\r\n>\r\n <input type=\"checkbox\" [attr.id]=\"id\" [disabled]=\"isDisabled\" [checked]=\"switchValue\" (change)=\"onSwitchChange()\" />\r\n <span class=\"slider\"></span>\r\n <span\r\n class=\"switch-label\"\r\n [class.on]=\"switchValue\"\r\n [class.off]=\"!switchValue\"\r\n [attr.disabled]=\"isDisabled ? true : null\"\r\n [ngClass]=\"customClassesLabel\"\r\n [attr.aria-label]=\"!labelOn && !labelOff ? (switchValue ? 'Prendido' : 'Apagado') : null\"\r\n >\r\n {{ switchValue ? labelOn : labelOff }}\r\n </span>\r\n</label>\r\n", styles: ["label.switch-label[disabled=true]{cursor:not-allowed}\n"] }] }], propDecorators: { id: [{ type: Input }], labelOn: [{ type: Input }], labelOff: [{ type: Input }], isDark: [{ type: Input }], isDisabled: [{ type: Input }], isSmall: [{ type: Input }], isFixed: [{ type: Input }], customClasses: [{ type: Input }], customClassesLabel: [{ type: Input }], switchValue: [{ type: Input }], switchValueChange: [{ type: Output }] } }); class OSwitchModule { } OSwitchModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OSwitchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); OSwitchModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: OSwitchModule, declarations: [OSwitchComponent], imports: [CommonModule], exports: [OSwitchComponent] }); OSwitchModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OSwitchModule, imports: [CommonModule] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OSwitchModule, decorators: [{ type: NgModule, args: [{ declarations: [OSwitchComponent], imports: [CommonModule], exports: [OSwitchComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { OSwitchComponent, OSwitchModule }; //# sourceMappingURL=ngx-obelisco-example-switch.mjs.map