UNPKG

@pepperi/lib

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.1.

2 lines 15.8 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@angular/material/core"),require("@angular/material/form-field"),require("@angular/material/icon"),require("@pepperi/lib"),require("@pepperi/lib/icon"),require("@pepperi/lib/field-title"),require("@pepperi/lib/files-uploader"),require("jquery"),require("@ngx-translate/core"),require("@pepperi/lib/dialog")):"function"==typeof define&&define.amd?define("@pepperi/lib/image",["exports","@angular/core","@angular/common","@angular/forms","@angular/material/core","@angular/material/form-field","@angular/material/icon","@pepperi/lib","@pepperi/lib/icon","@pepperi/lib/field-title","@pepperi/lib/files-uploader","jquery","@ngx-translate/core","@pepperi/lib/dialog"],t):t(((e=e||self).pepperi=e.pepperi||{},e.pepperi.lib=e.pepperi.lib||{},e.pepperi.lib.image={}),e.ng.core,e.ng.common,e.ng.forms,e.ng.material.core,e.ng.material.formField,e.ng.material.icon,e.pepperi.lib,e.pepperi.lib.icon,e.pepperi.lib["field-title"],e.pepperi.lib["files-uploader"],e.jquery,e.translate,e.pepperi.lib.dialog)}(this,(function(e,t,n,i,r,l,a,o,p,d,s,c,m,u){"use strict";var g=function(e){return{"one-row":e}};function h(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"div",2),t.ɵɵelement(2,"pep-field-title",3),t.ɵɵelementStart(3,"files-uploader",4),t.ɵɵlistener("fileChanged",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).onFileChanged(e)}))("elementClicked",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).onFileClicked(e)})),t.ɵɵelementEnd(),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵproperty("ngClass",t.ɵɵpureFunction1(20,g,1==r.rowSpan)),t.ɵɵadvance(1),t.ɵɵproperty("label",r.label)("required",r.required)("disabled",r.disabled)("xAlignment",r.xAlignment)("showTitle",r.showTitle),t.ɵɵadvance(1),t.ɵɵproperty("id",r.key)("key",r.key)("layoutType",r.layoutType)("standAlone",r.standAlone)("src",r.srcLarge||r.src)("label",r.label)("required",r.required)("disabled",r.disabled)("xAlignment",r.xAlignment)("rowSpan",r.rowSpan)("controlType",r.controlType)("form",r.form)("acceptedExtensions",r.acceptImagesType)("sizeLimitMB",r.sizeLimitMB)}}var f=function(e,t,n){return{"left-alignment":e,"right-alignment":t,"center-alignment":n}};function C(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"div",5),t.ɵɵelementStart(2,"img",6),t.ɵɵlistener("click",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).itemImageClick(e)}))("error",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).errorHandler(e)})),t.ɵɵelementEnd(),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵproperty("ngClass",t.ɵɵpureFunction3(6,f,"1"==r.xAlignment||"0"==r.xAlignment,"2"==r.xAlignment,"3"==r.xAlignment)),t.ɵɵadvance(1),t.ɵɵstyleProp("max-height",r.fieldHeight),t.ɵɵproperty("id",r.key)("alt",r.label)("src",r.src,t.ɵɵsanitizeUrl)}}var y=function(e){return[e]};function F(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"div",5),t.ɵɵelementStart(2,"img",7),t.ɵɵlistener("click",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).itemImageClick(e)}))("error",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).errorHandler(e)}))("load",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).setTitle(e)})),t.ɵɵelementEnd(),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵproperty("ngClass",t.ɵɵpureFunction3(7,f,"1"==r.xAlignment||"0"==r.xAlignment,"2"==r.xAlignment,"3"==r.xAlignment)),t.ɵɵadvance(1),t.ɵɵstyleProp("max-height",r.fieldHeight),t.ɵɵproperty("id",r.key)("ngClass",t.ɵɵpureFunction1(11,y,"text-align-"+r.xAlignment))("alt",r.label)("src",r.src,t.ɵɵsanitizeUrl)}}var v=function(e,t,n,i){return{bottom:e,top:t,left:n,right:i}};function b(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"button",8),t.ɵɵlistener("click",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).enterChildren(e)})),t.ɵɵelementStart(2,"mat-icon"),t.ɵɵelement(3,"pep-icon",9),t.ɵɵelementEnd(),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵproperty("id",r.key)("ngClass",t.ɵɵpureFunction4(2,v,"2"==(null==r.menuField||null==r.menuField.Layout?null:r.menuField.Layout.YAlignment),"1"==(null==r.menuField||null==r.menuField.Layout?null:r.menuField.Layout.YAlignment),"1"==(null==r.menuField||null==r.menuField.Layout?null:r.menuField.Layout.XAlignment),"2"==(null==r.menuField||null==r.menuField.Layout?null:r.menuField.Layout.XAlignment)))}}function x(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"span",10),t.ɵɵelementStart(2,"mat-icon",11),t.ɵɵelement(3,"pep-icon",12),t.ɵɵelementEnd(),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵpropertyInterpolate("title",null==i.hasCampaignField?null:i.hasCampaignField.FormattedValue),t.ɵɵproperty("id",i.key)("ngClass",t.ɵɵpureFunction4(3,v,"2"==(null==i.hasCampaignField||null==i.hasCampaignField.Layout?null:i.hasCampaignField.Layout.YAlignment),"1"==(null==i.hasCampaignField||null==i.hasCampaignField.Layout?null:i.hasCampaignField.Layout.YAlignment),"1"==(null==i.hasCampaignField||null==i.hasCampaignField.Layout?null:i.hasCampaignField.Layout.XAlignment),"2"==(null==i.hasCampaignField||null==i.hasCampaignField.Layout?null:i.hasCampaignField.Layout.XAlignment)))}}function M(e,n){1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelement(1,"pep-icon",15),t.ɵɵelementContainerEnd())}function I(e,n){1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelement(1,"pep-icon",16),t.ɵɵelementContainerEnd())}function S(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"span",13),t.ɵɵelementStart(2,"mat-icon"),t.ɵɵtemplate(3,M,2,0,"ng-container",14),t.ɵɵtemplate(4,I,2,0,"ng-container",1),t.ɵɵelementEnd(),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵproperty("id",i.key)("ngClass",t.ɵɵpureFunction4(4,v,"2"==(null==i.indicatorsField||null==i.indicatorsField.Layout?null:i.indicatorsField.Layout.YAlignment),"1"==(null==i.indicatorsField||null==i.indicatorsField.Layout?null:i.indicatorsField.Layout.YAlignment),"1"==(null==i.indicatorsField||null==i.indicatorsField.Layout?null:i.indicatorsField.Layout.XAlignment),"2"==(null==i.indicatorsField||null==i.indicatorsField.Layout?null:i.indicatorsField.Layout.XAlignment))),t.ɵɵadvance(2),t.ɵɵproperty("ngForOf",null==i.indicatorsField||null==i.indicatorsField.FormattedValue?null:i.indicatorsField.FormattedValue.split(";")),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",(null==i.indicatorsField||null==i.indicatorsField.FormattedValue?null:i.indicatorsField.FormattedValue.split(";").length)<4)}}function P(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelementContainerStart(1),t.ɵɵtemplate(2,h,4,22,"ng-container",1),t.ɵɵtemplate(3,C,3,10,"ng-container",1),t.ɵɵtemplate(4,F,3,13,"ng-container",1),t.ɵɵelementContainerEnd(),t.ɵɵtemplate(5,b,4,7,"ng-container",1),t.ɵɵtemplate(6,x,4,8,"ng-container",1),t.ɵɵtemplate(7,S,5,9,"ng-container",1),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵnextContext();t.ɵɵadvance(2),t.ɵɵproperty("ngIf",i.layoutType===i.LAYOUT_TYPE.PepperiForm),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",i.layoutType===i.LAYOUT_TYPE.PepperiCard),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",i.layoutType===i.LAYOUT_TYPE.PepperiTable),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",i.menuField),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",i.hasCampaignField&&(null==i.hasCampaignField?null:i.hasCampaignField.FormattedValue)),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",i.indicatorsField&&""!=(null==i.indicatorsField?null:i.indicatorsField.FormattedValue))}}var w=function(){function e(e,n,i,r,l,a){this.translate=e,this.dialogService=n,this.customizationService=i,this.fileService=r,this.renderer=l,this.element=a,this.key="",this.srcLarge="",this.src="",this.options=null,this.label="",this.type="image",this.required=!1,this.disabled=!1,this.readonly=!1,this.xAlignment="0",this.rowSpan=1,this.indicatorsField=null,this.menuField=null,this.hasCampaignField=null,this.controlType="image",this.form=null,this.objectId=null,this.showTitle=!0,this.layoutType=o.LAYOUT_TYPE.PepperiForm,this.isActive=!1,this.sizeLimitMB=5,this.acceptImagesType="bmp,jpg,jpeg,png,gif",this.valueChanged=new t.EventEmitter,this.elementClicked=new t.EventEmitter,this.LAYOUT_TYPE=o.LAYOUT_TYPE,this.fieldHeight="",this.standAlone=!1,this.dataURI=null}return e.prototype.ngOnInit=function(){null===this.form&&(this.standAlone=!0,this.form=this.customizationService.getDefaultFromGroup(this.key,this.src,this.required,this.readonly,this.disabled),this.renderer.addClass(this.element.nativeElement,o.CustomizationService.STAND_ALONE_FIELD_CLASS_NAME)),this.fieldHeight=this.customizationService.calculateFieldHeight(this.layoutType,this.rowSpan,this.standAlone)},e.prototype.ngOnChanges=function(e){var t,n;(null===(n=null===(t=e.src)||void 0===t?void 0:t.currentValue)||void 0===n?void 0:n.length)>0&&(this.dataURI=null)},e.prototype.ngOnDestroy=function(){this.elementClicked&&this.elementClicked.unsubscribe(),this.valueChanged&&this.valueChanged.unsubscribe()},e.prototype.errorHandler=function(e){e.target.src=this.fileService.getNoImagePath(),e.target.title=this.translate.instant("NoImage")},e.prototype.setTitle=function(e){e.target.style.visibility="visible",e.target.title=0===e.target.title.length?this.translate.instant("ClickToEnlarge"):e.target.title},e.prototype.enterChildren=function(t){this.elementClicked.emit({apiName:e.ENTER_CHILDREN,eventWhich:t.which})},e.prototype.onFileChanged=function(e){this.dataURI=e.length>0?JSON.parse(e):null,this.src=this.srcLarge=this.standAlone&&this.dataURI?this.dataURI.fileStr:"",this.customizationService.updateFormFieldValue(this.form,this.key,this.dataURI?this.dataURI.fileExt:""),this.valueChanged.emit({apiName:this.key,value:e,controlType:this.controlType})},e.prototype.onFileClicked=function(e){var t=!0;this.objectId&&this.src&&this.src.indexOf("no-image")>-1&&(t=!1),this.openImageModal(t),this.elementClicked.emit({apiName:this.key,eventWhich:e.which})},e.prototype.itemImageClick=function(e){var t=!0;(c(e.target).attr("src")&&c(e.target).attr("src").indexOf("no-image")>-1||c(e.target).next("img").length&&c(e.target).next("img").attr("src").indexOf("no-image")>-1)&&(t=!1),this.openImageModal(t)},e.prototype.openImageModal=function(e){if(this.dataURI){var t=this.dataURI.fileStr.split(";");if(2===t.length){var n=window.open("","_blank"),i=t[0].split(":")[1],r=t[1].split(",")[1],l=this.fileService.convertFromb64toBlob(r,i),a=URL.createObjectURL(l);n.location.href=a}}},e}();w.ENTER_CHILDREN="[EnterChildren]",w.ɵfac=function(e){return new(e||w)(t.ɵɵdirectiveInject(m.TranslateService),t.ɵɵdirectiveInject(u.DialogService),t.ɵɵdirectiveInject(o.CustomizationService),t.ɵɵdirectiveInject(o.FileService),t.ɵɵdirectiveInject(t.Renderer2),t.ɵɵdirectiveInject(t.ElementRef))},w.ɵcmp=t.ɵɵdefineComponent({type:w,selectors:[["pep-image"]],inputs:{key:"key",srcLarge:"srcLarge",src:"src",options:"options",label:"label",type:"type",required:"required",disabled:"disabled",readonly:"readonly",xAlignment:"xAlignment",rowSpan:"rowSpan",indicatorsField:"indicatorsField",menuField:"menuField",hasCampaignField:"hasCampaignField",form:"form",objectId:"objectId",showTitle:"showTitle",layoutType:"layoutType",isActive:"isActive",sizeLimitMB:"sizeLimitMB",acceptImagesType:"acceptImagesType"},outputs:{valueChanged:"valueChanged",elementClicked:"elementClicked"},features:[t.ɵɵNgOnChangesFeature],decls:2,vars:2,consts:[[3,"formGroup"],[4,"ngIf"],[1,"pepperi-file-container","image-container",3,"ngClass"],[3,"label","required","disabled","xAlignment","showTitle"],[3,"id","key","layoutType","standAlone","src","label","required","disabled","xAlignment","rowSpan","controlType","form","acceptedExtensions","sizeLimitMB","fileChanged","elementClicked"],[1,"img-wrapper",3,"ngClass"],[1,"pepperi-report-file",3,"id","alt","src","click","error"],[1,"pepperi-report-file","pepperi-report-img",3,"id","ngClass","alt","src","click","error","load"],[1,"floating-field","pepperi-button","icon-button","weak","invert",3,"id","ngClass","click"],["name","system_menu"],[1,"campaign","floating-field",3,"id","title","ngClass"],[1,"has-active-campaign"],["name","system_bolt"],[1,"indicators-container","floating-field",3,"id","ngClass"],[4,"ngFor","ngForOf"],["name","indicator_dot_placeholder","fill","value",1,"pull-left","flip"],["name","indicator_dot_placeholder",1,"pull-left","flip"]],template:function(e,n){1&e&&(t.ɵɵelementContainerStart(0,0),t.ɵɵtemplate(1,P,8,6,"ng-container",1),t.ɵɵelementContainerEnd()),2&e&&(t.ɵɵproperty("formGroup",n.form),t.ɵɵadvance(1),t.ɵɵproperty("ngIf","images"!==n.type))},directives:[i.NgControlStatusGroup,i.FormGroupDirective,n.NgIf,n.NgClass,d.PepperiFieldTitleComponent,s.FilesUploaderComponent,a.MatIcon,p.PepperiIconComponent,n.NgForOf],styles:["[_nghost-%COMP%]{display:-ms-grid;display:grid;height:inherit;width:100%}[_nghost-%COMP%] > *[_ngcontent-%COMP%]{-ms-grid-row-align:center;align-self:center}.img-wrapper[_ngcontent-%COMP%]{align-items:center;display:flex;height:100%;max-width:100%}.img-wrapper.left-alignment[_ngcontent-%COMP%]{justify-content:flex-start}.img-wrapper.center-alignment[_ngcontent-%COMP%]{justify-content:center}.img-wrapper.right-alignment[_ngcontent-%COMP%]{justify-content:flex-end}.img-wrapper[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{-o-object-fit:contain;height:100%;max-width:100%;object-fit:contain}.pepperi-file-container[_ngcontent-%COMP%]{height:100%}.pepperi-file-container[_ngcontent-%COMP%] .img-wrapper[_ngcontent-%COMP%]{height:calc(100% - 1.5rem)}.pepperi-file-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{cursor:pointer}.indicators-container[_ngcontent-%COMP%]{padding:0!important}.indicators-container[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{height:100%;padding:.4rem;width:100%}.indicators-container[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%] .svg-icon[_ngcontent-%COMP%]{height:.75rem;margin:.05rem;width:.75rem}.floating-field[_ngcontent-%COMP%]{border-radius:var(--pep-border-radius-md,.25rem);cursor:pointer;height:2.5rem;padding:.5rem;position:absolute;width:2.5rem}.top[_ngcontent-%COMP%]{top:0}.bottom[_ngcontent-%COMP%]{bottom:0}.left[_ngcontent-%COMP%]{left:0}.right[_ngcontent-%COMP%]{right:0}"],changeDetection:0});var A=function(e){this.pepperiIconRegistry=e,this.pepperiIconRegistry.registerIcons([p.pepperiIconSystemMenu,p.pepperiIconSystemBolt,p.pepperiIconIndicatorDotPlaceholder])};A.ɵmod=t.ɵɵdefineNgModule({type:A}),A.ɵinj=t.ɵɵdefineInjector({factory:function(e){return new(e||A)(t.ɵɵinject(p.PepperiIconRegistry))},imports:[[n.CommonModule,i.ReactiveFormsModule,i.FormsModule,r.MatCommonModule,l.MatFormFieldModule,a.MatIconModule,o.PepperiModule,p.PepperiIconModule,d.PepperiFieldTitleModule,s.PepperiFilesUploaderModule]]}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(A,{declarations:[w],imports:[n.CommonModule,i.ReactiveFormsModule,i.FormsModule,r.MatCommonModule,l.MatFormFieldModule,a.MatIconModule,o.PepperiModule,p.PepperiIconModule,d.PepperiFieldTitleModule,s.PepperiFilesUploaderModule],exports:[w]}),e.PepperiImageComponent=w,e.PepperiImageModule=A,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=pepperi-lib-image.umd.min.js.map