[59329aa] | 1 | {"version":3,"file":"primeng-image.mjs","sources":["../../src/app/components/image/image.ts","../../src/app/components/image/primeng-image.ts"],"sourcesContent":["import { NgModule, Component, Input, ElementRef, ContentChild, ChangeDetectionStrategy, ViewEncapsulation, TemplateRef, AfterContentInit, ContentChildren, QueryList, Output, EventEmitter, ChangeDetectorRef, ViewChild } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SharedModule, PrimeTemplate, PrimeNGConfig } from 'primeng/api';\nimport {trigger,style,transition,animate, AnimationEvent,} from '@angular/animations';\nimport { DomHandler } from 'primeng/dom';\nimport { ZIndexUtils } from 'primeng/utils';\n\n@Component({\n selector: 'p-image',\n template: `\n <span [ngClass]=\"containerClass()\" [class]=\"styleClass\" [ngStyle]=\"style\">\n <img [attr.src]=\"src\" [attr.alt]=\"alt\" [attr.width]=\"width\" [attr.height]=\"height\" [ngStyle]=\"imageStyle\" [class]=\"imageClass\" />\n <div class=\"p-image-preview-indicator\" *ngIf=\"preview\" (click)=\"onImageClick()\">\n <ng-container *ngIf=\"indicatorTemplate;else defaultTemplate\">\n <ng-container *ngTemplateOutlet=\"indicatorTemplate\"></ng-container>\n </ng-container>\n <ng-template #defaultTemplate>\n <i class=\"p-image-preview-icon pi pi-eye\"></i>\n </ng-template>\n </div>\n <div #mask class=\"p-image-mask p-component-overlay p-component-overlay-enter\" *ngIf=\"maskVisible\" (click)=\"onMaskClick()\">\n <div class=\"p-image-toolbar\">\n <button class=\"p-image-action p-link\" (click)=\"rotateRight()\" type=\"button\">\n <i class=\"pi pi-refresh\"></i>\n </button>\n <button class=\"p-image-action p-link\" (click)=\"rotateLeft()\" type=\"button\">\n <i class=\"pi pi-undo\"></i>\n </button>\n <button class=\"p-image-action p-link\" (click)=\"zoomOut()\" type=\"button\" [disabled]=\"zoomDisabled()\">\n <i class=\"pi pi-search-minus\"></i>\n </button>\n <button class=\"p-image-action p-link\" (click)=\"zoomIn()\" type=\"button\" [disabled]=\"zoomDisabled()\">\n <i class=\"pi pi-search-plus\"></i>\n </button>\n <button class=\"p-image-action p-link\" type=\"button\">\n <i class=\"pi pi-times\"></i>\n </button>\n </div>\n <div *ngIf=\"previewVisible\" [@animation]=\"{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}\"\n (@animation.start)=\"onAnimationStart($event)\" (@animation.done)=\"onAnimationEnd($event)\">\n <img [attr.src]=\"src\" class=\"p-image-preview\" [ngStyle]=\"imagePreviewStyle()\" (click)=\"onPreviewImageClick()\"/>\n </div>\n </div>\n </span>\n `,\n animations: [\n trigger('animation', [\n transition('void => visible', [\n style({ transform: 'scale(0.7)', opacity: 0 }),\n animate('{{showTransitionParams}}')\n ]),\n transition('visible => void', [\n animate('{{hideTransitionParams}}', style({ transform: 'scale(0.7)', opacity: 0 }))\n ])\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./image.css'],\n host: {\n 'class': 'p-element'\n }\n})\nexport class Image implements AfterContentInit {\n\n @Input() imageClass: string;\n\n @Input() imageStyle: any;\n\n @Input() styleClass: string;\n\n @Input() style: any;\n\n @Input() src: string;\n\n @Input() alt: string;\n\n @Input() width: string;\n\n @Input() height: string;\n\n @Input() appendTo: any;\n\n @Input() preview: boolean = false;\n\n @Input() showTransitionOptions: string = '150ms cubic-bezier(0, 0, 0.2, 1)';\n\n @Input() hideTransitionOptions: string = '150ms cubic-bezier(0, 0, 0.2, 1)';\n\n @Output() onShow: EventEmitter<any> = new EventEmitter();\n\n @Output() onHide: EventEmitter<any> = new EventEmitter();\n\n @ViewChild('mask') mask: ElementRef;\n\n @ContentChildren(PrimeTemplate) templates: QueryList<any>;\n\n indicatorTemplate: TemplateRef<any>;\n\n maskVisible: boolean = false;\n\n previewVisible: boolean = false;\n\n rotate: number = 0;\n\n scale: number = 1;\n\n previewClick: boolean = false;\n\n container: HTMLElement;\n\n wrapper: HTMLElement;\n\n constructor(private config: PrimeNGConfig, private cd: ChangeDetectorRef) { }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'indicator':\n this.indicatorTemplate = item.template;\n break;\n\n default:\n this.indicatorTemplate = item.template;\n break;\n }\n });\n }\n\n onImageClick() {\n if (this.preview) {\n this.maskVisible = true;\n this.previewVisible = true;\n }\n }\n\n onMaskClick() {\n if (!this.previewClick) {\n this.previewVisible = false;\n this.rotate = 0;\n this.scale = 1;\n }\n\n this.previewClick = false;\n }\n\n onPreviewImageClick() {\n this.previewClick = true;\n }\n\n rotateRight() {\n this.rotate += 90;\n this.previewClick = true;\n }\n\n rotateLeft() {\n this.rotate -= 90;\n this.previewClick = true;\n }\n\n zoomIn() {\n this.scale = this.scale + 0.1;\n this.previewClick = true;\n }\n\n zoomOut() {\n this.scale = this.scale - 0.1;\n this.previewClick = true;\n }\n\n zoomDisabled() {\n return this.scale <= 0.5 || this.scale >= 1.5;\n }\n\n onAnimationStart(event: AnimationEvent) {\n switch(event.toState) {\n case 'visible':\n this.container = event.element;\n this.wrapper = this.container.parentElement;\n this.appendContainer();\n this.moveOnTop();\n break;\n\n case 'void':\n DomHandler.addClass(this.wrapper, 'p-component-overlay-leave');\n break;\n }\n }\n\n onAnimationEnd(event: AnimationEvent) {\n switch(event.toState) {\n case 'void':\n ZIndexUtils.clear(this.container);\n this.maskVisible = false;\n this.container = null;\n this.wrapper = null;\n this.cd.markForCheck();\n this.onHide.emit({});\n break;\n case 'visible':\n this.onShow.emit({});\n break;\n }\n }\n\n moveOnTop() {\n ZIndexUtils.set('modal', this.container, this.config.zIndex.modal);\n this.wrapper.style.zIndex = String(parseInt(this.container.style.zIndex, 10) - 1);\n }\n\n appendContainer() {\n if (this.appendTo) {\n if (this.appendTo === 'body')\n document.body.appendChild(this.wrapper);\n else\n DomHandler.appendChild(this.wrapper, this.appendTo);\n }\n }\n\n imagePreviewStyle() {\n return {transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')'};\n }\n\n containerClass() {\n return {\n 'p-image p-component': true,\n 'p-image-preview-container': this.preview\n };\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Image, SharedModule],\n declarations: [Image]\n})\nexport class ImageModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;MA+Da,KAAK;IAkDd,YAAoB,MAAqB,EAAU,EAAqB;QAApD,WAAM,GAAN,MAAM,CAAe;QAAU,OAAE,GAAF,EAAE,CAAmB;QA9B/D,YAAO,GAAY,KAAK,CAAC;QAEzB,0BAAqB,GAAW,kCAAkC,CAAC;QAEnE,0BAAqB,GAAW,kCAAkC,CAAC;QAElE,WAAM,GAAsB,IAAI,YAAY,EAAE,CAAC;QAE/C,WAAM,GAAsB,IAAI,YAAY,EAAE,CAAC;QAQzD,gBAAW,GAAY,KAAK,CAAC;QAE7B,mBAAc,GAAa,KAAK,CAAC;QAEjC,WAAM,GAAW,CAAC,CAAC;QAEnB,UAAK,GAAW,CAAC,CAAC;QAElB,iBAAY,GAAY,KAAK,CAAC;KAM+C;IAE7E,kBAAkB;QACd,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI;YACxB,QAAO,IAAI,CAAC,OAAO,EAAE;gBACjB,KAAK,WAAW;oBACZ,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC;oBAC3C,MAAM;gBAEN;oBACI,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC;oBAC3C,MAAM;aACT;SACJ,CAAC,CAAC;KACN;IAED,YAAY;QACR,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC9B;KACJ;IAED,WAAW;QACP,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACpB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAC5B,IAAI,CAAC,MAA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