UNPKG

ngx-obelisco-example

Version:

Componentes funcionales y reutilizables para Angular.

126 lines (119 loc) 6.57 kB
import * as i0 from '@angular/core'; import { Directive, Input, HostListener } from '@angular/core'; import { Subject, takeUntil } from 'rxjs'; import * as i1 from 'ngx-obelisco-example/core/services'; const DEFAULT_IMAGE = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ5jomR9foeDrKFgdh_LNV4dCK14fY3DPk-0Q&usqp=CAU'; class ODefaultImageDirective { constructor(imgHost, renderer) { this.imgHost = imgHost; this.renderer = renderer; } handleError() { const imageUrl = this.defaultImageUrl || DEFAULT_IMAGE; this.renderer.setAttribute(this.imgHost.nativeElement, 'src', imageUrl); } } ODefaultImageDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ODefaultImageDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); ODefaultImageDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ODefaultImageDirective, isStandalone: true, selector: "img[oDefaultImage]", inputs: { defaultImageUrl: "defaultImageUrl" }, host: { listeners: { "error": "handleError()" } }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ODefaultImageDirective, decorators: [{ type: Directive, args: [{ selector: 'img[oDefaultImage]', standalone: true }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { defaultImageUrl: [{ type: Input }], handleError: [{ type: HostListener, args: ['error'] }] } }); class StepNextDirective { constructor(stepService, element, renderer) { this.stepService = stepService; this.element = element; this.renderer = renderer; this.onDestroy$ = new Subject(); this.stepService.initialize(); } ngOnInit() { this.stepService.stopEmmiter.pipe(takeUntil(this.onDestroy$)).subscribe(() => { this.stepService.stop(); this.renderer.setProperty(this.element.nativeElement, 'disabled', true); }); } onClick() { this.stepService.next(); } ngOnDestroy() { this.onDestroy$.next(); this.onDestroy$.complete(); } } StepNextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: StepNextDirective, deps: [{ token: i1.StepService }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); StepNextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: StepNextDirective, isStandalone: true, selector: "[oStepNext]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: StepNextDirective, decorators: [{ type: Directive, args: [{ selector: '[oStepNext]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.StepService }, { type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { onClick: [{ type: HostListener, args: ['click'] }] } }); class StepPreviousDirective { constructor(stepService, element, renderer) { this.stepService = stepService; this.element = element; this.renderer = renderer; this.onDestroy$ = new Subject(); this.stepService.initialize(); } ngOnInit() { this.renderer.setProperty(this.element.nativeElement, 'disabled', true); this.stepService.isFirstStep.pipe(takeUntil(this.onDestroy$)).subscribe((event) => { this.renderer.setProperty(this.element.nativeElement, 'disabled', event); }); this.stepService.stopEmmiter.pipe(takeUntil(this.onDestroy$)).subscribe(() => { this.stepService.stop(); }); } onClick() { this.stepService.previous(); } ngOnDestroy() { this.onDestroy$.next(); this.onDestroy$.complete(); } } StepPreviousDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: StepPreviousDirective, deps: [{ token: i1.StepService }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); StepPreviousDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: StepPreviousDirective, isStandalone: true, selector: "[oStepPrevious]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: StepPreviousDirective, decorators: [{ type: Directive, args: [{ selector: '[oStepPrevious]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.StepService }, { type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { onClick: [{ type: HostListener, args: ['click'] }] } }); class OCustomContentDirective { constructor(template) { this.template = template; } } OCustomContentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OCustomContentDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); OCustomContentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: OCustomContentDirective, isStandalone: true, selector: "[oCustomContent]", ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: OCustomContentDirective, decorators: [{ type: Directive, args: [{ selector: '[oCustomContent]', standalone: true }] }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } }); /** * Generated bundle index. Do not edit. */ export { OCustomContentDirective, ODefaultImageDirective, StepNextDirective, StepPreviousDirective }; //# sourceMappingURL=ngx-obelisco-example-directives.mjs.map