UNPKG

@pepperi/lib

Version:

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

16 lines (14 loc) 17.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/button"),require("@angular/material/form-field"),require("@angular/material/select"),require("@angular/material/icon"),require("@pepperi/lib"),require("@pepperi/lib/icon"),require("@pepperi/lib/field-title"),require("@angular/cdk/bidi"),require("@ngx-translate/core")):"function"==typeof define&&define.amd?define("@pepperi/lib/select",["exports","@angular/core","@angular/common","@angular/forms","@angular/material/core","@angular/material/button","@angular/material/form-field","@angular/material/select","@angular/material/icon","@pepperi/lib","@pepperi/lib/icon","@pepperi/lib/field-title","@angular/cdk/bidi","@ngx-translate/core"],t):t(((e=e||self).pepperi=e.pepperi||{},e.pepperi.lib=e.pepperi.lib||{},e.pepperi.lib.select={}),e.ng.core,e.ng.common,e.ng.forms,e.ng.material.core,e.ng.material.button,e.ng.material.formField,e.ng.material.select,e.ng.material.icon,e.pepperi.lib,e.pepperi.lib.icon,e.pepperi.lib["field-title"],e.ng.cdk.bidi,e.translate)}(this,(function(e,t,n,i,r,l,a,o,p,d,s,u,c,m){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */Object.create;function f(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}Object.create;var g=["select"];function h(e,n){1&e&&t.ɵɵelementContainer(0)}function y(e,n){1&e&&(t.ɵɵelementStart(0,"mat-option",12),t.ɵɵtext(1),t.ɵɵpipe(2,"translate"),t.ɵɵelementEnd()),2&e&&(t.ɵɵadvance(1),t.ɵɵtextInterpolate(t.ɵɵpipeBind1(2,1,"None")))}function v(e,n){if(1&e&&(t.ɵɵelementStart(0,"mat-option",13),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var i=n.$implicit;t.ɵɵproperty("value",i.Key),t.ɵɵadvance(1),t.ɵɵtextInterpolate(i.Value)}}var C=function(e){return{"right-alignment":e}},x=function(){return{standalone:!0}},M=function(e){return{field:e}};function b(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"mat-form-field",6),t.ɵɵelementStart(1,"mat-select",7,8),t.ɵɵlistener("ngModelChange",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).selectedValueModel=e}))("selectionChange",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).selectionChange(e)}))("openedChange",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).openedChange(e)})),t.ɵɵpipe(3,"translate"),t.ɵɵtemplate(4,y,3,3,"mat-option",9),t.ɵɵtemplate(5,v,2,2,"mat-option",10),t.ɵɵelementEnd(),t.ɵɵelementStart(6,"mat-error"),t.ɵɵelement(7,"span",11),t.ɵɵpipe(8,"translate"),t.ɵɵpipe(9,"translate"),t.ɵɵelementEnd(),t.ɵɵelementEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵpropertyInterpolate("dir","2"===r.xAlignment?"rtl":"ltr"),t.ɵɵadvance(1),t.ɵɵclassMapInterpolate1("body-sm text-align-",r.xAlignment,""),t.ɵɵpropertyInterpolate("title",r.formattedValue),t.ɵɵproperty("required",r.required?r.required:void 0)("id",r.key)("ngClass",t.ɵɵpureFunction1(24,C,"2"==r.xAlignment))("placeholder",r.disabled||r.readonly?"":t.ɵɵpipeBind1(3,16,"Dropdown_Placeholder_Msg"))("ngModel",r.selectedValueModel)("ngModelOptions",t.ɵɵpureFunction0(26,x))("disabled",r.disabled),t.ɵɵadvance(3),t.ɵɵproperty("ngIf",r.emptyOption),t.ɵɵadvance(1),t.ɵɵproperty("ngForOf",r.options),t.ɵɵadvance(2),t.ɵɵproperty("title",t.ɵɵpipeBind2(8,18,"Msg_Is_Required",t.ɵɵpureFunction1(27,M,r.label)))("innerText",t.ɵɵpipeBind2(9,21,"Msg_Is_Required",t.ɵɵpureFunction1(29,M,r.label)))}}function I(e,n){if(1&e&&(t.ɵɵelementStart(0,"mat-option",13),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var i=n.$implicit;t.ɵɵproperty("value",i.Key),t.ɵɵadvance(1),t.ɵɵtextInterpolate(i.Value)}}function E(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"mat-form-field",6),t.ɵɵelementStart(1,"mat-select",14,8),t.ɵɵlistener("ngModelChange",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).selectedValuesModel=e}))("openedChange",(function(e){return t.ɵɵrestoreView(i),t.ɵɵnextContext(2).openedChange(e)})),t.ɵɵpipe(3,"translate"),t.ɵɵtemplate(4,I,2,2,"mat-option",10),t.ɵɵelementEnd(),t.ɵɵelementStart(5,"mat-error"),t.ɵɵelement(6,"span",11),t.ɵɵpipe(7,"translate"),t.ɵɵpipe(8,"translate"),t.ɵɵelementEnd(),t.ɵɵelementEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵpropertyInterpolate("dir","2"===r.xAlignment?"rtl":"ltr"),t.ɵɵadvance(1),t.ɵɵclassMapInterpolate1("body-sm text-align-",r.xAlignment,""),t.ɵɵpropertyInterpolate("title",r.formattedValue),t.ɵɵproperty("required",r.required?r.required:void 0)("id",r.key)("ngClass",t.ɵɵpureFunction1(23,C,"2"==r.xAlignment))("placeholder",r.disabled||r.readonly?"":t.ɵɵpipeBind1(3,15,"MultiDropdown_Placeholder_Msg"))("ngModel",r.selectedValuesModel)("ngModelOptions",t.ɵɵpureFunction0(25,x))("disabled",r.disabled),t.ɵɵadvance(3),t.ɵɵproperty("ngForOf",r.options),t.ɵɵadvance(2),t.ɵɵproperty("title",t.ɵɵpipeBind2(7,17,"Msg_Is_Required",t.ɵɵpureFunction1(26,M,r.label)))("innerText",t.ɵɵpipeBind2(8,20,"Msg_Is_Required",t.ɵɵpureFunction1(28,M,r.label)))}}function T(e,n){if(1&e&&(t.ɵɵtemplate(0,h,1,0,"ng-container",3),t.ɵɵtemplate(1,b,10,31,"ng-template",null,4,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(3,E,9,30,"ng-template",null,5,t.ɵɵtemplateRefExtractor)),2&e){var i=t.ɵɵreference(2),r=t.ɵɵreference(4),l=t.ɵɵnextContext();t.ɵɵproperty("ngIf","multi"==l.type)("ngIfThen",r)("ngIfElse",i)}}function S(e,n){if(1&e&&t.ɵɵelement(0,"pep-field-title",17),2&e){var i=t.ɵɵnextContext(2);t.ɵɵproperty("label",i.label)("required",i.required)("disabled",i.disabled)("xAlignment",i.xAlignment)("showTitle",i.showTitle)}}function F(e,n){1&e&&t.ɵɵelementContainer(0)}function V(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,S,1,5,"pep-field-title",15),t.ɵɵtemplate(2,F,1,0,"ng-container",16),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵnextContext(),r=t.ɵɵreference(2);t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!i.parentFieldKey),t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",r)}}function O(e,n){1&e&&t.ɵɵelementContainer(0)}function w(e,n){1&e&&t.ɵɵelementContainer(0)}var q=function(e){return{"one-row":e}};function A(e,n){if(1&e&&(t.ɵɵelementStart(0,"div",20),t.ɵɵtemplate(1,w,1,0,"ng-container",16),t.ɵɵelementEnd()),2&e){var i=t.ɵɵnextContext(2),r=t.ɵɵreference(2);t.ɵɵproperty("ngClass",t.ɵɵpureFunction1(2,q,1===i.rowSpan)),t.ɵɵadvance(1),t.ɵɵproperty("ngTemplateOutlet",r)}}function P(e,n){if(1&e&&(t.ɵɵelementStart(0,"span",25),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var i=t.ɵɵnextContext(3);t.ɵɵpropertyInterpolate("title",i.label),t.ɵɵadvance(1),t.ɵɵtextInterpolate1("",i.label," ")}}function _(e,n){1&e&&(t.ɵɵelementStart(0,"button",26),t.ɵɵelementStart(1,"mat-icon"),t.ɵɵelement(2,"pep-icon",27),t.ɵɵelementEnd(),t.ɵɵelementEnd())}var k=function(e,t){return{"one-row":e,"pepperi-button weak":t}};function R(e,n){if(1&e){var i=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"div",21),t.ɵɵlistener("click",(function(e){t.ɵɵrestoreView(i);var n=t.ɵɵnextContext(2);return n.disabled?"":n.cardTemplateClicked(e)})),t.ɵɵtemplate(1,P,2,2,"span",22),t.ɵɵelementStart(2,"span",23),t.ɵɵtext(3),t.ɵɵelementEnd(),t.ɵɵtemplate(4,_,3,0,"button",24),t.ɵɵelementEnd()}if(2&e){var r=t.ɵɵnextContext(2);t.ɵɵclassMap("text-align-"+r.xAlignment),t.ɵɵproperty("ngClass",t.ɵɵpureFunction2(8,k,1===r.rowSpan,r.isActive&&!r.disabled)),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",r.showTitle&&""!=r.label),t.ɵɵadvance(1),t.ɵɵpropertyInterpolate("title",r.formattedValue),t.ɵɵproperty("id",r.key),t.ɵɵadvance(1),t.ɵɵtextInterpolate(r.formattedValue),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",r.isActive&&!r.disabled)}}function N(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,O,1,0,"ng-container",3),t.ɵɵtemplate(2,A,2,4,"ng-template",null,18,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,R,5,11,"ng-template",null,19,t.ɵɵtemplateRefExtractor),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵreference(3),r=t.ɵɵreference(5),l=t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngIf",l.isInEditMode)("ngIfThen",i)("ngIfElse",r)}}function B(e,n){1&e&&t.ɵɵelementContainer(0)}function Y(e,n){1&e&&t.ɵɵelementContainer(0)}function j(e,n){if(1&e&&t.ɵɵtemplate(0,Y,1,0,"ng-container",16),2&e){t.ɵɵnextContext(2);var i=t.ɵɵreference(2);t.ɵɵproperty("ngTemplateOutlet",i)}}var K=function(e){return{readonly:e}};function L(e,n){if(1&e&&(t.ɵɵelementStart(0,"span",30),t.ɵɵtext(1),t.ɵɵelementEnd()),2&e){var i=t.ɵɵnextContext(2);t.ɵɵpropertyInterpolate("title",i.fieldFormattedValue),t.ɵɵproperty("id",i.key)("ngClass",t.ɵɵpureFunction1(4,K,i.disabled)),t.ɵɵadvance(1),t.ɵɵtextInterpolate(i.fieldFormattedValue)}}function D(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵtemplate(1,B,1,0,"ng-container",3),t.ɵɵtemplate(2,j,1,1,"ng-template",null,28,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(4,L,2,6,"ng-template",null,29,t.ɵɵtemplateRefExtractor),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵreference(3),r=t.ɵɵreference(5),l=t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngIf",l.isActive&&!l.disabled)("ngIfThen",i)("ngIfElse",r)}}function U(e,n){1&e&&t.ɵɵelementContainer(0)}function z(e,n){if(1&e&&(t.ɵɵelementContainerStart(0),t.ɵɵelement(1,"pep-field-title",17),t.ɵɵtemplate(2,U,1,0,"ng-container",16),t.ɵɵelementContainerEnd()),2&e){var i=t.ɵɵnextContext(),r=t.ɵɵreference(2);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)}}var G=function(){function e(e,n,i){this.customizationService=e,this.renderer=n,this.element=i,this.key="",this.value="",this.formattedValue="",this.label="",this.type="select",this.required=!1,this.disabled=!1,this.readonly=!1,this.xAlignment="0",this.rowSpan=1,this.options=[],this.controlType="select",this.form=null,this.layoutType=d.LAYOUT_TYPE.PepperiForm,this.parentFieldKey=null,this.isActive=!1,this.showTitle=!0,this.emptyOption=!0,this.valueChanged=new t.EventEmitter,this.formValidationChanged=new t.EventEmitter,this.LAYOUT_TYPE=d.LAYOUT_TYPE,this.standAlone=!1,this.isInEditMode=!1,this.isMulti=!1,this.fieldFormattedValue=""}return e.prototype.addOptionsIfNeeded=function(){var e,t,n=this;if(this.isMulti){var i=function(e){var t=!1;r.options&&!r.options.find((function(t){return t.Key===e}))&&(t=!0),t&&r.options.push({Key:e,Value:e})},r=this;try{for(var l=f(this.selectedValuesModel),a=l.next();!a.done;a=l.next()){i(a.value)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}}else this.value&&""!==this.value&&this.options&&!this.options.find((function(e){return e.Key===n.value}))&&this.options.push({Key:this.value,Value:this.formattedValue})},e.prototype.ngOnInit=function(){null===this.form&&(this.standAlone=!0,this.form=this.customizationService.getDefaultFromGroup(this.key,this.value,this.required,this.readonly,this.disabled),this.renderer.addClass(this.element.nativeElement,d.CustomizationService.STAND_ALONE_FIELD_CLASS_NAME))},e.prototype.ngOnChanges=function(e){this.isMulti="multi"===this.type,this.isMulti?this.selectedValuesModel=this.value.length>0?this.value.split(";"):[]:this.selectedValueModel=this.value,this.fieldFormattedValue="string"==typeof this.value?this.value.replace(new RegExp(";","g"),", "):"",this.addOptionsIfNeeded()},e.prototype.ngOnDestroy=function(){this.valueChanged&&this.valueChanged.unsubscribe(),this.formValidationChanged&&this.formValidationChanged.unsubscribe()},e.prototype.selectionChange=function(e){this.isMulti||this.changeValue(this.selectedValueModel)},e.prototype.openedChange=function(e){e||(this.isMulti&&this.changeValue(this.selectedValuesModel.join(";")),this.isInEditMode&&(this.isInEditMode=!1))},e.prototype.changeValue=function(e){if(this.formattedValue=e,this.customizationService.updateFormFieldValue(this.form,this.key,e,this.parentFieldKey),this.required){var t=this.form.controls[this.key];e?t.setErrors(null):t.setErrors({serverError:"Required"}),this.formValidationChanged.emit(this.form.valid)}this.valueChanged.emit({apiName:this.key,value:e})},e.prototype.cardTemplateClicked=function(e){var t=this;this.isInEditMode=!0,setTimeout((function(){t.select.open()}),0)},e}();G.ɵfac=function(e){return new(e||G)(t.ɵɵdirectiveInject(d.CustomizationService),t.ɵɵdirectiveInject(t.Renderer2),t.ɵɵdirectiveInject(t.ElementRef))},G.ɵcmp=t.ɵɵdefineComponent({type:G,selectors:[["pep-select"]],viewQuery:function(e,n){var i;(1&e&&t.ɵɵviewQuery(g,!0),2&e)&&(t.ɵɵqueryRefresh(i=t.ɵɵloadQuery())&&(n.select=i.first))},inputs:{key:"key",value:"value",formattedValue:"formattedValue",label:"label",type:"type",required:"required",disabled:"disabled",readonly:"readonly",xAlignment:"xAlignment",rowSpan:"rowSpan",options:"options",form:"form",layoutType:"layoutType",parentFieldKey:"parentFieldKey",isActive:"isActive",showTitle:"showTitle",emptyOption:"emptyOption"},outputs:{valueChanged:"valueChanged",formValidationChanged:"formValidationChanged"},features:[t.ɵɵNgOnChangesFeature],decls:7,vars:5,consts:[[3,"formGroup"],["pepperiTemplate",""],[4,"ngIf"],[4,"ngIf","ngIfThen","ngIfElse"],["regularSelectBlock",""],["multiSelectBlock",""],["appearance","outline",3,"dir"],["matInput","","disableOptionCentering","",3,"required","id","ngClass","placeholder","ngModel","ngModelOptions","disabled","title","ngModelChange","selectionChange","openedChange"],["select",""],["value","",4,"ngIf"],[3,"value",4,"ngFor","ngForOf"],[1,"body-xs",3,"title","innerText"],["value",""],[3,"value"],["matInput","","disableOptionCentering","","multiple","",3,"required","id","ngClass","placeholder","ngModel","ngModelOptions","disabled","title","ngModelChange","openedChange"],[3,"label","required","disabled","xAlignment","showTitle",4,"ngIf"],[4,"ngTemplateOutlet"],[3,"label","required","disabled","xAlignment","showTitle"],["editBlock",""],["readOnlyBlock",""],[3,"ngClass"],[1,"pepperi-card-input","card-flex-container",3,"ngClass","click"],["class","body-xs title",3,"title",4,"ngIf"],[1,"body-sm","value",3,"id","title"],["class","pepperi-button weak card-edit-button","mat-button","",4,"ngIf"],[1,"body-xs","title",3,"title"],["mat-button","",1,"pepperi-button","weak","card-edit-button"],["name","system_edit"],["selectedBlock",""],["notSelectedBlock",""],[1,"body-sm","pepperi-report-input",3,"id","ngClass","title"]],template:function(e,n){1&e&&(t.ɵɵelementContainerStart(0,0),t.ɵɵtemplate(1,T,5,3,"ng-template",null,1,t.ɵɵtemplateRefExtractor),t.ɵɵtemplate(3,V,3,2,"ng-container",2),t.ɵɵtemplate(4,N,6,3,"ng-container",2),t.ɵɵtemplate(5,D,6,3,"ng-container",2),t.ɵɵtemplate(6,z,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:[i.NgControlStatusGroup,i.FormGroupDirective,n.NgIf,a.MatFormField,c.Dir,o.MatSelect,i.RequiredValidator,n.NgClass,i.NgControlStatus,i.NgModel,n.NgForOf,a.MatError,r.MatOption,n.NgTemplateOutlet,u.PepperiFieldTitleComponent,l.MatButton,p.MatIcon,s.PepperiIconComponent],pipes:[m.TranslatePipe],styles:["[_nghost-%COMP%]{display:-ms-grid;display:grid;height:inherit}[_nghost-%COMP%] > *[_ngcontent-%COMP%]{-ms-grid-row-align:center;align-self:center}.material-additional-selection[_ngcontent-%COMP%]{font-size:.75em;opacity:.75}"],changeDetection:0});var Q=function(e){this.pepperiIconRegistry=e,this.pepperiIconRegistry.registerIcons([s.pepperiIconSystemEdit])};Q.ɵmod=t.ɵɵdefineNgModule({type:Q}),Q.ɵinj=t.ɵɵdefineInjector({factory:function(e){return new(e||Q)(t.ɵɵinject(s.PepperiIconRegistry))},imports:[[n.CommonModule,i.ReactiveFormsModule,i.FormsModule,r.MatCommonModule,l.MatButtonModule,a.MatFormFieldModule,o.MatSelectModule,p.MatIconModule,d.PepperiModule,s.PepperiIconModule,u.PepperiFieldTitleModule]]}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(Q,{declarations:[G],imports:[n.CommonModule,i.ReactiveFormsModule,i.FormsModule,r.MatCommonModule,l.MatButtonModule,a.MatFormFieldModule,o.MatSelectModule,p.MatIconModule,d.PepperiModule,s.PepperiIconModule,u.PepperiFieldTitleModule],exports:[G]}),e.PepperiSelectComponent=G,e.PepperiSelectModule=Q,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=pepperi-lib-select.umd.min.js.map