@stemy/ngx-dynamic-form 10.2.19 → 10.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +27 -27
  2. package/bundles/stemy-ngx-dynamic-form.umd.js +1417 -1396
  3. package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
  4. package/bundles/stemy-ngx-dynamic-form.umd.min.js +1 -1
  5. package/bundles/stemy-ngx-dynamic-form.umd.min.js.map +1 -1
  6. package/esm2015/ngx-dynamic-form/common-types.js +134 -134
  7. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.js +91 -91
  8. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form.component.js +129 -129
  9. package/esm2015/ngx-dynamic-form/directives/async-submit.directive.js +100 -100
  10. package/esm2015/ngx-dynamic-form/ngx-dynamic-form.module.js +82 -82
  11. package/esm2015/ngx-dynamic-form/services/dynamic-form-validation.service.js +11 -11
  12. package/esm2015/ngx-dynamic-form/services/dynamic-form.service.js +393 -389
  13. package/esm2015/ngx-dynamic-form/utils/dynamic-form-array.model.js +8 -8
  14. package/esm2015/ngx-dynamic-form/utils/form-subject.js +18 -18
  15. package/esm2015/ngx-dynamic-form/utils/validators.js +28 -28
  16. package/esm2015/public_api.js +9 -9
  17. package/esm2015/stemy-ngx-dynamic-form.js +6 -6
  18. package/fesm2015/stemy-ngx-dynamic-form.js +935 -931
  19. package/fesm2015/stemy-ngx-dynamic-form.js.map +1 -1
  20. package/ngx-dynamic-form/common-types.d.ts +148 -148
  21. package/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.d.ts +37 -37
  22. package/ngx-dynamic-form/components/base/dynamic-base-form.component.d.ts +37 -37
  23. package/ngx-dynamic-form/directives/async-submit.directive.d.ts +27 -27
  24. package/ngx-dynamic-form/ngx-dynamic-form.module.d.ts +10 -10
  25. package/ngx-dynamic-form/services/dynamic-form-validation.service.d.ts +5 -5
  26. package/ngx-dynamic-form/services/dynamic-form.service.d.ts +40 -40
  27. package/ngx-dynamic-form/utils/dynamic-form-array.model.d.ts +12 -12
  28. package/ngx-dynamic-form/utils/form-subject.d.ts +8 -8
  29. package/ngx-dynamic-form/utils/validators.d.ts +4 -4
  30. package/package.json +11 -11
  31. package/public_api.d.ts +8 -8
  32. package/stemy-ngx-dynamic-form.d.ts +6 -6
@@ -12,5 +12,5 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var S=function(e,t){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function F(e,t){function r(){this.constructor=e}S(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function O(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function D(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}Object.create;function w(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function x(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(A(arguments[t]));return e}Object.create;var j=function(e){function t(t){var r=e.call(this)||this;return r.notifyCallback=t,r}return F(t,e),t.prototype.notify=function(e,t){return O(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return(r=this.notifyCallback(e,t))instanceof Promise?[4,r]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return this.next(r),[2]}}))}))},t}(r.Subject),E=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.additional=t.additional||{},n}return F(t,e),t}(i.DynamicFormArrayModel),M=function(e){function a(t,r,o){var i=e.call(this,t,r)||this;return i.openApi=o,i.onDetectChanges=new n.EventEmitter,i}return F(a,e),Object.defineProperty(a.prototype,"api",{get:function(){return this.openApi.api},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"language",{get:function(){return this.api.language},enumerable:!1,configurable:!0}),a.prototype.patchGroup=function(e,r,n){this.patchValueRecursive(e,r,n),this.detectChanges(),n.patchValue(t.ObjectUtils.copy(e))},a.prototype.patchForm=function(e,t){this.patchValueRecursive(e,t.model,t.group),this.detectChanges(t),t.group.patchValue(e)},a.prototype.serialize=function(e,t){return this.serializeRecursive(e,t)},a.prototype.notifyChanges=function(e,t){this.notifyChangesRecursive(e,t)},a.prototype.updateSelectOptions=function(e,t){if(e instanceof i.DynamicSelectModel){var n=e.options$;if(n instanceof j)return void n.notify(e,t);for(;n instanceof r.Subject&&n.source;)(n=n.source)instanceof j&&n.notify(e,t)}},a.prototype.showErrors=function(e){this.showErrorsForGroup(e.group),this.detectChanges(e)},a.prototype.detectChanges=function(t){e.prototype.detectChanges.call(this,t),this.onDetectChanges.emit(t)},a.prototype.patchValueRecursive=function(e,r,n){var o=this;Object.keys(e).forEach((function(a){var s=o.findModelById(a,r),c=e[a];if(s){var u=o.findControlByModel(s,n);if(s instanceof i.DynamicSelectModel&&t.ObjectUtils.isObject(c))e[a]=c.id||c._id||c;else if(s instanceof i.DynamicFormArrayModel){for(var l=Array.isArray(c)?c.length:0,p=u;s.size>l;)o.removeFormArrayGroup(0,p,s);for(;s.size<l;)o.insertFormArrayGroup(s.size,p,s);for(var m=0;m<l;m++){var f=s.get(m);o.patchValueRecursive(c[m],f.group,p.at(m))}}else s instanceof i.DynamicFormGroupModel&&o.patchValueRecursive(c,s.group,u)}}))},a.prototype.serializeRecursive=function(e,r){var n;return O(this,void 0,void 0,(function(){var o,a,s,c,u,l,p,m,f,h,d,y,g,v,b,C,S,F,O;return D(this,(function(D){switch(D.label){case 0:if(o={},!e||!r||!r.value)return[2,o];for(s in a=[],e)a.push(s);c=0,D.label=1;case 1:return c<a.length?(u=a[c],l=e[u],p=this.findControlByModel(l,r),m=null===(n=l.additional)||void 0===n?void 0:n.serializer,t.ObjectUtils.isFunction(m)?(f=o,h=l.id,[4,m(l,p)]):[3,3]):[3,12];case 2:return f[h]=D.sent(),[3,11];case 3:if(!(l instanceof i.DynamicFormArrayModel))return[3,8];d=Array.isArray(p.value)?p.value.length:0,y=p,g=[],v=0,D.label=4;case 4:return v<d?(b=l.get(v),S=(C=g).push,[4,this.serializeRecursive(b.group,y.at(v))]):[3,7];case 5:S.apply(C,[D.sent()]),D.label=6;case 6:return v++,[3,4];case 7:return o[l.id]=g,[3,11];case 8:return l instanceof i.DynamicFormGroupModel?(F=o,O=l.id,[4,this.serializeRecursive(l.group,p)]):[3,10];case 9:return F[O]=D.sent(),[3,11];case 10:if(l instanceof i.DynamicInputModel&&!t.ObjectUtils.isNullOrUndefined(p.value))return o[l.id]="number"==l.inputType?parseFloat((""+p.value||"0").replace(/,/gi,"."))||null:p.value,[3,11];o[l.id]=p.value,D.label=11;case 11:return c++,[3,1];case 12:return[2,o]}}))}))},a.prototype.notifyChangesRecursive=function(e,t){if(e&&t)for(var r in e){var n=e[r],o=this.findControlByModel(n,t);if(n instanceof i.DynamicFormArrayModel)for(var a=Array.isArray(o.value)?o.value.length:0,s=o,c=0;c<a;c++){var u=n.get(c);this.notifyChangesRecursive(u.group,s.at(c))}else n instanceof i.DynamicFormGroupModel?this.notifyChangesRecursive(n.group,o):this.updateSelectOptions(n,o)}},a.prototype.showErrorsForGroup=function(e){if(e){e.markAsTouched({onlySelf:!0});var t=Object.keys(e.controls).map((function(t){return e.controls[t]}));this.showErrorsForControls(t)}},a.prototype.showErrorsForControls=function(e){var t=this;e.forEach((function(e){e instanceof o.FormGroup?t.showErrorsForGroup(e):(e.markAsTouched({onlySelf:!0}),e instanceof o.FormArray&&t.showErrorsForControls(e.controls))}))},a.prototype.getFormModelForSchema=function(e){return O(this,void 0,void 0,(function(){var t;return D(this,(function(r){switch(r.label){case 0:return this.api.cache={},t=this,[4,this.openApi.getSchemas()];case 1:return t.schemas=r.sent(),[2,this.getFormModelForSchemaDef(this.schemas[e])]}}))}))},a.prototype.getFormModelForSchemaDef=function(e){var t=this;return e?Object.keys(e.properties||{}).map((function(r){var n=e.properties[r];return t.getFormControlModel(n,e)})).filter((function(e){return null!==e})):[]},a.prototype.getFormControlModel=function(e,r){var n,o;if(Array.isArray(e.enum)||t.ObjectUtils.isString(e.optionsPath))return new i.DynamicSelectModel(this.getFormSelectConfig(e,r));switch(e.type){case"string":case"number":return new i.DynamicInputModel(this.getFormInputConfig(e,r));case"textarea":return new i.DynamicTextAreaModel(this.getFormTextareaConfig(e,r));case"boolean":return new i.DynamicCheckboxModel(this.getFormCheckboxConfig(e,r));case"list":return new i.DynamicSelectModel(this.getFormSelectConfig(e,r));case"array":return(null===(n=e.items)||void 0===n?void 0:n.$ref)||e.$ref?new E(this.getFormArrayConfig(e,r)):(null===(o=e.items)||void 0===o?void 0:o.enum)||e.enum?new i.DynamicSelectModel(this.getFormSelectConfig(e,r)):new i.DynamicInputModel(this.getFormInputConfig(e,r));case"file":return new i.DynamicFileUploadModel(this.getFormUploadConfig(e,r))}return e.$ref?new i.DynamicFormGroupModel(this.getFormGroupConfig(e,r)):null},a.prototype.getFormControlConfig=function(e,r){var n=this.getValidators(e,r),o=Object.keys(n).reduce((function(e,t){return e[t]="error."+t,e}),{});return{id:e.id,label:t.ObjectUtils.isString(e.label)?e.label:e.id,hidden:e.hidden,disabled:e.disabled,validators:n,errorMessages:o,additional:Object.assign({},e)}},a.prototype.getFormArrayConfig=function(e,t){var r,n=this,o=(null===(r=e.items)||void 0===r?void 0:r.$ref)||e.$ref||"",i=this.schemas[o.split("/").pop()];return Object.assign(this.getFormControlConfig(e,t),{groupFactory:function(){return n.getFormModelForSchemaDef(i)}})},a.prototype.getFormGroupConfig=function(e,t){var r=e.$ref||"",n=this.schemas[r.split("/").pop()];return Object.assign(this.getFormControlConfig(e,t),{group:this.getFormModelForSchemaDef(n)})},a.prototype.getFormInputConfig=function(e,r){var n,o=t.StringUtils.has(e.id,"password","Password")?"password":(null===(n=e.items)||void 0===n?void 0:n.type)||e.type;switch(o){case"boolean":o="checkbox";break;case"textarea":o="textarea"}return Object.assign(this.getFormControlConfig(e,r),{inputType:o,autoComplete:e.autoComplete||"off",multiple:"array"==e.type,accept:t.ObjectUtils.isString(e.accept)?e.accept:null,mask:t.ObjectUtils.isString(e.mask)?e.mask:null,pattern:t.ObjectUtils.isString(e.pattern)?e.pattern:null,step:isNaN(e.step)?1:e.step,min:isNaN(e.min)?Number.MIN_SAFE_INTEGER:e.min,max:isNaN(e.max)?Number.MAX_SAFE_INTEGER:e.max})},a.prototype.getFormTextareaConfig=function(e,t){return Object.assign(this.getFormControlConfig(e,t),{cols:e.cols||null,rows:e.rows||10,wrap:e.wrap||!1,autoComplete:e.autoComplete||"off",multiple:"array"==e.type})},a.prototype.getFormSelectConfig=function(e,t){return Object.assign(this.getFormControlConfig(e,t),{options:this.getFormSelectOptions(e,t),multiple:"array"==e.type})},a.prototype.getFormCheckboxConfig=function(e,t){return Object.assign(this.getFormControlConfig(e,t),{indeterminate:!0===e.indeterminate})},a.prototype.translateOptions=function(e){return O(this,void 0,void 0,(function(){var t,r,n,o,i,a,s;return D(this,(function(c){switch(c.label){case 0:if(!e)return[2,[]];c.label=1;case 1:c.trys.push([1,6,7,8]),t=w(e),r=t.next(),c.label=2;case 2:return r.done?[3,5]:(n=r.value,o=n,[4,this.language.getTranslation(n.label)]);case 3:o.label=c.sent(),c.label=4;case 4:return r=t.next(),[3,2];case 5:return[3,8];case 6:return i=c.sent(),a={error:i},[3,8];case 7:try{r&&!r.done&&(s=t.return)&&s.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2,e]}}))}))},a.prototype.getFormSelectOptions=function(e,r){var n,o=this,i=(null===(n=e.items)||void 0===n?void 0:n.enum)||e.enum;return e.optionsPath?new j((function(r,n){var i=e.optionsPath,a=n;if(i.startsWith("$root"))for(i=i.substr(5);a.parent;)a=a.parent;for(;i.startsWith(".");)i=i.substr(1),a.parent&&(a=a.parent);var s=t.ObjectUtils.getValue(a.value,i),c=(t.ObjectUtils.isArray(s)?s:[]).map((function(e){return{value:e,label:e}}));return o.translateOptions(c)})):t.ObjectUtils.isArray(i)?new j((function(){var t=i.map((function(t){return{value:t,label:e.translatable?e.id+"."+t:t}}));return o.translateOptions(t)})):new j((function(){return O(o,void 0,void 0,(function(){var t;return D(this,(function(r){switch(r.label){case 0:return this.api.cache[e.endpoint]=this.api.cache[e.endpoint]||this.api.list(e.endpoint,this.api.makeListParams(1,-1)).then((function(t){return t.items.map((function(t){return{value:t.id||t._id,label:t[e.labelField]||t.label||t.id||t._id}}))})),[4,this.api.cache[e.endpoint]];case 1:return t=r.sent().map((function(e){return Object.assign({},e)})),[2,this.translateOptions(t)]}}))}))}))},a.prototype.getFormUploadConfig=function(e,t){var r=this.api.url(e.url||"assets"),n=e.accept,o=e.autoUpload,i=e.maxSize,a=e.minSize,s=e.removeUrl,c=e.showFileList;return Object.assign(this.getFormControlConfig(e,t),{url:r,accept:n,autoUpload:o,maxSize:i,minSize:a,removeUrl:s,showFileList:c})},a.prototype.getValidators=function(e,t){var r={};switch(t.required.indexOf(e.id)>=0&&(r.required=null),e.minLength&&(r.minLength=e.minLength),e.maxLength&&(r.maxLength=e.maxLength),e.min&&(r.min=e.min),e.max&&(r.max=e.max),e.format){case"email":r.email=null}return r},a}(i.DynamicFormService);M.decorators=[{type:n.Injectable}],M.ctorParameters=function(){return[{type:i.DynamicFormComponentService},{type:i.DynamicFormValidationService},{type:t.OpenApiService}]};var R=function(){function e(e,t,r,o){this.toaster=e,this.cdr=t,this.elem=r,this.renderer=o,this.onSuccess=new n.EventEmitter,this.onError=new n.EventEmitter,"BUTTON"===r.nativeElement.tagName&&o.setAttribute(r.nativeElement,"type","button")}return Object.defineProperty(e.prototype,"isDisabled",{get:function(){return this.disabled},set:function(e){this.disabled=e,e?this.renderer.setAttribute(this.elem.nativeElement,"disabled","disabled"):this.renderer.removeAttribute(this.elem.nativeElement,"disabled")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this.loading},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this.form&&(this.isDisabled="VALID"!==this.form.status,this.cdr.detectChanges(),this.onStatusChange=this.form.onStatusChange.subscribe((function(){e.isDisabled="VALID"!==e.form.status,e.cdr.detectChanges(),e.callback&&"PENDING"!=e.form.status&&(e.disabled||e.callback(),e.callback=null)})),this.onSubmit=this.form.onSubmit.subscribe((function(){return e.callMethod()})))},e.prototype.ngOnDestroy=function(){this.onStatusChange&&this.onStatusChange.unsubscribe(),this.onSubmit&&this.onSubmit.unsubscribe()},e.prototype.click=function(){var e=this;this.callback=function(){return e.callMethod()},"VALID"!==this.form.status&&"INVALID"!==this.form.status||(this.callback(),this.callback=null)},e.prototype.callMethod=function(){var e=this;this.loading||(this.loading=!0,this.method(this.form,this.context).then((function(t){e.loading=!1,t&&(e.onSuccess.emit(t),e.toaster.success(t.message,t.context))}),(function(t){if(!t||!t.message)throw new Error("Reason must implement IAsyncMessage interface");e.loading=!1,e.onError.emit(t),e.toaster.error(t.message,t.context)})))},e}();R.decorators=[{type:n.Directive,args:[{selector:"[async-submit]",exportAs:"async-submit"}]}],R.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[t.TOASTER_SERVICE]}]},{type:n.ChangeDetectorRef},{type:n.ElementRef},{type:n.Renderer2}]},R.propDecorators={method:[{type:n.Input,args:["async-submit"]}],form:[{type:n.Input}],context:[{type:n.Input}],onSuccess:[{type:n.Output}],onError:[{type:n.Output}],isDisabled:[{type:n.HostBinding,args:["class.disabled"]}],isLoading:[{type:n.HostBinding,args:["class.loading"]}],click:[{type:n.HostListener,args:["click"]}]};var I=function(e){function o(t,o,i,a){var s=e.call(this,i,a)||this;return s.formService=t,s.events=o,s.blur=new n.EventEmitter,s.change=new n.EventEmitter,s.focus=new n.EventEmitter,s.onStatusChange=new n.EventEmitter,s.onValueChange=new n.EventEmitter,s.onSubmit=new n.EventEmitter,s.templates=new n.QueryList,s.subscription=new r.Subscription,s.groupSubscription=new r.Subscription,s.labelPrefix="label",s}return F(o,e),Object.defineProperty(o.prototype,"status",{get:function(){return this.group?this.group.status:null},enumerable:!1,configurable:!0}),o.prototype.ngOnChanges=function(e){var r=this;this.groupSubscription.unsubscribe(),this.group&&(this.groupSubscription=t.ObservableUtils.multiSubscription(this.group.statusChanges.subscribe((function(){r.onStatusChange.emit(r)})),this.group.valueChanges.subscribe((function(){r.onValueChange.emit(r),r.formService.notifyChanges(r.model,r.group)}))))},o.prototype.ngAfterViewInit=function(){var e=this;this.subscription=t.ObservableUtils.multiSubscription(t.ObservableUtils.subscribe({subjects:[this.contentTemplates.changes,this.viewTemplates.changes],cb:function(){var t=e.contentTemplates.toArray().concat(e.viewTemplates.toArray());e.templates.reset(t)}}),this.events.languageChanged.subscribe((function(){e.formService.detectChanges(e)})),this.ngForm.ngSubmit.subscribe((function(){e.onSubmit.emit(e)})))},o.prototype.ngOnDestroy=function(){e.prototype.ngOnDestroy.call(this),this.subscription.unsubscribe(),this.groupSubscription.unsubscribe()},o.prototype.insertFormArrayGroup=function(e,t,r){this.formService.insertFormArrayGroup(e,t,r),this.changeDetectorRef.detectChanges()},o.prototype.removeFormArrayGroup=function(e,t,r){this.formService.removeFormArrayGroup(e,t,r),this.changeDetectorRef.detectChanges()},o.prototype.moveFormArrayGroup=function(e,t,r,n){this.formService.moveFormArrayGroup(e,t,r,n),this.changeDetectorRef.detectChanges()},o.prototype.clearFormArray=function(e,t){this.formService.clearFormArray(e,t),this.changeDetectorRef.detectChanges()},o.prototype.validate=function(e){var t=this;return void 0===e&&(e=!0),this.group?new Promise((function(r,n){t.group.statusChanges.pipe(a.first((function(e){return"VALID"==e||"INVALID"==e}))).subscribe((function(o){e&&t.formService.showErrors(t),"VALID"!=o?n(null):r(null)})),t.group.updateValueAndValidity()})):Promise.resolve()},o.prototype.serialize=function(e){return O(this,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return this.group?e?[4,this.validate()]:[3,2]:[2,null];case 1:t.sent(),t.label=2;case 2:return[4,this.formService.serialize(this.model,this.group)];case 3:return[2,t.sent()]}}))}))},o}(i.DynamicFormComponent);I.decorators=[{type:n.Component,args:[{selector:"dynamic-base-form",template:"",changeDetection:n.ChangeDetectionStrategy.Default}]}],I.ctorParameters=function(){return[{type:M,decorators:[{type:n.Inject,args:[M]}]},{type:t.EventsService,decorators:[{type:n.Inject,args:[t.EventsService]}]},{type:n.ChangeDetectorRef},{type:i.DynamicFormComponentService}]},I.propDecorators={group:[{type:n.Input}],model:[{type:n.Input}],layout:[{type:n.Input}],labelPrefix:[{type:n.Input}],blur:[{type:n.Output}],change:[{type:n.Output}],focus:[{type:n.Output}],contentTemplates:[{type:n.ContentChildren,args:[i.DynamicTemplateDirective]}],viewTemplates:[{type:n.ViewChildren,args:[i.DynamicTemplateDirective]}],onStatusChange:[{type:n.Output}],onValueChange:[{type:n.Output}],onSubmit:[{type:n.Output}],ngForm:[{type:n.ViewChild,args:[o.NgForm]}]};var T=function(e){function r(t,r,o,i,a,s,c){var u=e.call(this,r,o,i,a,s,c)||this;return u.form=t,u.changeDetectorRef=r,u.componentFactoryResolver=o,u.layoutService=i,u.validationService=a,u.componentService=s,u.relationService=c,u.context=null,u.blur=new n.EventEmitter,u.change=new n.EventEmitter,u.focus=new n.EventEmitter,u}return F(r,e),Object.defineProperty(r.prototype,"componentType",{get:function(){var e;return null!==(e=this.componentService.getCustomComponentType(this.model))&&void 0!==e?e:this.getComponentType(this.model)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"startTemplate",{get:function(){return this.model.type==i.DYNAMIC_FORM_CONTROL_TYPE_ARRAY?this.layoutService.getAlignedTemplate(this.model,this.templates,"ARRAY_START"):this.layoutService.getStartTemplate(this.model,this.templates)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"endTemplate",{get:function(){return this.model.type==i.DYNAMIC_FORM_CONTROL_TYPE_ARRAY?this.layoutService.getAlignedTemplate(this.model,this.templates,"ARRAY_END"):this.layoutService.getEndTemplate(this.model,this.templates)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"formService",{get:function(){return this.form.formService},enumerable:!1,configurable:!0}),r.prototype.ngOnInit=function(){var e=this;this.onDetectChanges=this.formService.onDetectChanges.subscribe((function(t){t===e.form&&(e.changeDetectorRef.detectChanges(),e.formService.updateSelectOptions(e.model,e.control))}))},r.prototype.ngOnDestroy=function(){e.prototype.ngOnDestroy.call(this),this.onDetectChanges.unsubscribe()},r.prototype.createFormControlComponent=function(){var r;e.prototype.createFormControlComponent.call(this);var n=null===(r=this.componentRef)||void 0===r?void 0:r.instance;n&&t.ObjectUtils.isFunction(n.onCreated)&&n.onCreated()},r.prototype.getComponentType=function(e){return null},r}(i.DynamicFormControlContainerComponent);T.decorators=[{type:n.Component,args:[{selector:"dynamic-base-form-control",template:"",changeDetection:n.ChangeDetectionStrategy.OnPush}]}],T.ctorParameters=function(){return[{type:I},{type:n.ChangeDetectorRef},{type:n.ComponentFactoryResolver},{type:i.DynamicFormLayoutService},{type:i.DynamicFormValidationService},{type:i.DynamicFormComponentService},{type:i.DynamicFormRelationService}]},T.propDecorators={contentTemplateList:[{type:n.ContentChildren,args:[i.DynamicTemplateDirective]}],klass:[{type:n.HostBinding,args:["class"]}],context:[{type:n.Input}],group:[{type:n.Input}],hostClass:[{type:n.Input}],inputTemplateList:[{type:n.Input,args:["templates"]}],layout:[{type:n.Input}],model:[{type:n.Input}],blur:[{type:n.Output}],change:[{type:n.Output}],focus:[{type:n.Output}],componentViewContainerRef:[{type:n.ViewChild,args:["componentViewContainer",{read:n.ViewContainerRef,static:!0}]}]};var U=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return F(t,e),t.prototype.showErrorMessages=function(t,r,n){return e.prototype.showErrorMessages.call(this,t,r,n)},t}(i.DynamicFormValidationService);U.decorators=[{type:n.Injectable}];var V=[I,T],N=[R],k=[],P=v,_=b,L=C,G=new Map([["validateJSON",v],["validateRequiredTranslation",b],["validatePhone",C]]),z=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[M,U,{provide:i.DynamicFormService,useExisting:M},{provide:i.DynamicFormValidationService,useExisting:U}]}},e}();z.decorators=[{type:n.NgModule,args:[{declarations:x(V,N,k),imports:[s.CommonModule,o.FormsModule,o.ReactiveFormsModule,t.NgxUtilsModule],exports:x(V,N,k,[o.FormsModule,o.ReactiveFormsModule,t.NgxUtilsModule]),entryComponents:V,providers:x(k,[{provide:o.NG_VALIDATORS,useValue:P,multi:!0},{provide:o.NG_VALIDATORS,useValue:_,multi:!0},{provide:o.NG_VALIDATORS,useValue:L,multi:!0},{provide:i.DYNAMIC_VALIDATORS,useValue:G}])}]}],e.AsyncSubmitDirective=R,e.DynamicBaseFormComponent=I,e.DynamicBaseFormControlContainerComponent=T,e.DynamicFormService=M,e.FormFieldSet=function(e){return function(r){var n=m(r);e.classes=e.classes||"",n[e.id]=e,t.ReflectUtils.defineMetadata("dynamicFormFieldSets",n,r)}},e.FormFile=function(e){return function(r,n){p(r,n,function(e,r){var n=f(e,"file",r);return(r=n.data).accept=r.accept||".jpg,.jpeg,.png",r.multi=r.multi||!1,r.baseUrl=t.ObjectUtils.isString(r.baseUrl)?r.baseUrl:"assets/",r.uploadUrl=t.ObjectUtils.isString(r.uploadUrl)?r.uploadUrl:"assets",r.createUploadData=r.createUploadData||function(e){var t=new FormData;return t.append("file",e),t},n}(n,e))}},e.FormInput=function(e){return function(r,n){var o=t.ReflectUtils.getOwnMetadata("design:type",r,n),i=o?o.name:"",a=n.indexOf("password")<0?"text":"password";switch(i){case"Number":a="number";break;case"Boolean":a="checkbox"}p(r,n,h(n,e,a))}},e.FormModel=function(e){return function(t,r){p(t,r,g(r,e))}},e.FormSelect=function(e){return function(t,r){p(t,r,d(r,e))}},e.FormSerializable=function(e){return function(r,n){t.ReflectUtils.defineMetadata("dynamicFormSerializer",e||l,r,n)}},e.FormStatic=function(e){return function(t,r){p(t,r,y(r,e))}},e.FormSubject=j,e.NgxDynamicFormModule=z,e.createFormControl=f,e.createFormInput=h,e.createFormModel=g,e.createFormSelect=d,e.createFormStatic=y,e.defaultSerializer=l,e.defineFormControl=p,e.getFormControl=function(e,r){return t.ReflectUtils.getMetadata("dynamicFormControl",e,r)},e.getFormFieldSets=m,e.getFormSerializer=function(e,r){return t.ReflectUtils.getMetadata("dynamicFormSerializer",e,r)},e.validateJSON=v,e.validatePhone=C,e.validateRequiredTranslation=b,e.ɵa=V,e.ɵb=N,e.ɵc=k,e.ɵd=U,Object.defineProperty(e,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */var S=function(e,t){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},S(e,t)};function F(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}S(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function O(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function D(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}Object.create;function w(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function x(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(A(arguments[t]));return e}Object.create;var j=function(e){function t(t){var r=e.call(this)||this;return r.notifyCallback=t,r}return F(t,e),t.prototype.notify=function(e,t){return O(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return(r=this.notifyCallback(e,t))instanceof Promise?[4,r]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return this.next(r),[2]}}))}))},t}(r.Subject),E=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.additional=t.additional||{},n}return F(t,e),t}(i.DynamicFormArrayModel),M=function(e){function a(t,r,o){var i=e.call(this,t,r)||this;return i.openApi=o,i.onDetectChanges=new n.EventEmitter,i}return F(a,e),Object.defineProperty(a.prototype,"api",{get:function(){return this.openApi.api},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"language",{get:function(){return this.api.language},enumerable:!1,configurable:!0}),a.prototype.patchGroup=function(e,r,n){this.patchValueRecursive(e,r,n),this.detectChanges(),n.patchValue(t.ObjectUtils.copy(e))},a.prototype.patchForm=function(e,t){this.patchValueRecursive(e,t.model,t.group),this.detectChanges(t),t.group.patchValue(e)},a.prototype.serialize=function(e,t){return this.serializeRecursive(e,t)},a.prototype.notifyChanges=function(e,t){this.notifyChangesRecursive(e,t)},a.prototype.updateSelectOptions=function(e,t){if(e instanceof i.DynamicSelectModel){var n=e.options$;if(n instanceof j)return void n.notify(e,t);for(;n instanceof r.Subject&&n.source;)(n=n.source)instanceof j&&n.notify(e,t)}},a.prototype.showErrors=function(e){this.showErrorsForGroup(e.group),this.detectChanges(e)},a.prototype.detectChanges=function(t){e.prototype.detectChanges.call(this,t),this.onDetectChanges.emit(t)},a.prototype.patchValueRecursive=function(e,r,n){var o=this;Object.keys(e).forEach((function(a){var s=o.findModelById(a,r),c=e[a];if(s){var u=o.findControlByModel(s,n);if(s instanceof i.DynamicSelectModel&&t.ObjectUtils.isObject(c))e[a]=c.id||c._id||c;else if(s instanceof i.DynamicFormArrayModel){for(var l=Array.isArray(c)?c.length:0,p=u;s.size>l;)o.removeFormArrayGroup(0,p,s);for(;s.size<l;)o.insertFormArrayGroup(s.size,p,s);for(var m=0;m<l;m++){var f=s.get(m);o.patchValueRecursive(c[m],f.group,p.at(m))}}else s instanceof i.DynamicFormGroupModel&&o.patchValueRecursive(c,s.group,u)}}))},a.prototype.serializeRecursive=function(e,r){var n;return O(this,void 0,void 0,(function(){var o,a,s,c,u,l,p,m,f,h,d,y,g,v,b,C,S,F,O;return D(this,(function(D){switch(D.label){case 0:if(o={},!e||!r||!r.value)return[2,o];for(s in a=[],e)a.push(s);c=0,D.label=1;case 1:return c<a.length?(u=a[c],l=e[u],p=this.findControlByModel(l,r),m=null===(n=l.additional)||void 0===n?void 0:n.serializer,t.ObjectUtils.isFunction(m)?(f=o,h=l.id,[4,m(l,p)]):[3,3]):[3,12];case 2:return f[h]=D.sent(),[3,11];case 3:if(!(l instanceof i.DynamicFormArrayModel))return[3,8];d=Array.isArray(p.value)?p.value.length:0,y=p,g=[],v=0,D.label=4;case 4:return v<d?(b=l.get(v),S=(C=g).push,[4,this.serializeRecursive(b.group,y.at(v))]):[3,7];case 5:S.apply(C,[D.sent()]),D.label=6;case 6:return v++,[3,4];case 7:return o[l.id]=g,[3,11];case 8:return l instanceof i.DynamicFormGroupModel?(F=o,O=l.id,[4,this.serializeRecursive(l.group,p)]):[3,10];case 9:return F[O]=D.sent(),[3,11];case 10:if(l instanceof i.DynamicInputModel&&!t.ObjectUtils.isNullOrUndefined(p.value))return o[l.id]="number"==l.inputType?parseFloat((""+p.value||"0").replace(/,/gi,"."))||null:p.value,[3,11];o[l.id]=p.value,D.label=11;case 11:return c++,[3,1];case 12:return[2,o]}}))}))},a.prototype.notifyChangesRecursive=function(e,t){if(e&&t)for(var r in e){var n=e[r],o=this.findControlByModel(n,t);if(n instanceof i.DynamicFormArrayModel)for(var a=Array.isArray(o.value)?o.value.length:0,s=o,c=0;c<a;c++){var u=n.get(c);this.notifyChangesRecursive(u.group,s.at(c))}else n instanceof i.DynamicFormGroupModel?this.notifyChangesRecursive(n.group,o):this.updateSelectOptions(n,o)}},a.prototype.showErrorsForGroup=function(e){if(e){e.markAsTouched({onlySelf:!0});var t=Object.keys(e.controls).map((function(t){return e.controls[t]}));this.showErrorsForControls(t)}},a.prototype.showErrorsForControls=function(e){var t=this;e.forEach((function(e){e instanceof o.FormGroup?t.showErrorsForGroup(e):(e.markAsTouched({onlySelf:!0}),e instanceof o.FormArray&&t.showErrorsForControls(e.controls))}))},a.prototype.getFormModelForSchema=function(e){return O(this,void 0,void 0,(function(){var t;return D(this,(function(r){switch(r.label){case 0:return this.api.cache={},t=this,[4,this.openApi.getSchemas()];case 1:return t.schemas=r.sent(),[2,this.getFormModelForSchemaDef(this.schemas[e])]}}))}))},a.prototype.getFormModelForSchemaDef=function(e){var t=this;return e?Object.keys(e.properties||{}).map((function(r){var n=e.properties[r];return t.getFormControlModel(n,e)})).filter((function(e){return null!==e})):[]},a.prototype.getFormControlModel=function(e,r){var n,o;if(Array.isArray(e.enum)||t.ObjectUtils.isString(e.optionsPath))return new i.DynamicSelectModel(this.getFormSelectConfig(e,r));switch(e.type){case"string":case"number":case"integer":return new i.DynamicInputModel(this.getFormInputConfig(e,r));case"textarea":return new i.DynamicTextAreaModel(this.getFormTextareaConfig(e,r));case"boolean":return new i.DynamicCheckboxModel(this.getFormCheckboxConfig(e,r));case"list":return new i.DynamicSelectModel(this.getFormSelectConfig(e,r));case"array":return(null===(n=e.items)||void 0===n?void 0:n.$ref)||e.$ref?new E(this.getFormArrayConfig(e,r)):(null===(o=e.items)||void 0===o?void 0:o.enum)||e.enum?new i.DynamicSelectModel(this.getFormSelectConfig(e,r)):new i.DynamicInputModel(this.getFormInputConfig(e,r));case"file":return new i.DynamicFileUploadModel(this.getFormUploadConfig(e,r))}return e.$ref?new i.DynamicFormGroupModel(this.getFormGroupConfig(e,r)):null},a.prototype.getFormControlConfig=function(e,r){var n=this.getValidators(e,r),o=Object.keys(n).reduce((function(e,t){return e[t]="error."+t,e}),{});return{id:e.id,label:t.ObjectUtils.isString(e.label)?e.label:e.id,hidden:e.hidden,disabled:e.disabled,validators:n,errorMessages:o,additional:Object.assign({},e)}},a.prototype.getFormArrayConfig=function(e,t){var r,n=this,o=(null===(r=e.items)||void 0===r?void 0:r.$ref)||e.$ref||"",i=this.schemas[o.split("/").pop()];return Object.assign(this.getFormControlConfig(e,t),{groupFactory:function(){return n.getFormModelForSchemaDef(i)}})},a.prototype.getFormGroupConfig=function(e,t){var r=e.$ref||"",n=this.schemas[r.split("/").pop()];return Object.assign(this.getFormControlConfig(e,t),{group:this.getFormModelForSchemaDef(n)})},a.prototype.getFormInputConfig=function(e,r){var n,o=t.StringUtils.has(e.id,"password","Password")?"password":(null===(n=e.items)||void 0===n?void 0:n.type)||e.type;switch(o){case"boolean":o="checkbox";break;case"textarea":o="textarea";break;case"integer":o="number"}return Object.assign(this.getFormControlConfig(e,r),{inputType:o,autoComplete:e.autoComplete||"off",multiple:"array"==e.type,accept:t.ObjectUtils.isString(e.accept)?e.accept:null,mask:t.ObjectUtils.isString(e.mask)?e.mask:null,pattern:t.ObjectUtils.isString(e.pattern)?e.pattern:null,step:isNaN(e.step)?1:e.step,min:isNaN(e.min)?Number.MIN_SAFE_INTEGER:e.min,max:isNaN(e.max)?Number.MAX_SAFE_INTEGER:e.max})},a.prototype.getFormTextareaConfig=function(e,t){return Object.assign(this.getFormControlConfig(e,t),{cols:e.cols||null,rows:e.rows||10,wrap:e.wrap||!1,autoComplete:e.autoComplete||"off",multiple:"array"==e.type})},a.prototype.getFormSelectConfig=function(e,t){return Object.assign(this.getFormControlConfig(e,t),{options:this.getFormSelectOptions(e,t),multiple:"array"==e.type})},a.prototype.getFormCheckboxConfig=function(e,t){return Object.assign(this.getFormControlConfig(e,t),{indeterminate:!0===e.indeterminate})},a.prototype.translateOptions=function(e){return O(this,void 0,void 0,(function(){var t,r,n,o,i,a,s;return D(this,(function(c){switch(c.label){case 0:if(!e)return[2,[]];c.label=1;case 1:c.trys.push([1,6,7,8]),t=w(e),r=t.next(),c.label=2;case 2:return r.done?[3,5]:(n=r.value,o=n,[4,this.language.getTranslation(n.label)]);case 3:o.label=c.sent(),c.label=4;case 4:return r=t.next(),[3,2];case 5:return[3,8];case 6:return i=c.sent(),a={error:i},[3,8];case 7:try{r&&!r.done&&(s=t.return)&&s.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2,e]}}))}))},a.prototype.getFormSelectOptions=function(e,r){var n,o=this,i=(null===(n=e.items)||void 0===n?void 0:n.enum)||e.enum;return e.optionsPath?new j((function(r,n){var i=e.optionsPath,a=n;if(i.startsWith("$root"))for(i=i.substr(5);a.parent;)a=a.parent;for(;i.startsWith(".");)i=i.substr(1),a.parent&&(a=a.parent);var s=t.ObjectUtils.getValue(a.value,i),c=(t.ObjectUtils.isArray(s)?s:[]).map((function(e){return{value:e,label:e}}));return o.translateOptions(c)})):t.ObjectUtils.isArray(i)?new j((function(){var t=i.map((function(t){return{value:t,label:e.translatable?e.id+"."+t:t}}));return o.translateOptions(t)})):new j((function(){return O(o,void 0,void 0,(function(){var t;return D(this,(function(r){switch(r.label){case 0:return this.api.cache[e.endpoint]=this.api.cache[e.endpoint]||this.api.list(e.endpoint,this.api.makeListParams(1,-1)).then((function(t){return t.items.map((function(t){return{value:t.id||t._id,label:t[e.labelField]||t.label||t.id||t._id}}))})),[4,this.api.cache[e.endpoint]];case 1:return t=r.sent().map((function(e){return Object.assign({},e)})),[2,this.translateOptions(t)]}}))}))}))},a.prototype.getFormUploadConfig=function(e,t){var r=this.api.url(e.url||"assets"),n=e.accept,o=e.autoUpload,i=e.maxSize,a=e.minSize,s=e.removeUrl,c=e.showFileList;return Object.assign(this.getFormControlConfig(e,t),{url:r,accept:n,autoUpload:o,maxSize:i,minSize:a,removeUrl:s,showFileList:c})},a.prototype.getValidators=function(e,r){var n={};if(t.ObjectUtils.isArray(r.required)&&r.required.indexOf(e.id)>=0&&(n.required=null),e.minLength&&(n.minLength=e.minLength),e.maxLength&&(n.maxLength=e.maxLength),e.min&&(n.min=e.min),e.max&&(n.max=e.max),"email"===e.format)n.email=null;return n},a}(i.DynamicFormService);M.decorators=[{type:n.Injectable}],M.ctorParameters=function(){return[{type:i.DynamicFormComponentService},{type:i.DynamicFormValidationService},{type:t.OpenApiService}]};var R=function(){function e(e,t,r,o){this.toaster=e,this.cdr=t,this.elem=r,this.renderer=o,this.onSuccess=new n.EventEmitter,this.onError=new n.EventEmitter,"BUTTON"===r.nativeElement.tagName&&o.setAttribute(r.nativeElement,"type","button")}return Object.defineProperty(e.prototype,"isDisabled",{get:function(){return this.disabled},set:function(e){this.disabled=e,e?this.renderer.setAttribute(this.elem.nativeElement,"disabled","disabled"):this.renderer.removeAttribute(this.elem.nativeElement,"disabled")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this.loading},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this.form&&(this.isDisabled="VALID"!==this.form.status,this.cdr.detectChanges(),this.onStatusChange=this.form.onStatusChange.subscribe((function(){e.isDisabled="VALID"!==e.form.status,e.cdr.detectChanges(),e.callback&&"PENDING"!=e.form.status&&(e.disabled||e.callback(),e.callback=null)})),this.onSubmit=this.form.onSubmit.subscribe((function(){return e.callMethod()})))},e.prototype.ngOnDestroy=function(){this.onStatusChange&&this.onStatusChange.unsubscribe(),this.onSubmit&&this.onSubmit.unsubscribe()},e.prototype.click=function(){var e=this;this.callback=function(){return e.callMethod()},"VALID"!==this.form.status&&"INVALID"!==this.form.status||(this.callback(),this.callback=null)},e.prototype.callMethod=function(){var e=this;this.loading||(this.loading=!0,this.method(this.form,this.context).then((function(t){e.loading=!1,t&&(e.onSuccess.emit(t),e.toaster.success(t.message,t.context))}),(function(t){if(!t||!t.message)throw new Error("Reason must implement IAsyncMessage interface");e.loading=!1,e.onError.emit(t),e.toaster.error(t.message,t.context)})))},e}();R.decorators=[{type:n.Directive,args:[{selector:"[async-submit]",exportAs:"async-submit"}]}],R.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[t.TOASTER_SERVICE]}]},{type:n.ChangeDetectorRef},{type:n.ElementRef},{type:n.Renderer2}]},R.propDecorators={method:[{type:n.Input,args:["async-submit"]}],form:[{type:n.Input}],context:[{type:n.Input}],onSuccess:[{type:n.Output}],onError:[{type:n.Output}],isDisabled:[{type:n.HostBinding,args:["class.disabled"]}],isLoading:[{type:n.HostBinding,args:["class.loading"]}],click:[{type:n.HostListener,args:["click"]}]};var I=function(e){function o(t,o,i,a){var s=e.call(this,i,a)||this;return s.formService=t,s.events=o,s.blur=new n.EventEmitter,s.change=new n.EventEmitter,s.focus=new n.EventEmitter,s.onStatusChange=new n.EventEmitter,s.onValueChange=new n.EventEmitter,s.onSubmit=new n.EventEmitter,s.templates=new n.QueryList,s.subscription=new r.Subscription,s.groupSubscription=new r.Subscription,s.labelPrefix="label",s}return F(o,e),Object.defineProperty(o.prototype,"status",{get:function(){return this.group?this.group.status:null},enumerable:!1,configurable:!0}),o.prototype.ngOnChanges=function(e){var r=this;this.groupSubscription.unsubscribe(),this.group&&(this.groupSubscription=t.ObservableUtils.multiSubscription(this.group.statusChanges.subscribe((function(){r.onStatusChange.emit(r)})),this.group.valueChanges.subscribe((function(){r.onValueChange.emit(r),r.formService.notifyChanges(r.model,r.group)}))))},o.prototype.ngAfterViewInit=function(){var e=this;this.subscription=t.ObservableUtils.multiSubscription(t.ObservableUtils.subscribe({subjects:[this.contentTemplates.changes,this.viewTemplates.changes],cb:function(){var t=e.contentTemplates.toArray().concat(e.viewTemplates.toArray());e.templates.reset(t)}}),this.events.languageChanged.subscribe((function(){e.formService.detectChanges(e)})),this.ngForm.ngSubmit.subscribe((function(){e.onSubmit.emit(e)})))},o.prototype.ngOnDestroy=function(){e.prototype.ngOnDestroy.call(this),this.subscription.unsubscribe(),this.groupSubscription.unsubscribe()},o.prototype.insertFormArrayGroup=function(e,t,r){this.formService.insertFormArrayGroup(e,t,r),this.changeDetectorRef.detectChanges()},o.prototype.removeFormArrayGroup=function(e,t,r){this.formService.removeFormArrayGroup(e,t,r),this.changeDetectorRef.detectChanges()},o.prototype.moveFormArrayGroup=function(e,t,r,n){this.formService.moveFormArrayGroup(e,t,r,n),this.changeDetectorRef.detectChanges()},o.prototype.clearFormArray=function(e,t){this.formService.clearFormArray(e,t),this.changeDetectorRef.detectChanges()},o.prototype.validate=function(e){var t=this;return void 0===e&&(e=!0),this.group?new Promise((function(r,n){t.group.statusChanges.pipe(a.first((function(e){return"VALID"==e||"INVALID"==e}))).subscribe((function(o){e&&t.formService.showErrors(t),"VALID"!=o?n(null):r(null)})),t.group.updateValueAndValidity()})):Promise.resolve()},o.prototype.serialize=function(e){return O(this,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return this.group?e?[4,this.validate()]:[3,2]:[2,null];case 1:t.sent(),t.label=2;case 2:return[4,this.formService.serialize(this.model,this.group)];case 3:return[2,t.sent()]}}))}))},o}(i.DynamicFormComponent);I.decorators=[{type:n.Component,args:[{selector:"dynamic-base-form",template:"",changeDetection:n.ChangeDetectionStrategy.Default}]}],I.ctorParameters=function(){return[{type:M,decorators:[{type:n.Inject,args:[M]}]},{type:t.EventsService,decorators:[{type:n.Inject,args:[t.EventsService]}]},{type:n.ChangeDetectorRef},{type:i.DynamicFormComponentService}]},I.propDecorators={group:[{type:n.Input}],model:[{type:n.Input}],layout:[{type:n.Input}],labelPrefix:[{type:n.Input}],blur:[{type:n.Output}],change:[{type:n.Output}],focus:[{type:n.Output}],contentTemplates:[{type:n.ContentChildren,args:[i.DynamicTemplateDirective]}],viewTemplates:[{type:n.ViewChildren,args:[i.DynamicTemplateDirective]}],onStatusChange:[{type:n.Output}],onValueChange:[{type:n.Output}],onSubmit:[{type:n.Output}],ngForm:[{type:n.ViewChild,args:[o.NgForm]}]};var T=function(e){function r(t,r,o,i,a,s,c){var u=e.call(this,r,o,i,a,s,c)||this;return u.form=t,u.changeDetectorRef=r,u.componentFactoryResolver=o,u.layoutService=i,u.validationService=a,u.componentService=s,u.relationService=c,u.context=null,u.blur=new n.EventEmitter,u.change=new n.EventEmitter,u.focus=new n.EventEmitter,u}return F(r,e),Object.defineProperty(r.prototype,"componentType",{get:function(){var e;return null!==(e=this.componentService.getCustomComponentType(this.model))&&void 0!==e?e:this.getComponentType(this.model)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"startTemplate",{get:function(){return this.model.type==i.DYNAMIC_FORM_CONTROL_TYPE_ARRAY?this.layoutService.getAlignedTemplate(this.model,this.templates,"ARRAY_START"):this.layoutService.getStartTemplate(this.model,this.templates)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"endTemplate",{get:function(){return this.model.type==i.DYNAMIC_FORM_CONTROL_TYPE_ARRAY?this.layoutService.getAlignedTemplate(this.model,this.templates,"ARRAY_END"):this.layoutService.getEndTemplate(this.model,this.templates)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"formService",{get:function(){return this.form.formService},enumerable:!1,configurable:!0}),r.prototype.ngOnInit=function(){var e=this;this.onDetectChanges=this.formService.onDetectChanges.subscribe((function(t){t===e.form&&(e.changeDetectorRef.detectChanges(),e.formService.updateSelectOptions(e.model,e.control))}))},r.prototype.ngOnDestroy=function(){e.prototype.ngOnDestroy.call(this),this.onDetectChanges.unsubscribe()},r.prototype.createFormControlComponent=function(){var r;e.prototype.createFormControlComponent.call(this);var n=null===(r=this.componentRef)||void 0===r?void 0:r.instance;n&&t.ObjectUtils.isFunction(n.onCreated)&&n.onCreated()},r.prototype.getComponentType=function(e){return null},r}(i.DynamicFormControlContainerComponent);T.decorators=[{type:n.Component,args:[{selector:"dynamic-base-form-control",template:"",changeDetection:n.ChangeDetectionStrategy.OnPush}]}],T.ctorParameters=function(){return[{type:I},{type:n.ChangeDetectorRef},{type:n.ComponentFactoryResolver},{type:i.DynamicFormLayoutService},{type:i.DynamicFormValidationService},{type:i.DynamicFormComponentService},{type:i.DynamicFormRelationService}]},T.propDecorators={contentTemplateList:[{type:n.ContentChildren,args:[i.DynamicTemplateDirective]}],klass:[{type:n.HostBinding,args:["class"]}],context:[{type:n.Input}],group:[{type:n.Input}],hostClass:[{type:n.Input}],inputTemplateList:[{type:n.Input,args:["templates"]}],layout:[{type:n.Input}],model:[{type:n.Input}],blur:[{type:n.Output}],change:[{type:n.Output}],focus:[{type:n.Output}],componentViewContainerRef:[{type:n.ViewChild,args:["componentViewContainer",{read:n.ViewContainerRef,static:!0}]}]};var U=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return F(t,e),t.prototype.showErrorMessages=function(t,r,n){return e.prototype.showErrorMessages.call(this,t,r,n)},t}(i.DynamicFormValidationService);U.decorators=[{type:n.Injectable}];var V=[I,T],k=[R],N=[],P=v,_=b,L=C,G=new Map([["validateJSON",v],["validateRequiredTranslation",b],["validatePhone",C]]),z=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[M,U,{provide:i.DynamicFormService,useExisting:M},{provide:i.DynamicFormValidationService,useExisting:U}]}},e}();z.decorators=[{type:n.NgModule,args:[{declarations:x(V,k,N),imports:[s.CommonModule,o.FormsModule,o.ReactiveFormsModule,t.NgxUtilsModule],exports:x(V,k,N,[o.FormsModule,o.ReactiveFormsModule,t.NgxUtilsModule]),entryComponents:V,providers:x(N,[{provide:o.NG_VALIDATORS,useValue:P,multi:!0},{provide:o.NG_VALIDATORS,useValue:_,multi:!0},{provide:o.NG_VALIDATORS,useValue:L,multi:!0},{provide:i.DYNAMIC_VALIDATORS,useValue:G}])}]}],e.AsyncSubmitDirective=R,e.DynamicBaseFormComponent=I,e.DynamicBaseFormControlContainerComponent=T,e.DynamicFormService=M,e.FormFieldSet=function(e){return function(r){var n=m(r);e.classes=e.classes||"",n[e.id]=e,t.ReflectUtils.defineMetadata("dynamicFormFieldSets",n,r)}},e.FormFile=function(e){return function(r,n){p(r,n,function(e,r){var n=f(e,"file",r);return(r=n.data).accept=r.accept||".jpg,.jpeg,.png",r.multi=r.multi||!1,r.baseUrl=t.ObjectUtils.isString(r.baseUrl)?r.baseUrl:"assets/",r.uploadUrl=t.ObjectUtils.isString(r.uploadUrl)?r.uploadUrl:"assets",r.createUploadData=r.createUploadData||function(e){var t=new FormData;return t.append("file",e),t},n}(n,e))}},e.FormInput=function(e){return function(r,n){var o=t.ReflectUtils.getOwnMetadata("design:type",r,n),i=o?o.name:"",a=n.indexOf("password")<0?"text":"password";switch(i){case"Number":a="number";break;case"Boolean":a="checkbox"}p(r,n,h(n,e,a))}},e.FormModel=function(e){return function(t,r){p(t,r,g(r,e))}},e.FormSelect=function(e){return function(t,r){p(t,r,d(r,e))}},e.FormSerializable=function(e){return function(r,n){t.ReflectUtils.defineMetadata("dynamicFormSerializer",e||l,r,n)}},e.FormStatic=function(e){return function(t,r){p(t,r,y(r,e))}},e.FormSubject=j,e.NgxDynamicFormModule=z,e.createFormControl=f,e.createFormInput=h,e.createFormModel=g,e.createFormSelect=d,e.createFormStatic=y,e.defaultSerializer=l,e.defineFormControl=p,e.getFormControl=function(e,r){return t.ReflectUtils.getMetadata("dynamicFormControl",e,r)},e.getFormFieldSets=m,e.getFormSerializer=function(e,r){return t.ReflectUtils.getMetadata("dynamicFormSerializer",e,r)},e.validateJSON=v,e.validatePhone=C,e.validateRequiredTranslation=b,e.ɵa=V,e.ɵb=k,e.ɵc=N,e.ɵd=U,Object.defineProperty(e,"__esModule",{value:!0})}));
16
16
  //# sourceMappingURL=stemy-ngx-dynamic-form.umd.min.js.map