UNPKG

@pepperi/lib

Version:

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

2 lines 10.2 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("@pepperi/lib"),require("@pepperi/lib/field-title"),require("@pepperi/lib/files-uploader")):"function"==typeof define&&define.amd?define("@pepperi/lib/attachment",["exports","@angular/core","@angular/common","@angular/forms","@angular/material/core","@angular/material/form-field","@pepperi/lib","@pepperi/lib/field-title","@pepperi/lib/files-uploader"],t):t(((e=e||self).pepperi=e.pepperi||{},e.pepperi.lib=e.pepperi.lib||{},e.pepperi.lib.attachment={}),e.ng.core,e.ng.common,e.ng.forms,e.ng.material.core,e.ng.material.formField,e.pepperi.lib,e.pepperi.lib["field-title"],e.pepperi.lib["files-uploader"])}(this,(function(e,t,n,i,r,l,a,o,p){"use strict";function c(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"files-uploader",3),t.ɵɵlistener("fileChanged",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext().onFileChanged(e)}))("elementClicked",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext().onFileClicked(e)})),t.ɵɵelementEnd()}if(2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("key",r.key)("src",r.src)("label",r.label)("required",r.required)("disabled",r.disabled)("xAlignment",r.xAlignment)("rowSpan",r.rowSpan)("controlType",r.controlType)("form",r.form)("layoutType",r.layoutType)("standAlone",r.standAlone)("acceptedExtensions",r.acceptAttachmentType)}}function s(e,n){1&e&&t.ɵɵelementContainer(0)}function d(e,n){if(1&e&&(t.ɵɵelementStart(0,"a",9),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var i=t.ɵɵnextContext(3);t.ɵɵpropertyInterpolate("title",i.src),t.ɵɵpropertyInterpolate("href",i.src,t.ɵɵsanitizeUrl),t.ɵɵproperty("id",i.key),t.ɵɵadvance(1),t.ɵɵtextInterpolate(i.src)}}function m(e,n){if(1&e&&(t.ɵɵelementStart(0,"div",7),t.ɵɵtemplate(1,d,2,4,"a",8),t.ɵɵelementEnd()),2&e){var i=t.ɵɵnextContext(2);t.ɵɵadvance(1),t.ɵɵproperty("ngIf",null!=i.src)}}function u(e,n){1&e&&(t.ɵɵelementStart(0,"span"),t.ɵɵtext(1," "),t.ɵɵelementEnd())}function f(e,n){if(1&e&&(t.ɵɵtemplate(0,s,1,0,"ng-container",4),t.ɵɵtemplate(1,m,2,1,"ng-template",null,5,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(3,u,2,0,"ng-template",null,6,t.ɵɵtemplateRefExtractor)),2&e){var i=t.ɵɵreference(2),r=t.ɵɵreference(4),l=t.ɵɵnextContext();t.ɵɵproperty("ngIf",(null==l.src?null:l.src.length)>0)("ngIfThen",i)("ngIfElse",r)}}function h(e,n){1&e&&t.ɵɵelementContainer(0)}var g=function(e,t){return{"one-row":e,"stand-alone":t}};function y(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelementStart(1,"div",10),t.ɵɵelement(2,"pep-field-title",11),t.ɵɵtemplate(3,h,1,0,"ng-container",12),t.ɵɵelementEnd(),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵnextContext(),r=t.ɵɵreference(1);t.ɵɵadvance(1),t.ɵɵproperty("ngClass",t.ɵɵpureFunction2(7,g,1==i.rowSpan,i.standAlone)),t.ɵɵadvance(1),t.ɵɵproperty("label",i.label)("required",i.required)("disabled",i.disabled)("xAlignment",i.xAlignment)("showTitle",i.showTitle),t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",r)}}function v(e,n){1&e&&t.ɵɵelementContainer(0)}function C(e,n){1&e&&t.ɵɵelementContainer(0)}function x(e,n){if(1&e&&(t.ɵɵelementStart(0,"div",10),t.ɵɵtemplate(1,C,1,0,"ng-container",12),t.ɵɵelementEnd()),2&e){var i=t.ɵɵnextContext(2),r=t.ɵɵreference(1);t.ɵɵproperty("ngClass",t.ɵɵpureFunction2(2,g,1==i.rowSpan,i.standAlone)),t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",r)}}function T(e,n){1&e&&t.ɵɵelementContainer(0)}function b(e,n){if(1&e&&t.ɵɵtemplate(0,T,1,0,"ng-container",12),2&e){t.ɵɵnextContext(2);var i=t.ɵɵreference(3);t.ɵɵproperty("ngTemplateOutlet",i)}}function E(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,v,1,0,"ng-container",4),t.ɵɵtemplate(2,x,2,5,"ng-template",null,13,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,b,1,1,"ng-template",null,14,t.ɵɵtemplateRefExtractor),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵreference(3),r=t.ɵɵreference(5);t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!1)("ngIfThen",i)("ngIfElse",r)}}function I(e,n){1&e&&t.ɵɵelementContainer(0)}function S(e,n){1&e&&t.ɵɵelementContainer(0)}function A(e,n){if(1&e&&(t.ɵɵelementStart(0,"div",15),t.ɵɵtemplate(1,S,1,0,"ng-container",12),t.ɵɵelementEnd()),2&e){t.ɵɵnextContext(2);var i=t.ɵɵreference(1);t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",i)}}function k(e,n){1&e&&t.ɵɵelementContainer(0)}function w(e,n){if(1&e&&t.ɵɵtemplate(0,k,1,0,"ng-container",12),2&e){t.ɵɵnextContext(2);var i=t.ɵɵreference(3);t.ɵɵproperty("ngTemplateOutlet",i)}}function F(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,I,1,0,"ng-container",4),t.ɵɵtemplate(2,A,2,1,"ng-template",null,13,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,w,1,1,"ng-template",null,14,t.ɵɵtemplateRefExtractor),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵreference(3),r=t.ɵɵreference(5);t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!1)("ngIfThen",i)("ngIfElse",r)}}var M=function(){function e(e,n,i,r){this.customizationService=e,this.renderer=n,this.element=i,this.fileService=r,this.key="",this.src="",this.label="",this.required=!1,this.disabled=!1,this.readonly=!1,this.xAlignment="0",this.rowSpan=1,this.controlType="attachment",this.form=null,this.showTitle=!0,this.layoutType=a.LAYOUT_TYPE.PepperiForm,this.isActive=!1,this.valueChanged=new t.EventEmitter,this.elementClicked=new t.EventEmitter,this.LAYOUT_TYPE=a.LAYOUT_TYPE,this.fieldHeight="",this.standAlone=!1,this.dataURI=null,this.acceptAttachmentType="application/pdf,application/json,text/csv,text/csv-schema,application/msword,application/vnd.ms-excel,text/plain,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.wordprocessingml.document,image/bmp,image/jpg, image/jpeg, image/png, image/tif, image/tiff, txt, json"}return e.prototype.ngOnDestroy=function(){this.elementClicked&&this.elementClicked.unsubscribe(),this.valueChanged&&this.valueChanged.unsubscribe()},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,a.CustomizationService.STAND_ALONE_FIELD_CLASS_NAME)),this.fieldHeight=this.customizationService.calculateFieldHeight(this.layoutType,this.rowSpan,this.standAlone)},e.prototype.ngOnChanges=function(e){e.src&&e.src.currentValue.length>0&&(this.dataURI=null)},e.prototype.onFileChanged=function(e){this.dataURI=e.length>0?JSON.parse(e):null,this.src=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){if(null!=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}}else{if(this.fileService.isValidUrl(this.src))(n=window.open("","_blank")).location.href=this.src}this.elementClicked.emit({apiName:this.key,eventWhich:e.which})},e}();M.ɵfac=function(e){return new(e||M)(t.ɵɵdirectiveInject(a.CustomizationService),t.ɵɵdirectiveInject(t.Renderer2),t.ɵɵdirectiveInject(t.ElementRef),t.ɵɵdirectiveInject(a.FileService))},M.ɵcmp=t.ɵɵdefineComponent({type:M,selectors:[["pep-attachment"]],inputs:{key:"key",src:"src",label:"label",required:"required",disabled:"disabled",readonly:"readonly",xAlignment:"xAlignment",rowSpan:"rowSpan",form:"form",showTitle:"showTitle",layoutType:"layoutType",isActive:"isActive"},outputs:{valueChanged:"valueChanged",elementClicked:"elementClicked"},features:[t.ɵɵNgOnChangesFeature],decls:7,vars:3,consts:[["pepperiTemplate",""],["pepperiReadonlyTemplate",""],[4,"ngIf"],[3,"key","src","label","required","disabled","xAlignment","rowSpan","controlType","form","layoutType","standAlone","acceptedExtensions","fileChanged","elementClicked"],[4,"ngIf","ngIfThen","ngIfElse"],["notEmptyBlock",""],["emptyBlock",""],[1,"pepperi-file-container"],["class","color-link body-sm pepperi-card-input ","target","_blank",3,"id","title","href",4,"ngIf"],["target","_blank",1,"color-link","body-sm","pepperi-card-input",3,"id","title","href"],[1,"pepperi-file-container",3,"ngClass"],[3,"label","required","disabled","xAlignment","showTitle"],[4,"ngTemplateOutlet"],["selectedBlock",""],["notSelectedBlock",""],[1,"pepperi-file-container","one-row"]],template:function(e,n){1&e&&(t.ɵɵtemplate(0,c,1,12,"ng-template",null,0,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(2,f,5,3,"ng-template",null,1,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,y,4,10,"ng-container",2),t.ɵɵtemplate(5,E,6,3,"ng-container",2),t.ɵɵtemplate(6,F,6,3,"ng-container",2)),2&e&&(t.ɵɵadvance(4),t.ɵɵproperty("ngIf",n.layoutType===n.LAYOUT_TYPE.PepperiForm),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",n.layoutType===n.LAYOUT_TYPE.PepperiCard),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",n.layoutType===n.LAYOUT_TYPE.PepperiTable))},directives:[n.NgIf,p.FilesUploaderComponent,n.NgClass,o.PepperiFieldTitleComponent,n.NgTemplateOutlet],styles:["[_nghost-%COMP%]{display:block}"],changeDetection:0});var R=function(){};R.ɵmod=t.ɵɵdefineNgModule({type:R}),R.ɵinj=t.ɵɵdefineInjector({factory:function(e){return new(e||R)},imports:[[n.CommonModule,i.ReactiveFormsModule,i.FormsModule,r.MatCommonModule,l.MatFormFieldModule,a.PepperiModule,o.PepperiFieldTitleModule,p.PepperiFilesUploaderModule]]}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(R,{declarations:[M],imports:[n.CommonModule,i.ReactiveFormsModule,i.FormsModule,r.MatCommonModule,l.MatFormFieldModule,a.PepperiModule,o.PepperiFieldTitleModule,p.PepperiFilesUploaderModule],exports:[M]}),e.PepperiAttachmentComponent=M,e.PepperiAttachmentModule=R,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=pepperi-lib-attachment.umd.min.js.map