@pepperi/ngx-lib
Version:
Pepperi Angular Components and Services
3 lines (2 loc) • 11.7 kB
JavaScript
!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/checkbox"),require("@angular/material/icon"),require("@pepperi/ngx-lib"),require("@pepperi/ngx-lib/icon"),require("@pepperi/ngx-lib/field-title"),require("@ngx-translate/core"),require("@angular/cdk/bidi")):"function"==typeof define&&define.amd?define("@pepperi/ngx-lib/checkbox",["exports","@angular/core","@angular/common","@angular/forms","@angular/material/core","@angular/material/form-field","@angular/material/checkbox","@angular/material/icon","@pepperi/ngx-lib","@pepperi/ngx-lib/icon","@pepperi/ngx-lib/field-title","@ngx-translate/core","@angular/cdk/bidi"],t):t(((e=e||self)["pepperi-addons"]=e["pepperi-addons"]||{},e["pepperi-addons"]["ngx-lib"]=e["pepperi-addons"]["ngx-lib"]||{},e["pepperi-addons"]["ngx-lib"].checkbox={}),e.ng.core,e.ng.common,e.ng.forms,e.ng.material.core,e.ng.material.formField,e.ng.material.checkbox,e.ng.material.icon,e["pepperi-addons"]["ngx-lib"],e["pepperi-addons"]["ngx-lib"].icon,e["pepperi-addons"]["ngx-lib"]["field-title"],e.translate,e.ng.cdk.bidi)}(this,(function(e,t,n,a,i,r,l,o,p,c,d,u,s){"use strict";function m(e,n){1&e&&t.ɵɵelementContainer(0)}function g(e,n){if(1&e&&(t.ɵɵelementStart(0,"span",10),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var a=t.ɵɵnextContext(3);t.ɵɵadvance(1),t.ɵɵtextInterpolate(a.label)}}function f(e,n){if(1&e){var a=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"div",7),t.ɵɵlistener("click",(function(e){return t.ɵɵrestoreView(a),t.ɵɵnextContext(2).toggleChecked(e)})),t.ɵɵpipe(1,"translate"),t.ɵɵpipe(2,"translate"),t.ɵɵelementStart(3,"button",8),t.ɵɵtext(4),t.ɵɵelementEnd(),t.ɵɵtemplate(5,g,2,1,"span",9),t.ɵɵelementEnd()}if(2&e){var i=t.ɵɵnextContext(2);t.ɵɵproperty("title",(i.label.length>0?i.label+": ":"")+("true"==i.value.toLowerCase()||"1"==i.value?t.ɵɵpipeBind1(1,4,"CHECKBOX.TRUE"):t.ɵɵpipeBind1(2,6,"CHECKBOX.FALSE"))),t.ɵɵadvance(3),t.ɵɵproperty("id",i.key),t.ɵɵadvance(1),t.ɵɵtextInterpolate1(" ","true"==i.value.toLowerCase()||"1"==i.value?i.additionalValueObject.CheckedText:i.additionalValueObject.UncheckedText," "),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",i.label.length>0&&i.layoutType!==i.LAYOUT_TYPE.PepperiTable)}}function h(e,n){if(1&e&&(t.ɵɵelementStart(0,"span"),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var a=t.ɵɵnextContext(3);t.ɵɵadvance(1),t.ɵɵtextInterpolate(a.label)}}function x(e,n){if(1&e){var a=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"mat-checkbox",11),t.ɵɵlistener("change",(function(e){return t.ɵɵrestoreView(a),t.ɵɵnextContext(2).onMaterialChange(e)})),t.ɵɵpipe(1,"translate"),t.ɵɵpipe(2,"translate"),t.ɵɵtemplate(3,h,2,1,"span",2),t.ɵɵelementEnd()}if(2&e){var i=t.ɵɵnextContext(2);t.ɵɵproperty("name",i.key)("title",(i.label.length>0?i.label+": ":"")+("true"==i.value.toLowerCase()||"1"==i.value?t.ɵɵpipeBind1(1,5,"CHECKBOX.TRUE"):t.ɵɵpipeBind1(2,7,"CHECKBOX.FALSE")))("checked","true"==i.value.toLowerCase()||"1"==i.value)("disabled",i.disabled),t.ɵɵadvance(3),t.ɵɵproperty("ngIf",i.label.length>0&&i.layoutType!==i.LAYOUT_TYPE.PepperiTable)}}var b=function(e,t,n,a,i,r,l){return{disable:e,"pepperi-report-checkbox":t,"pepperi-card-checkbox":n,"one-row":a,"no-title":i,"right-alignment pull-right flip":r,"center-alignment":l}};function y(e,n){if(1&e&&(t.ɵɵelementStart(0,"div",3),t.ɵɵtemplate(1,m,1,0,"ng-container",4),t.ɵɵtemplate(2,f,6,8,"ng-template",null,5,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,x,4,9,"ng-template",null,6,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd()),2&e){var a=t.ɵɵreference(3),i=t.ɵɵreference(5),r=t.ɵɵnextContext();t.ɵɵpropertyInterpolate("dir","2"==r.xAlignment?"rtl":"ltr"),t.ɵɵproperty("ngClass",t.ɵɵpureFunction7(5,b,r.disabled,r.layoutType===r.LAYOUT_TYPE.PepperiTable&&!r.isActive,r.layoutType===r.LAYOUT_TYPE.PepperiCard,1===r.rowSpan,0==r.label.length,"2"==r.xAlignment,"3"==r.xAlignment)),t.ɵɵadvance(1),t.ɵɵproperty("ngIf","booleanText"==r.type)("ngIfThen",a)("ngIfElse",i)}}function C(e,n){1&e&&t.ɵɵelementContainer(0)}function v(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelement(1,"pep-field-title",12),t.ɵɵtemplate(2,C,1,0,"ng-container",13),t.ɵɵelementContainerEnd()),2&e){var a=t.ɵɵnextContext(),i=t.ɵɵreference(2);t.ɵɵadvance(1),t.ɵɵproperty("label",a.label)("required",a.required)("disabled",a.disabled)("xAlignment",a.xAlignment)("showTitle",!1),t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",i)}}function T(e,n){1&e&&t.ɵɵelementContainer(0)}function E(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,T,1,0,"ng-container",13),t.ɵɵelementContainerEnd()),2&e){t.ɵɵnextContext();var a=t.ɵɵreference(2);t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",a)}}function k(e,n){1&e&&t.ɵɵelementContainer(0)}function I(e,n){1&e&&t.ɵɵelementContainer(0)}function M(e,n){1&e&&(t.ɵɵelementStart(0,"mat-icon",18),t.ɵɵpipe(1,"translate"),t.ɵɵelement(2,"pep-icon",19),t.ɵɵelementEnd()),2&e&&t.ɵɵpropertyInterpolate("title",t.ɵɵpipeBind1(1,1,"CHECKBOX.TRUE"))}function O(e,n){1&e&&(t.ɵɵelementStart(0,"span"),t.ɵɵtext(1," "),t.ɵɵelementEnd())}function A(e,n){if(1&e&&(t.ɵɵtemplate(0,I,1,0,"ng-container",4),t.ɵɵtemplate(1,M,3,3,"ng-template",null,16,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(3,O,2,0,"ng-template",null,17,t.ɵɵtemplateRefExtractor)),2&e){var a=t.ɵɵreference(2),i=t.ɵɵreference(4),r=t.ɵɵnextContext(2);t.ɵɵproperty("ngIf","true"==r.value.toLowerCase()||"1"==r.value)("ngIfThen",a)("ngIfElse",i)}}function P(e,n){1&e&&t.ɵɵelementContainer(0)}function S(e,n){if(1&e&&t.ɵɵtemplate(0,P,1,0,"ng-container",13),2&e){t.ɵɵnextContext(2);var a=t.ɵɵreference(2);t.ɵɵproperty("ngTemplateOutlet",a)}}function w(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,k,1,0,"ng-container",4),t.ɵɵtemplate(2,A,5,3,"ng-template",null,14,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,S,1,1,"ng-template",null,15,t.ɵɵtemplateRefExtractor),t.ɵɵelementContainerEnd()),2&e){var a=t.ɵɵreference(3),i=t.ɵɵreference(5),r=t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngIf","ItemHasActiveCampaign"===r.key)("ngIfThen",a)("ngIfElse",i)}}function F(e,n){1&e&&t.ɵɵelementContainer(0)}function L(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelement(1,"pep-field-title",12),t.ɵɵtemplate(2,F,1,0,"ng-container",13),t.ɵɵelementContainerEnd()),2&e){var a=t.ɵɵnextContext(),i=t.ɵɵreference(2);t.ɵɵadvance(1),t.ɵɵproperty("label",a.label)("required",a.required)("disabled",a.disabled)("xAlignment",a.xAlignment)("showTitle",!1),t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",i)}}var Y=function(){function e(e,n,a,i){this.renderer=e,this.customizationService=n,this.translate=a,this.element=i,this.key="",this.value="",this.label="",this.type="checkbox",this.required=!1,this.disabled=!1,this.readonly=!1,this.xAlignment="0",this.rowSpan=1,this.controlType="checkbox",this.form=null,this.isActive=!1,this.showTitle=!0,this.layoutType=p.LAYOUT_TYPE.PepperiForm,this.valueChanged=new t.EventEmitter,this.LAYOUT_TYPE=p.LAYOUT_TYPE,this.standAlone=!1,this.jsonLib=JSON}return e.prototype.ngOnInit=function(){if(null===this.form&&(this.standAlone=!0,this.form=this.customizationService.getDefaultFromGroup(this.key,this.value,this.required,this.readonly,this.disabled,0,"",!0),this.renderer.addClass(this.element.nativeElement,p.CustomizationService.STAND_ALONE_FIELD_CLASS_NAME)),"booleanText"===this.type)try{"string"==typeof this.additionalValue?this.additionalValueObject=JSON.parse(this.additionalValue):this.additionalValueObject=this.additionalValue}catch(e){this.additionalValueObject={CheckedText:this.translate.instant("CHECKBOX.TRUE"),UncheckedText:this.translate.instant("CHECKBOX.FALSE")}}},e.prototype.ngOnDestroy=function(){this.valueChanged&&this.valueChanged.unsubscribe()},e.prototype.onMaterialChange=function(e){this.changeValue(e.checked)},e.prototype.toggleChecked=function(e){if(!this.disabled){var t="true"===this.value||"1"===this.value;this.value=(!t).toString(),this.changeValue(this.value)}},e.prototype.changeValue=function(e){this.customizationService.updateFormFieldValue(this.form,this.key,e),this.valueChanged.emit({apiName:this.key,value:e})},e}();Y.ɵfac=function(e){return new(e||Y)(t.ɵɵdirectiveInject(t.Renderer2),t.ɵɵdirectiveInject(p.CustomizationService),t.ɵɵdirectiveInject(u.TranslateService),t.ɵɵdirectiveInject(t.ElementRef))},Y.ɵcmp=t.ɵɵdefineComponent({type:Y,selectors:[["pep-checkbox"]],inputs:{key:"key",value:"value",label:"label",type:"type",required:"required",disabled:"disabled",readonly:"readonly",xAlignment:"xAlignment",rowSpan:"rowSpan",additionalValue:"additionalValue",form:"form",isActive:"isActive",showTitle:"showTitle",layoutType:"layoutType"},outputs:{valueChanged:"valueChanged"},decls:7,vars:5,consts:[[3,"formGroup"],["pepperiTemplate",""],[4,"ngIf"],[1,"pepperi-checkbox-container","pepperi-input",3,"ngClass","dir"],[4,"ngIf","ngIfThen","ngIfElse"],["booleanTextTemplate",""],["regularTemplate",""],[1,"mat-checkbox-layout","body-sm",3,"title","click"],[1,"mat-icon-button","emoji-icon","pull-left","flip",3,"id"],["class","mat-checkbox-label emoji-title",4,"ngIf"],[1,"mat-checkbox-label","emoji-title"],["type","checkbox",1,"body-sm","ellipsis",3,"name","title","checked","disabled","change"],[3,"label","required","disabled","xAlignment","showTitle"],[4,"ngTemplateOutlet"],["itemCampaignBlock",""],["checkboxBlock",""],["trueTemplate",""],["falseTemplate",""],[1,"has-active-campaign",3,"title"],["name","system_bolt"]],template:function(e,n){1&e&&(t.ɵɵelementContainerStart(0,0),t.ɵɵtemplate(1,y,6,13,"ng-template",null,1,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(3,v,3,6,"ng-container",2),t.ɵɵtemplate(4,E,2,1,"ng-container",2),t.ɵɵtemplate(5,w,6,3,"ng-container",2),t.ɵɵtemplate(6,L,3,6,"ng-container",2),t.ɵɵelementContainerEnd()),2&e&&(t.ɵɵproperty("formGroup",n.form),t.ɵɵadvance(3),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),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",n.layoutType===n.LAYOUT_TYPE.Editmodal))},directives:[a.NgControlStatusGroup,a.FormGroupDirective,n.NgIf,n.NgClass,s.Dir,l.MatCheckbox,d.PepperiFieldTitleComponent,n.NgTemplateOutlet,o.MatIcon,c.PepperiIconComponent],pipes:[u.TranslatePipe],styles:["[_nghost-%COMP%]{display:-ms-grid;display:grid;height:inherit}[_nghost-%COMP%] > *[_ngcontent-%COMP%]{-ms-grid-row-align:center;align-self:center}"],changeDetection:0});var q=function(e){this.pepperiIconRegistry=e,this.pepperiIconRegistry.registerIcons([c.pepperiIconSystemBolt])};q.ɵmod=t.ɵɵdefineNgModule({type:q}),q.ɵinj=t.ɵɵdefineInjector({factory:function(e){return new(e||q)(t.ɵɵinject(c.PepperiIconRegistry))},imports:[[n.CommonModule,a.ReactiveFormsModule,a.FormsModule,i.MatCommonModule,r.MatFormFieldModule,l.MatCheckboxModule,o.MatIconModule,p.PepperiModule,c.PepperiIconModule,d.PepperiFieldTitleModule]]}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(q,{declarations:[Y],imports:[n.CommonModule,a.ReactiveFormsModule,a.FormsModule,i.MatCommonModule,r.MatFormFieldModule,l.MatCheckboxModule,o.MatIconModule,p.PepperiModule,c.PepperiIconModule,d.PepperiFieldTitleModule],exports:[Y]}),e.PepperiCheckboxComponent=Y,e.PepperiCheckboxModule=q,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=pepperi-addons-ngx-lib-checkbox.umd.min.js.map