import * as i0 from '@angular/core'; import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChildren, NgModule } from '@angular/core'; import * as i2 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i1 from 'primeng/api'; import { PrimeTemplate, SharedModule } from 'primeng/api'; import { trigger, transition, style, animate } from '@angular/animations'; import { DomHandler } from 'primeng/dom'; import { ZIndexUtils } from 'primeng/utils'; class Image { constructor(config, cd) { this.config = config; this.cd = cd; this.preview = false; this.showTransitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)'; this.hideTransitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)'; this.onShow = new EventEmitter(); this.onHide = new EventEmitter(); this.maskVisible = false; this.previewVisible = false; this.rotate = 0; this.scale = 1; this.previewClick = false; } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'indicator': this.indicatorTemplate = item.template; break; default: this.indicatorTemplate = item.template; break; } }); } onImageClick() { if (this.preview) { this.maskVisible = true; this.previewVisible = true; } } onMaskClick() { if (!this.previewClick) { this.previewVisible = false; this.rotate = 0; this.scale = 1; } this.previewClick = false; } onPreviewImageClick() { this.previewClick = true; } rotateRight() { this.rotate += 90; this.previewClick = true; } rotateLeft() { this.rotate -= 90; this.previewClick = true; } zoomIn() { this.scale = this.scale + 0.1; this.previewClick = true; } zoomOut() { this.scale = this.scale - 0.1; this.previewClick = true; } zoomDisabled() { return this.scale <= 0.5 || this.scale >= 1.5; } onAnimationStart(event) { switch (event.toState) { case 'visible': this.container = event.element; this.wrapper = this.container.parentElement; this.appendContainer(); this.moveOnTop(); break; case 'void': DomHandler.addClass(this.wrapper, 'p-component-overlay-leave'); break; } } onAnimationEnd(event) { switch (event.toState) { case 'void': ZIndexUtils.clear(this.container); this.maskVisible = false; this.container = null; this.wrapper = null; this.cd.markForCheck(); this.onHide.emit({}); break; case 'visible': this.onShow.emit({}); break; } } moveOnTop() { ZIndexUtils.set('modal', this.container, this.config.zIndex.modal); this.wrapper.style.zIndex = String(parseInt(this.container.style.zIndex, 10) - 1); } appendContainer() { if (this.appendTo) { if (this.appendTo === 'body') document.body.appendChild(this.wrapper); else DomHandler.appendChild(this.wrapper, this.appendTo); } } imagePreviewStyle() { return { transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')' }; } containerClass() { return { 'p-image p-component': true, 'p-image-preview-container': this.preview }; } } Image.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Image, deps: [{ token: i1.PrimeNGConfig }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); Image.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Image, selector: "p-image", inputs: { imageClass: "imageClass", imageStyle: "imageStyle", styleClass: "styleClass", style: "style", src: "src", alt: "alt", width: "width", height: "height", appendTo: "appendTo", preview: "preview", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions" }, outputs: { onShow: "onShow", onHide: "onHide" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "mask", first: true, predicate: ["mask"], descendants: true }], ngImport: i0, template: `
`, isInline: true, styles: [".p-image-mask{display:flex;align-items:center;justify-content:center}.p-image-preview-container{position:relative;display:inline-block}.p-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .3s}.p-image-preview-icon{font-size:1.5rem}.p-image-preview-container:hover>.p-image-preview-indicator{opacity:1;cursor:pointer}.p-image-preview-container>img{cursor:pointer}.p-image-toolbar{position:absolute;top:0;right:0;display:flex}.p-image-action.p-link{display:flex;justify-content:center;align-items:center}.p-image-preview{transition:transform .15s;max-width:100vw;max-height:100vh}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], animations: [ trigger('animation', [ transition('void => visible', [ style({ transform: 'scale(0.7)', opacity: 0 }), animate('{{showTransitionParams}}') ]), transition('visible => void', [ animate('{{hideTransitionParams}}', style({ transform: 'scale(0.7)', opacity: 0 })) ]) ]) ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Image, decorators: [{ type: Component, args: [{ selector: 'p-image', template: `
`, animations: [ trigger('animation', [ transition('void => visible', [ style({ transform: 'scale(0.7)', opacity: 0 }), animate('{{showTransitionParams}}') ]), transition('visible => void', [ animate('{{hideTransitionParams}}', style({ transform: 'scale(0.7)', opacity: 0 })) ]) ]) ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' }, styles: [".p-image-mask{display:flex;align-items:center;justify-content:center}.p-image-preview-container{position:relative;display:inline-block}.p-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .3s}.p-image-preview-icon{font-size:1.5rem}.p-image-preview-container:hover>.p-image-preview-indicator{opacity:1;cursor:pointer}.p-image-preview-container>img{cursor:pointer}.p-image-toolbar{position:absolute;top:0;right:0;display:flex}.p-image-action.p-link{display:flex;justify-content:center;align-items:center}.p-image-preview{transition:transform .15s;max-width:100vw;max-height:100vh}\n"] }] }], ctorParameters: function () { return [{ type: i1.PrimeNGConfig }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { imageClass: [{ type: Input }], imageStyle: [{ type: Input }], styleClass: [{ type: Input }], style: [{ type: Input }], src: [{ type: Input }], alt: [{ type: Input }], width: [{ type: Input }], height: [{ type: Input }], appendTo: [{ type: Input }], preview: [{ type: Input }], showTransitionOptions: [{ type: Input }], hideTransitionOptions: [{ type: Input }], onShow: [{ type: Output }], onHide: [{ type: Output }], mask: [{ type: ViewChild, args: ['mask'] }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }] } }); class ImageModule { } ImageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); ImageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, declarations: [Image], imports: [CommonModule], exports: [Image, SharedModule] }); ImageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, imports: [[CommonModule], SharedModule] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], exports: [Image, SharedModule], declarations: [Image] }] }] }); /** * Generated bundle index. Do not edit. */ export { Image, ImageModule };