@ngx-formly/core 5.10.23 → 5.10.24
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.
- package/bundles/ngx-formly-core.umd.js +8 -1
- package/bundles/ngx-formly-core.umd.js.map +1 -1
- package/bundles/ngx-formly-core.umd.min.js +1 -1
- package/bundles/ngx-formly-core.umd.min.js.map +1 -1
- package/esm2015/lib/components/formly.field.js +9 -2
- package/esm5/lib/components/formly.field.js +9 -2
- package/fesm2015/ngx-formly-core.js +9 -2
- package/fesm2015/ngx-formly-core.js.map +1 -1
- package/fesm5/ngx-formly-core.js +8 -1
- package/fesm5/ngx-formly-core.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/platform-browser"),require("rxjs/operators"),require("@angular/forms"),require("rxjs")):"function"==typeof define&&define.amd?define("@ngx-formly/core",["exports","@angular/common","@angular/core","@angular/platform-browser","rxjs/operators","@angular/forms","rxjs"],t):t((e["ngx-formly"]=e["ngx-formly"]||{},e["ngx-formly"].core={}),e.ng.common,e.ng.core,e.ng.platformBrowser,e.rxjs.operators,e.ng.forms,e.rxjs)}(this,function(e,r,s,t,p,f,u){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function n(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var c=function(){return(c=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function d(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}function h(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function m(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(o=i.next()).done;)s.push(o.value)}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=i["return"])&&r.call(i)}finally{if(n)throw n.error}}return s}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}function g(e){if(!e.key)return[];if(!e._keyPath||e._keyPath.key!==e.key){var t=[];if("string"==typeof e.key){var r=-1===e.key.indexOf("[")?e.key:e.key.replace(/\[(\w+)\]/g,".$1");t=-1!==r.indexOf(".")?r.split("."):[r]}else t=Array.isArray(e.key)?e.key.slice(0):[""+e.key];e._keyPath={key:e.key,path:t}}return e._keyPath.path.slice(0)}var a=["required","pattern","minLength","maxLength","min","max"];function i(e,t){var r=g(e);if(0!==r.length){for(var o=e;o.parent;)r=y(g(o=o.parent),r);if(t===undefined&&e.resetOnHide){var n=r.pop();delete r.reduce(function(e,t){return e[t]||{}},o.model)[n]}else!function i(e,t,r){for(var o=0;o<t.length-1;o++){var n=t[o];e[n]&&F(e[n])||(e[n]=/^\d+$/.test(t[o+1])?[]:{}),e=e[n]}e[t[t.length-1]]=_(r)}(o.model,r,t)}}function v(e){var t,r,o=e.parent.model;try{for(var n=h(g(e)),i=n.next();!i.done;i=n.next()){var s=i.value;if(!o)return o;o=o[s]}}catch(a){t={error:a}}finally{try{i&&!i.done&&(r=n["return"])&&r.call(n)}finally{if(t)throw t.error}}return o}function l(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return e.forEach(function(e){for(var t in e)b(n[t])||""===n[t]?n[t]=_(e[t]):(r=n[t],o=e[t],F(r)&&F(o)&&Object.getPrototypeOf(r)===Object.getPrototypeOf(o)&&!Array.isArray(r)&&!Array.isArray(o)&&l(n[t],e[t]));var r,o}),n}function b(e){return e===undefined||null===e}function C(e){return e===undefined}function O(e){return"function"==typeof e}function F(e){return null!=e&&"object"==typeof e}function _(o){if(!F(o)||u.isObservable(o)||o.changingThisBreaksApplicationSecurity||-1!==["RegExp","FileList","File","Blob"].indexOf(o.constructor.name))return o;if(o instanceof Set)return new Set(o);if(o instanceof Map)return new Map(o);if(o._isAMomentObject&&O(o.clone))return o.clone();if(o instanceof f.AbstractControl)return null;if(o instanceof Date)return new Date(o.getTime());if(Array.isArray(o))return o.slice(0).map(function(e){return _(e)});var e=Object.getPrototypeOf(o),t=Object.create(e);return t=Object.setPrototypeOf(t,e),Object.keys(o).reduce(function(e,t){var r=Object.getOwnPropertyDescriptor(o,t);return r.get?Object.defineProperty(e,t,r):e[t]=_(o[t]),e},t)}function E(e,t,r){Object.defineProperty(e,t,{enumerable:!1,writable:!0,configurable:!0}),e[t]=r}function x(e,o,t){e._observers||E(e,"_observers",{}),e._observers[o]||(e._observers[o]=[]);var n=e._observers[o];return-1===n.indexOf(t)&&(n.push(t),t({currentValue:e[o],firstChange:!0}),1===n.length&&(E(e,"___$"+o,e[o]),Object.defineProperty(e,o,{configurable:!0,get:function(){return e["___$"+o]},set:function(t){if(t!==e["___$"+o]){var r=e["___$"+o];e["___$"+o]=t,n.forEach(function(e){return e({previousValue:r,currentValue:t,firstChange:!1})})}}}))),function(){return n.splice(n.indexOf(t),1)}}function k(e,t){var r=e._updateTreeValidity.bind(e),o={called:!1,emitEvent:!1};e._updateTreeValidity=function(e){var t=(void 0===e?{emitEvent:!0}:e).emitEvent;return o={called:!0,emitEvent:t||o.emitEvent}},t(),o.called&&r({emitEvent:o.emitEvent}),e._updateTreeValidity=r}var w=new s.InjectionToken("FORMLY_CONFIG"),P=function(){function e(){this.types={},this.validators={},this.wrappers={},this.messages={},this.templateManipulators={preWrapper:[],postWrapper:[]},this.extras={checkExpressionOn:"changeDetectionCheck",lazyRender:!1,showError:function(e){return e.formControl&&e.formControl.invalid&&(e.formControl.touched||e.options.parentForm&&e.options.parentForm.submitted||!(!e.field.validation||!e.field.validation.show))}},this.extensions={}}return e.prototype.addConfig=function(e){var t=this;e.types&&e.types.forEach(function(e){return t.setType(e)}),e.validators&&e.validators.forEach(function(e){return t.setValidator(e)}),e.wrappers&&e.wrappers.forEach(function(e){return t.setWrapper(e)}),e.manipulators&&(console.warn("NgxFormly: passing 'manipulators' config is deprecated, use custom extension instead."),e.manipulators.forEach(function(e){return t.setManipulator(e)})),e.validationMessages&&e.validationMessages.forEach(function(e){return t.addValidatorMessage(e.name,e.message)}),e.extensions&&e.extensions.forEach(function(e){return t.extensions[e.name]=e.extension}),e.extras&&(this.extras=c({},this.extras,e.extras))},e.prototype.setType=function(t){var r=this;Array.isArray(t)?t.forEach(function(e){return r.setType(e)}):(this.types[t.name]||(this.types[t.name]={name:t.name}),["component","extends","defaultOptions","wrappers"].forEach(function(e){t.hasOwnProperty(e)&&(r.types[t.name][e]=t[e])}))},e.prototype.getType=function(e){if(!this.types[e])throw new Error('[Formly Error] The type "'+e+'" could not be found. Please make sure that is registered through the FormlyModule declaration.');return this.mergeExtendedType(e),this.types[e]},e.prototype.getMergedField=function(r){var o=this;void 0===r&&(r={});var e=this.getType(r.type);e.defaultOptions&&l(r,e.defaultOptions);var t=e["extends"]&&this.getType(e["extends"]).defaultOptions;t&&l(r,t),r&&r.optionsTypes&&r.optionsTypes.forEach(function(e){var t=o.getType(e).defaultOptions;t&&l(r,t)});var n=this.resolveFieldTypeRef(r);n&&n.instance&&n.instance.defaultOptions&&l(r,n.instance.defaultOptions),!r.wrappers&&e.wrappers&&(r.wrappers=y(e.wrappers))},e.prototype.resolveFieldTypeRef=function(e){if(void 0===e&&(e={}),!e.type)return null;var t=this.getType(e.type);if(!t.component||t._componentRef)return t._componentRef;var r=e.parent.options,o=r._resolver,n=r._injector,i=o.resolveComponentFactory(t.component).create(n);return E(t,"_componentRef",i),i.destroy(),t._componentRef},e.prototype.setWrapper=function(t){var r=this;(this.wrappers[t.name]=t).types&&t.types.forEach(function(e){r.setTypeWrapper(e,t.name)})},e.prototype.getWrapper=function(e){if(!this.wrappers[e])throw new Error('[Formly Error] The wrapper "'+e+'" could not be found. Please make sure that is registered through the FormlyModule declaration.');return this.wrappers[e]},e.prototype.setTypeWrapper=function(e,t){this.types[e]||(this.types[e]={}),this.types[e].wrappers||(this.types[e].wrappers=[]),-1===this.types[e].wrappers.indexOf(t)&&this.types[e].wrappers.push(t)},e.prototype.setValidator=function(e){this.validators[e.name]=e},e.prototype.getValidator=function(e){if(!this.validators[e])throw new Error('[Formly Error] The validator "'+e+'" could not be found. Please make sure that is registered through the FormlyModule declaration.');return this.validators[e]},e.prototype.addValidatorMessage=function(e,t){this.messages[e]=t},e.prototype.getValidatorMessage=function(e){return this.messages[e]},e.prototype.setManipulator=function(e){(new e["class"])[e.method](this)},e.prototype.mergeExtendedType=function(e){if(this.types[e]["extends"]){var t=this.getType(this.types[e]["extends"]);this.types[e].component||(this.types[e].component=t.component),this.types[e].wrappers||(this.types[e].wrappers=t.wrappers)}},e.decorators=[{type:s.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=s.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),V=function(){function e(e,t,r){this.formlyConfig=e,this.componentFactoryResolver=t,this.injector=r}return e.prototype.buildForm=function(e,t,r,o){var n=this;if(void 0===t&&(t=[]),!this.formlyConfig.extensions.core)throw new Error("NgxFormly: missing `forRoot()` call. use `forRoot()` when registering the `FormlyModule`.");var i={fieldGroup:t,model:r,formControl:e,options:this._setOptions(o)};k(e,function(){return n._buildForm(i)}),i.options._checkField(i,!0)},e.prototype._buildForm=function(t){var r=this;this.getExtensions().forEach(function(e){return e.prePopulate&&e.prePopulate(t)}),this.getExtensions().forEach(function(e){return e.onPopulate&&e.onPopulate(t)}),t.fieldGroup&&t.fieldGroup.forEach(function(e){return r._buildForm(e)}),this.getExtensions().forEach(function(e){return e.postPopulate&&e.postPopulate(t)})},e.prototype.getExtensions=function(){var t=this;return Object.keys(this.formlyConfig.extensions).map(function(e){return t.formlyConfig.extensions[e]})},e.prototype._setOptions=function(t){var r=this;return(t=t||{}).formState=t.formState||{},t.showError||(t.showError=this.formlyConfig.extras.showError),t.fieldChanges||E(t,"fieldChanges",new u.Subject),t._resolver||E(t,"_resolver",this.componentFactoryResolver),t._injector||E(t,"_injector",this.injector),t._hiddenFieldsForCheck||(t._hiddenFieldsForCheck=[]),t._markForCheck||(t._markForCheck=function(e){e._componentRefs&&e._componentRefs.forEach(function(e){e.injector.get(s.ChangeDetectorRef).markForCheck()}),e.fieldGroup&&e.fieldGroup.forEach(function(e){return t._markForCheck(e)})}),t._buildField||(t._buildField=function(e){return r.buildForm(e.form,e.fieldGroup,e.model,e.options),e}),t},e.decorators=[{type:s.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:P},{type:s.ComponentFactoryResolver},{type:s.Injector}]},e.ngInjectableDef=s.defineInjectable({factory:function(){return new e(s.inject(P),s.inject(s.ComponentFactoryResolver),s.inject(s.INJECTOR))},token:e,providedIn:"root"}),e}();function j(e,t){void 0===t&&(t=!1);var r=e.formControl.parent;if(r){var o=e.formControl,n={emitEvent:t};if(r instanceof f.FormArray){var i=r.controls.findIndex(function(e){return e===o});-1!==i&&M(r,n,function(){return r.removeAt(i)})}else if(r instanceof f.FormGroup){var s=g(e),a=s[s.length-1];r.get([a])===o&&M(r,n,function(){return r.removeControl(a)})}o.setParent(null)}}function R(e){if(e.formControl)return e.formControl;if(!1===e.shareFormControl)return null;var t=e.parent.formControl;return t?t.get(g(e)):null}function A(o,e,r){void 0===r&&(r=!1),(e=e||o.formControl)._fields||E(e,"_fields",[]),-1===e._fields.indexOf(o)&&e._fields.push(o),!o.formControl&&e&&(E(o,"formControl",e),e.setValidators(null),e.setAsyncValidators(null),o.templateOptions.disabled=!!o.templateOptions.disabled,x(o.templateOptions,"disabled",function(e){var t=e.firstChange,r=e.currentValue;t||(r?o.formControl.disable():o.formControl.enable())}),e.registerOnDisabledChange&&e.registerOnDisabledChange(function(e){o.templateOptions.___$disabled=e,o.options&&o.options._markForCheck(o)}));var n=o.parent.formControl;if(n&&o.key){var i=g(o),t=v(o);b(e.value)&&b(t)||e.value===t||!(e instanceof f.FormControl)||e.patchValue(t);for(var s=function(e){var t=i[e];n.get([t])||M(n,{emitEvent:r},function(){return n.setControl(t,new f.FormGroup({}))}),n=n.get([t])},a=0;a<i.length-1;a++)s(a);var l=i[i.length-1];o._hide||n.get([l])===e||M(n,{emitEvent:r},function(){return n.setControl(l,e)})}}function G(e){var t=e.status;e.updateValueAndValidity({emitEvent:!1}),t!==e.status&&e.statusChanges.emit(e.status)}function M(r,e,t){r instanceof f.FormGroup&&!r.__patchForEachChild&&(E(r,"__patchForEachChild",!0),r._forEachChild=function(t){Object.keys(r.controls).forEach(function(e){return r.controls[e]&&t(r.controls[e],e)})});var o=r.updateValueAndValidity.bind(r);!1===e.emitEvent&&(r.updateValueAndValidity=function(e){o(c({},e||{},{emitEvent:!1}))}),t(),!1===e.emitEvent&&(r.updateValueAndValidity=o)}var I=function(){function e(e,t,r,o,n){var i=this;this.formlyBuilder=e,this.formlyConfig=t,this.ngZone=r,this.parentFormGroup=n,this.modelChange=new s.EventEmitter,this.immutable=!1,this._modelChangeValue={},this.modelChangeSubs=[],this.modelChange$=new u.Subject,this.modelChangeSub=this.modelChange$.pipe(p.switchMap(function(){return i.ngZone.onStable.asObservable().pipe(p.take(1))})).subscribe(function(){return i.ngZone.runGuarded(function(){i.checkExpressionChange(),i.modelChange.emit(i._modelChangeValue=_(i.model))})}),null!==o&&console.warn("NgxFormly: passing 'immutable' attribute to 'formly-form' component is deprecated since v5.5, enable immutable mode through NgModule declaration instead."),this.immutable=null!==o||!!t.extras.immutable}return Object.defineProperty(e.prototype,"model",{get:function(){return this._model||(this._model={}),this._model},set:function(e){this._model=this.immutable?_(e):e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fields",{get:function(){return this._fields||[]},set:function(e){this._fields=this.immutable?_(e):e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(e){this._options=this.immutable?_(e):e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"content",{set:function(e){if(e){for(var t=!1,r=e.nativeElement.nextSibling;r&&!t;)(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE&&r.textContent&&""!==r.textContent.trim())&&(t=!0),r=r.nextSibling;t&&console.warn("NgxFormly: content projection for 'formly-form' component is deprecated since v5.5, you should avoid passing content inside the 'formly-form' tag.")}},enumerable:!0,configurable:!0}),e.prototype.ngDoCheck=function(){"changeDetectionCheck"===this.formlyConfig.extras.checkExpressionOn&&this.checkExpressionChange()},e.prototype.ngOnChanges=function(e){e.model&&this.field&&(this.field.model=this.model),e.fields&&this.form&&function r(t){t._fields&&delete t._fields,(t instanceof f.FormGroup||t instanceof f.FormArray)&&Object.keys(t.controls).forEach(function(e){return r(t.controls[e])})}(this.form),(e.fields||e.form||e.model&&this._modelChangeValue!==e.model.currentValue)&&(this.form=this.form||new f.FormGroup({}),this.setOptions(),this.options.updateInitialValue(),this.clearModelSubscriptions(),this.formlyBuilder.buildForm(this.form,this.fields,this.model,this.options),this.trackModelChanges(this.fields))},e.prototype.ngOnDestroy=function(){this.modelChangeSub.unsubscribe(),this.clearModelSubscriptions()},e.prototype.changeModel=function(e){e.key;var t=e.value;i(e.field,t),this.modelChange$.next()},e.prototype.setOptions=function(){var t=this;this.options||(this.options={}),this.options.resetModel||(this.options.resetModel=function(e){e=_(b(e)?t.options._initialModel:e),t.model&&(Object.keys(t.model).forEach(function(e){return delete t.model[e]}),Object.assign(t.model,e||{})),t.options._buildForm(),t.options.parentForm&&t.options.parentForm.control===t.form?t.options.parentForm.resetForm(t.model):t.form.reset(t.model)}),!this.options.parentForm&&this.parentFormGroup&&(E(this.options,"parentForm",this.parentFormGroup),x(this.options.parentForm,"submitted",function(e){e.firstChange||(t.checkExpressionChange(),t.options._markForCheck({fieldGroup:t.fields,model:t.model,formControl:t.form,options:t.options}))})),this.options.updateInitialValue||(this.options.updateInitialValue=function(){return t.options._initialModel=_(t.model)}),this.options._buildForm||(this.options._buildForm=function(e){void 0===e&&(e=!1),t.clearModelSubscriptions(),t.formlyBuilder.buildForm(t.form,t.fields,t.model,t.options),t.trackModelChanges(t.fields),e&&t.modelChange.emit(t._modelChangeValue=_(t.model))})},e.prototype.checkExpressionChange=function(){this.options&&this.options._checkField&&this.options._checkField({fieldGroup:this.fields,model:this.model,formControl:this.form,options:this.options})},e.prototype.trackModelChanges=function(e,a){var l=this;void 0===a&&(a=[]),e.forEach(function(e){if(e.key&&!e.fieldGroup&&e.formControl){var r=e.formControl,t=r.valueChanges.pipe(p.distinctUntilChanged(function(e,t){return e===t&&!Array.isArray(e)&&!F(e)})),o=e.modelOptions,n=o.updateOn,i=o.debounce;(!n||"change"===n)&&i&&0<i["default"]&&(t=r.valueChanges.pipe(p.debounceTime(i["default"]))),l.modelChangeSubs.push(t.subscribe(function(t){r instanceof f.FormControl&&r._fields&&1<r._fields.length&&r.patchValue(t,{emitEvent:!1,onlySelf:!0}),e.parsers&&0<e.parsers.length&&e.parsers.forEach(function(e){return t=e(t)}),l.changeModel({key:y(a,g(e)).join("."),value:t,field:e})}));var s=r.valueChanges.observers;s&&1<s.length&&s.unshift(s.pop())}e.fieldGroup&&0<e.fieldGroup.length&&l.trackModelChanges(e.fieldGroup,e.key?y(a,g(e)):a)})},e.prototype.clearModelSubscriptions=function(){this.modelChangeSubs.forEach(function(e){return e.unsubscribe()}),this.modelChangeSubs=[]},Object.defineProperty(e.prototype,"field",{get:function(){return this.fields&&this.fields[0]&&this.fields[0].parent},enumerable:!0,configurable:!0}),e.decorators=[{type:s.Component,args:[{selector:"formly-form",template:'\n <formly-field *ngFor="let field of fields"\n hide-deprecation\n [form]="field.form"\n [options]="field.options"\n [model]="field.model"\n [field]="field">\n </formly-field>\n <ng-container #content>\n <ng-content></ng-content>\n </ng-container>\n ',providers:[V]}]}],e.ctorParameters=function(){return[{type:V},{type:P},{type:s.NgZone},{type:undefined,decorators:[{type:s.Attribute,args:["immutable"]}]},{type:f.FormGroupDirective,decorators:[{type:s.Optional}]}]},e.propDecorators={form:[{type:s.Input}],model:[{type:s.Input}],fields:[{type:s.Input}],options:[{type:s.Input}],modelChange:[{type:s.Output}],content:[{type:s.ViewChild,args:["content"]}]},e}(),T=function(){function e(e,t,r,o,n){this.formlyConfig=e,this.renderer=t,this.resolver=r,this.elementRef=o,this.warnDeprecation=!1,this.modelChange=new s.EventEmitter,this.hostObservers=[],this.componentRefs=[],this.hooksObservers=[],this.detectFieldBuild=!1,this.warnDeprecation=null===n}return Object.defineProperty(e.prototype,"model",{set:function(e){this.warnDeprecation&&console.warn("NgxFormly: passing 'model' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"form",{set:function(e){this.warnDeprecation&&console.warn("NgxFormly: passing 'form' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{set:function(e){this.warnDeprecation&&console.warn("NgxFormly: passing 'options' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),e.prototype.ngAfterContentInit=function(){this.triggerHook("afterContentInit")},e.prototype.ngAfterContentChecked=function(){this.triggerHook("afterContentChecked")},e.prototype.ngAfterViewInit=function(){this.triggerHook("afterViewInit")},e.prototype.ngAfterViewChecked=function(){this.triggerHook("afterViewChecked")},e.prototype.ngDoCheck=function(){this.triggerHook("doCheck"),this.detectFieldBuild&&this.field&&this.field.options&&this.render()},e.prototype.ngOnInit=function(){this.triggerHook("onInit")},e.prototype.ngOnChanges=function(e){this.triggerHook("onChanges",e)},e.prototype.ngOnDestroy=function(){this.resetRefs(this.field),this.hostObservers.forEach(function(e){return e()}),this.hooksObservers.forEach(function(e){return e()}),this.triggerHook("onDestroy")},e.prototype.renderField=function(e,i,t){var s=this;if(void 0===t&&(t=[]),this.containerRef===e&&(this.resetRefs(this.field),this.containerRef.clear(),t=this.field?this.field.wrappers:[]),t&&0<t.length){var r=m(t),o=r[0],a=r.slice(1),n=this.formlyConfig.getWrapper(o).component,l=e.createComponent(this.resolver.resolveComponentFactory(n));this.attachComponentRef(l,i),x(l.instance,"fieldComponent",function(e){var t=e.firstChange,r=e.previousValue,o=e.currentValue;if(o){if(r&&r._lContainer===o._lContainer)return;var n=r?r.detach():null;n&&!n.destroyed?o.insert(n):s.renderField(o,i,a),!t&&l.changeDetectorRef.detectChanges()}})}else if(i&&i.type){n=this.formlyConfig.getType(i.type).component;var p=e.createComponent(this.resolver.resolveComponentFactory(n));this.attachComponentRef(p,i)}},e.prototype.triggerHook=function(e,t){if(this.field&&this.field.hooks&&this.field.hooks[e]&&(!t||t.field)){var r=this.field.hooks[e](this.field);if(u.isObservable(r)&&-1!==["onInit","afterContentInit","afterViewInit"].indexOf(e)){var o=r.subscribe();this.hooksObservers.push(function(){return o.unsubscribe()})}}this.field&&this.field.lifecycle&&this.field.lifecycle[e]&&this.field.lifecycle[e](this.field.form,this.field,this.field.model,this.field.options),"onChanges"===e&&t.field&&(this.resetRefs(t.field.previousValue),this.render())},e.prototype.attachComponentRef=function(e,t){this.componentRefs.push(e),t._componentRefs.push(e),Object.assign(e.instance,{field:t})},e.prototype.render=function(){var o=this;this.field&&(this.field.options?(this.detectFieldBuild=!1,this.hostObservers.forEach(function(e){return e()}),this.hostObservers=[x(this.field,"hide",function(e){var t=e.firstChange,r=e.currentValue;o.formlyConfig.extras.lazyRender?r?o.containerRef.clear():o.renderField(o.containerRef,o.field):(t&&o.renderField(o.containerRef,o.field),(!t||t&&r)&&o.renderer.setStyle(o.elementRef.nativeElement,"display",r?"none":""))}),x(this.field,"className",function(e){var t=e.firstChange,r=e.currentValue;(!t||t&&r)&&o.renderer.setAttribute(o.elementRef.nativeElement,"class",r)})]):this.detectFieldBuild=!0)},e.prototype.resetRefs=function(e){var t=this;e&&(e._componentRefs?e._componentRefs=e._componentRefs.filter(function(e){return-1===t.componentRefs.indexOf(e)}):E(this.field,"_componentRefs",[])),this.componentRefs=[]},e.decorators=[{type:s.Component,args:[{selector:"formly-field",template:"<ng-template #container></ng-template>"}]}],e.ctorParameters=function(){return[{type:P},{type:s.Renderer2},{type:s.ComponentFactoryResolver},{type:s.ElementRef},{type:undefined,decorators:[{type:s.Attribute,args:["hide-deprecation"]}]}]},e.propDecorators={field:[{type:s.Input}],model:[{type:s.Input}],form:[{type:s.Input}],options:[{type:s.Input}],modelChange:[{type:s.Output}],containerRef:[{type:s.ViewChild,args:["container",{read:s.ViewContainerRef,"static":!0}]}]},e}(),D=function(){function e(e,t,r){this.renderer=e,this.elementRef=t,this.uiAttributesCache={},this.uiAttributes=y(a,["tabindex","placeholder","readonly","disabled","step"]),this.uiEvents={listeners:[],events:["click","keyup","keydown","keypress"]},this.document=r}return Object.defineProperty(e.prototype,"to",{get:function(){return this.field.templateOptions||{}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fieldAttrElements",{get:function(){return this.field&&this.field._elementRefs||[]},enumerable:!0,configurable:!0}),e.prototype.ngOnChanges=function(e){var o=this;e.field&&(this.field.name&&this.setAttribute("name",this.field.name),this.uiEvents.listeners.forEach(function(e){return e()}),this.uiEvents.events.forEach(function(t){o.to&&o.to[t]&&o.uiEvents.listeners.push(o.renderer.listen(o.elementRef.nativeElement,t,function(e){return o.to[t](o.field,e)}))}),this.to&&this.to.attributes&&x(this.to,"attributes",function(e){var t=e.currentValue,r=e.previousValue;r&&Object.keys(r).forEach(function(e){return o.removeAttribute(e)}),t&&Object.keys(t).forEach(function(e){null!=t[e]&&o.setAttribute(e,t[e])})}),this.detachElementRef(e.field.previousValue),this.attachElementRef(e.field.currentValue),1===this.fieldAttrElements.length&&(!this.id&&this.field.id&&this.setAttribute("id",this.field.id),x(this.field,"focus",function(e){var t=e.currentValue;o.toggleFocus(t)}))),e.id&&this.setAttribute("id",this.id)},e.prototype.ngDoCheck=function(){var r=this;this.uiAttributes.forEach(function(e){var t=r.to[e];r.uiAttributesCache[e]===t||r.to.attributes&&r.to.attributes.hasOwnProperty(e.toLowerCase())||((r.uiAttributesCache[e]=t)||0===t?r.setAttribute(e,!0===t?e:""+t):r.removeAttribute(e))})},e.prototype.ngOnDestroy=function(){this.uiEvents.listeners.forEach(function(e){return e()}),this.detachElementRef(this.field)},e.prototype.toggleFocus=function(e){var r=this,t=this.fieldAttrElements?this.fieldAttrElements[0]:null;if(t&&t.nativeElement.focus){var o=!!this.document.activeElement&&this.fieldAttrElements.some(function(e){var t=e.nativeElement;return r.document.activeElement===t||t.contains(r.document.activeElement)});e&&!o?t.nativeElement.focus():!e&&o&&t.nativeElement.blur()}},e.prototype.onFocus=function(e){this.field.___$focus=!0,this.to.focus&&this.to.focus(this.field,e)},e.prototype.onBlur=function(e){this.field.___$focus=!1,this.to.blur&&this.to.blur(this.field,e)},e.prototype.onChange=function(e){this.to.change&&this.to.change(this.field,e),this.field.formControl&&this.field.formControl.markAsDirty()},e.prototype.attachElementRef=function(e){e&&(e._elementRefs&&-1===e._elementRefs.indexOf(this.elementRef)?e._elementRefs.push(this.elementRef):E(e,"_elementRefs",[this.elementRef]))},e.prototype.detachElementRef=function(e){var t=e&&e._elementRefs?this.fieldAttrElements.indexOf(this.elementRef):-1;-1!==t&&this.field._elementRefs.splice(t,1)},e.prototype.setAttribute=function(e,t){this.renderer.setAttribute(this.elementRef.nativeElement,e,t)},e.prototype.removeAttribute=function(e){this.renderer.removeAttribute(this.elementRef.nativeElement,e)},e.decorators=[{type:s.Directive,args:[{selector:"[formlyAttributes]",host:{"(focus)":"onFocus($event)","(blur)":"onBlur($event)","(change)":"onChange($event)"}}]}],e.ctorParameters=function(){return[{type:s.Renderer2},{type:s.ElementRef},{type:undefined,decorators:[{type:s.Inject,args:[r.DOCUMENT]}]}]},e.propDecorators={field:[{type:s.Input,args:["formlyAttributes"]}],id:[{type:s.Input}]},e}(),S=function(){function e(){}return Object.defineProperty(e.prototype,"model",{get:function(){return this.field.model},set:function(e){console.warn("NgxFormly: passing 'model' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"form",{get:function(){return this.field.parent.formControl},set:function(e){console.warn("NgxFormly: passing 'form' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.field.options},set:function(e){console.warn("NgxFormly: passing 'options' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this.field.key},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formControl",{get:function(){return this.field.formControl},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this.field.templateOptions||{}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showError",{get:function(){return this.options.showError(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.field.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formState",{get:function(){return this.options.formState||{}},enumerable:!0,configurable:!0}),e.propDecorators={field:[{type:s.Input}],model:[{type:s.Input}],form:[{type:s.Input}],options:[{type:s.Input}]},e}(),N=function(t){function e(){var e=t.call(this)||this;return console.warn("NgxFormly: 'Field' has been renamed to 'FieldType', extend 'FieldType' instead."),e}return n(e,t),e}(S),H=function(r){function e(e){var t=r.call(this)||this;return t.defaultOptions={defaultValue:[]},e instanceof V&&console.warn("NgxFormly: passing 'FormlyFormBuilder' to '"+t.constructor.name+"' type is not required anymore, you may remove it!"),t}return n(e,r),Object.defineProperty(e.prototype,"formControl",{get:function(){return this.field.formControl},enumerable:!0,configurable:!0}),e.prototype.onPopulate=function(e){if(!e.formControl&&e.key){var t=R(e);A(e,t||new f.FormArray([],{updateOn:e.modelOptions.updateOn}))}e.fieldGroup=e.fieldGroup||[];var r=e.model?e.model.length:0;if(e.fieldGroup.length>r)for(var o=e.fieldGroup.length-1;r<=o;--o)j(e.fieldGroup[o]),e.fieldGroup.splice(o,1);for(o=e.fieldGroup.length;o<r;o++){var n=c({},_(e.fieldArray),{key:""+o});e.fieldGroup.push(n)}},e.prototype.add=function(e,t,r){var o=(void 0===r?{markAsDirty:!0}:r).markAsDirty;e=b(e)?this.field.fieldGroup.length:e,this.model||i(this.field,[]),this.model.splice(e,0,t?_(t):undefined),this.options._buildForm(!0),o&&this.formControl.markAsDirty()},e.prototype.remove=function(e,t){var r=(void 0===t?{markAsDirty:!0}:t).markAsDirty;this.model.splice(e,1),j(this.field.fieldGroup[e],!0),this.field.fieldGroup.splice(e,1),this.field.fieldGroup.forEach(function(e,t){return e.key=""+t}),this.options._buildForm(!0),r&&this.formControl.markAsDirty()},e.decorators=[{type:s.Directive,args:[{selector:"[ɵfieldArray]"}]}],e.ctorParameters=function(){return[{type:V,decorators:[{type:s.Inject,args:[w]},{type:s.Optional}]}]},e}(S),W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.propDecorators={fieldComponent:[{type:s.ViewChild,args:["fieldComponent",{read:s.ViewContainerRef,"static":!1}]}]},t}(S),$=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.defaultOptions={defaultValue:{}},e}return n(e,t),e.decorators=[{type:s.Component,args:[{selector:"formly-group",template:'\n <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>\n <ng-content></ng-content>\n ',host:{"[class]":'field.fieldGroupClassName || ""'}}]}],e}(S),q=function(){function e(e){this.formlyConfig=e}return e.prototype.ngOnChanges=function(){var e=this;this.errorMessage$=this.field.formControl.statusChanges.pipe(p.startWith(null),p.switchMap(function(){return u.isObservable(e.errorMessage)?e.errorMessage:u.of(e.errorMessage)}))},Object.defineProperty(e.prototype,"errorMessage",{get:function(){var e=this.field.formControl;for(var t in e.errors)if(e.errors.hasOwnProperty(t)){var r=this.formlyConfig.getValidatorMessage(t);if(F(e.errors[t])){if(e.errors[t].errorPath)return;e.errors[t].message&&(r=e.errors[t].message)}return this.field.validation&&this.field.validation.messages&&this.field.validation.messages[t]&&(r=this.field.validation.messages[t]),this.field.validators&&this.field.validators[t]&&this.field.validators[t].message&&(r=this.field.validators[t].message),this.field.asyncValidators&&this.field.asyncValidators[t]&&this.field.asyncValidators[t].message&&(r=this.field.asyncValidators[t].message),"function"==typeof r?r(e.errors[t],this.field):r}},enumerable:!0,configurable:!0}),e.decorators=[{type:s.Component,args:[{selector:"formly-validation-message",template:"{{ errorMessage$ | async }}",changeDetection:s.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:P}]},e.propDecorators={field:[{type:s.Input}]},e}(),B=function(r){function e(e){var t=r.call(this)||this;return t.sanitizer=e,t.innerHtml={content:null,template:null},t}return n(e,r),Object.defineProperty(e.prototype,"template",{get:function(){return this.field&&this.field.template!==this.innerHtml.template&&(this.innerHtml={template:this.field.template,content:this.to.safeHtml?this.sanitizer.bypassSecurityTrustHtml(this.field.template):this.field.template}),this.innerHtml.content},enumerable:!0,configurable:!0}),e.decorators=[{type:s.Component,args:[{selector:"formly-template",template:'<div [innerHtml]="template"></div>'}]}],e.ctorParameters=function(){return[{type:t.DomSanitizer}]},e}(S);function L(e,t,r){return e instanceof Function?e.apply(t,r):!!e}var Y=function(){function e(){}return e.prototype.prePopulate=function(e){var r=this;if(!e.parent&&!e.options._checkField){var o=!1;e.options._checkField=function(e,t){o||(o=!0,k(e.formControl,function(){return r.checkField(e,t)}),o=!1)}}},e.prototype.postPopulate=function(s){var a=this;if(s.parent&&!s._expressionProperties){if(E(s,"_expressionProperties",{}),s.expressionProperties){var e=function(t){var e=s.expressionProperties[t];if("string"==typeof e||O(e))s._expressionProperties[t]={expression:l._evalExpression(t,e,"templateOptions.disabled"===t&&s.parent.expressionProperties&&s.parent.expressionProperties.hasOwnProperty("templateOptions.disabled")?function(){return s.parent.templateOptions.disabled}:undefined)},"templateOptions.disabled"===t&&Object.defineProperty(s._expressionProperties[t],"expressionValue",{get:function(){return s.templateOptions.disabled},set:function(){},enumerable:!0,configurable:!0});else if(e instanceof u.Observable){var r=function(){return e.subscribe(function(e){a.setExprValue(s,t,e),s.options&&s.options._markForCheck&&s.options._markForCheck(s)})},o=r(),n=s.hooks.onInit;s.hooks.onInit=function(){return null===o&&(o=r()),n&&n(s)};var i=s.hooks.onDestroy;s.hooks.onDestroy=function(){i&&i(s),o.unsubscribe(),o=null}}},l=this;for(var t in s.expressionProperties)e(t)}s.hideExpression?(delete s.hide,s.hideExpression=this._evalExpression("hide",s.hideExpression,function(){for(var e=s.parent;e.parent&&!e.hide;)e=e.parent;return e.hide})):x(s,"hide",function(e){var t=e.currentValue,r=e.firstChange;s._hide=t,(!r||r&&!0===t)&&s.options._hiddenFieldsForCheck.push(s)})}},e.prototype._evalExpression=function(i,s,a){return function(e,t,r){try{return"string"==typeof s&&(s=function o(e,t){try{return-1!==e.indexOf("this.field")&&console.warn("NgxFormly: using 'this.field' in expressionProperties is deprecated since v5.1, use 'field' instead."),Function.apply(void 0,y(t,["return "+e+";"]))}catch(r){console.error(r)}}(s,["model","formState","field"])),"function"!=typeof s&&(s=function(){return!!s}),a&&a()||s(e,t,r)}catch(n){throw n.message='[Formly Error] [Expression "'+i+'"] '+n.message,n}}},e.prototype.checkField=function(e,t){var r=this;void 0===t&&(t=!1);var o=this._checkField(e,t);e.options._hiddenFieldsForCheck.sort(function(e){return e.hide?-1:1}).forEach(function(e){return r.toggleFormControl(e,!!e.hide,!t)}),e.options._hiddenFieldsForCheck=[],o&&(this.checkField(e),e.options&&e.options._markForCheck&&e.options._markForCheck(e))},e.prototype._checkField=function(t,r){var o=this;void 0===r&&(r=!1);var n=!1;return t.fieldGroup.forEach(function(e){e.options&&(o.checkFieldExpressionChange(e,r)&&(n=!0),o.checkFieldVisibilityChange(e,r)&&(t.options._hiddenFieldsForCheck.push(e),n=!0),e.fieldGroup&&0<e.fieldGroup.length&&o._checkField(e,r)&&(n=!0))}),n},e.prototype.checkFieldExpressionChange=function(e,t){if(!e||!e._expressionProperties)return!1;var r=!1,o=e._expressionProperties;for(var n in o){var i=L(o[n].expression,{field:e},[e.model,e.options.formState,e]);"templateOptions.disabled"===n&&(i=!!i),(t||o[n].expressionValue!==i&&(!F(i)||u.isObservable(i)||JSON.stringify(i)!==JSON.stringify(o[n].expressionValue)))&&(r=!0,o[n].expressionValue=i,this.setExprValue(e,n,i))}return r},e.prototype.checkFieldVisibilityChange=function(e,t){if(!e||b(e.hideExpression))return!1;var r=!!L(e.hideExpression,{field:e},[e.model,e.options.formState,e]),o=!1;return(r!==e.hide||t)&&(o=!0,e.hide=r,e.templateOptions.hidden=r),o},e.prototype.setDisabledState=function(e,t){var r=this;e.fieldGroup&&e.fieldGroup.filter(function(e){return!e.expressionProperties||!e.expressionProperties.hasOwnProperty("templateOptions.disabled")}).forEach(function(e){return r.setDisabledState(e,t)}),e.key&&e.templateOptions.disabled!==t&&(e.templateOptions.disabled=t)},e.prototype.toggleFormControl=function(e,t,r){var o=this;if(e.formControl&&e.key){E(e,"_hide",!(!t&&!e.hide));var n=e.formControl;n._fields&&1<n._fields.length&&G(n),!0!==t||n._fields&&!n._fields.every(function(e){return!!e._hide})?!1===t&&(e.resetOnHide&&e.parent&&!C(e.defaultValue)&&C(v(e))&&i(e,e.defaultValue),A(e,undefined,!0),e.resetOnHide&&e.fieldArray&&(e.fieldGroup||[]).length!==(e.model||[]).length&&e.options._buildForm(!0)):(j(e,!0),r&&e.resetOnHide&&(e.formControl.reset({value:undefined,disabled:e.formControl.disabled}),e.fieldGroup&&(i(e,undefined),e.formControl instanceof f.FormArray&&(e.fieldGroup.length=0))))}e.fieldGroup&&e.fieldGroup.filter(function(e){return!e.hideExpression}).forEach(function(e){return o.toggleFormControl(e,t,r)}),e.options.fieldChanges&&e.options.fieldChanges.next({field:e,type:"hidden",value:t})},e.prototype.setExprValue=function(e,t,r){try{for(var o=e,n=-1===t.indexOf("[")?t.split("."):t.replace(/\'|\"/g,"").split(/[[\]]{1,2}/).filter(function(e){return e}),i=n.length-1,s=0;s<i;s++)o=o[n[s]];o[n[i]]=r}catch(p){throw p.message='[Formly Error] [Expression "'+t+'"] '+p.message,p}if("templateOptions.disabled"===t&&e.key&&this.setDisabledState(e,r),0===t.indexOf("model.")){var a=t.replace(/^model\./,""),l=e.key&&t===a?e.formControl:e.parent.formControl.get(a);!l||b(l.value)&&b(r)||l.value===r||l.patchValue(r)}this.emitExpressionChanges(e,t,r)},e.prototype.emitExpressionChanges=function(e,t,r){e.options.fieldChanges&&e.options.fieldChanges.next({field:e,type:"expressionChanges",property:t,value:r})},e}(),Z=function(){function e(e){this.formlyConfig=e}return e.prototype.onPopulate=function(e){this.initFieldValidation(e,"validators"),this.initFieldValidation(e,"asyncValidators")},e.prototype.initFieldValidation=function(t,e){var r=this,o=[];if("validators"!==e||t.hasOwnProperty("fieldGroup")&&!t.key||o.push(this.getPredefinedFieldValidation(t)),t[e])for(var n in t[e])"validation"!==n||Array.isArray(t[e].validation)||(t[e].validation=[t[e].validation],console.warn("NgxFormly("+t.key+"): passing a non array value to the 'validation' is deprecated, pass an array instead")),"validation"===n?o.push.apply(o,y(t[e].validation.map(function(e){return r.wrapNgValidatorFn(t,e)}))):o.push(this.wrapNgValidatorFn(t,t[e][n],n));E(t,"_"+e,o)},e.prototype.getPredefinedFieldValidation=function(n){var i=[];return a.forEach(function(o){return x(n.templateOptions,o,function(e){var t=e.currentValue,r=e.firstChange;i=i.filter(function(e){return e!==o}),null!=t&&!1!==t&&i.push(o),!r&&n.formControl&&G(n.formControl)})}),function(r){return 0===i.length?null:f.Validators.compose(i.map(function(t){return function(){var e=n.templateOptions[t];switch(t){case"required":return f.Validators.required(r);case"pattern":return f.Validators.pattern(e)(r);case"minLength":return f.Validators.minLength(e)(r);case"maxLength":return f.Validators.maxLength(e)(r);case"min":return f.Validators.min(e)(r);case"max":return f.Validators.max(e)(r)}}}))(r)}},e.prototype.wrapNgValidatorFn=function(o,e,n){var i=this,s=null;if("string"==typeof e&&(s=_(this.formlyConfig.getValidator(e))),"object"==typeof e&&e.name&&(s=_(this.formlyConfig.getValidator(e.name)),e.options&&(s.options=e.options)),"object"==typeof e&&e.expression){var t=e.expression,r=d(e,["expression"]);s={name:n,validation:t,options:0<Object.keys(r).length?r:null}}return"function"==typeof e&&(s={name:n,validation:e}),function(e){var t=s.validation(e,o,s.options);return function r(e){return!!e&&"function"==typeof e.then}(t)?t.then(function(e){return i.handleAsyncResult(o,n?!!e:e,s)}):u.isObservable(t)?t.pipe(p.map(function(e){return i.handleAsyncResult(o,n?!!e:e,s)})):i.handleResult(o,n?!!t:t,s)}},e.prototype.handleAsyncResult=function(e,t,r){return e.options&&e.options._markForCheck&&e.options._markForCheck(e),this.handleResult(e,t,r)},e.prototype.handleResult=function(s,a,e){var t,r=e.name,l=e.options;"boolean"==typeof a&&(a=a?null:((t={})[r]=l||!0,t));var p=s.formControl;return p._childrenErrors&&p._childrenErrors[r]&&p._childrenErrors[r](),F(a)&&Object.keys(a).forEach(function(o){var e,t=a[o].errorPath?a[o].errorPath:(l||{}).errorPath,n=t?s.formControl.get(t):null;if(n){var r=a[o],i=(r.errorPath,d(r,["errorPath"]));n.setErrors(c({},n.errors||{},((e={})[o]=i,e))),!p._childrenErrors&&E(p,"_childrenErrors",{}),p._childrenErrors[o]=function(){var e=n.errors||{},t=o,r=(e[t],d(e,["symbol"==typeof t?t:t+""]));n.setErrors(0===Object.keys(r).length?null:r)}}}),a},e}(),z=function(){function e(e){this.config=e}return e.prototype.onPopulate=function(e){e.parent&&(e.fieldGroup&&!e.key?E(e,"formControl",e.parent.formControl):this.addFormControl(e))},e.prototype.postPopulate=function(e){if(!e.parent){var t=this.setValidators(e);if(0!==t.length)if(1===t.length)for(var r=t[0].formControl;r;)r._updateTreeValidity({onlySelf:!0}),r=r.parent;else e.formControl._updateTreeValidity()}},e.prototype.addFormControl=function(e){var t=R(e);if(!t){var r={updateOn:e.modelOptions.updateOn},o=e.key?v(e):e.defaultValue,n=this.config?this.config.resolveFieldTypeRef(e):null;if(n&&n.componentType&&n.componentType.createControl){var i=n.componentType;console.warn("NgxFormly: '"+i.name+"::createControl' is deprecated since v5.0, use 'prePopulate' hook instead."),t=i.createControl(o,e)}else t=e.fieldGroup?new f.FormGroup({},r):new f.FormControl(o,r)}A(e,t)},e.prototype.setValidators=function(t){var r=this,o=!1;if(t.key||!t.parent||!t.key&&!t.fieldGroup){var n=t.formControl,e=!!t.templateOptions&&t.templateOptions.disabled;t.key&&n&&(e&&n.enabled&&(n.disable({emitEvent:!1,onlySelf:!0}),n.parent?o=!0:G(n)),!e&&n.disabled&&(n.enable({emitEvent:!1,onlySelf:!0}),n.parent?o=!0:G(n))),!n||null!==n.validator&&null!==n.asyncValidator||(n.setValidators(function(){var e=f.Validators.compose(r.mergeValidators(t,"_validators"));return e?e(n):null}),n.setAsyncValidators(function(){var e=f.Validators.composeAsync(r.mergeValidators(t,"_asyncValidators"));return e?e(n):u.of(null)}),n.parent?o=!0:G(n))}var i=o?[t]:[];return(t.fieldGroup||[]).forEach(function(e){var t=r.setValidators(e);o||i.push.apply(i,y(t))}),i},e.prototype.mergeValidators=function(e,t){var r=this,o=[],n=e.formControl;return n&&n._fields&&1<n._fields.length?n._fields.filter(function(e){return!e._hide}).forEach(function(e){return o.push.apply(o,y(e[t]))}):e[t]&&o.push.apply(o,y(e[t])),e.fieldGroup&&e.fieldGroup.filter(function(e){return!e.key&&e.fieldGroup}).forEach(function(e){return o.push.apply(o,y(r.mergeValidators(e,t)))}),o},e}(),J=function(){function e(e){this.formlyConfig=e,this.formId=0}return e.prototype.prePopulate=function(t){if(this.getFieldComponentInstance(t).prePopulate(),!t.parent){var e=t.options&&t.options.fieldTransform||this.formlyConfig.extras.fieldTransform;(Array.isArray(e)?e:[e]).forEach(function(e){if(e&&(console.warn("NgxFormly: fieldTransform is deprecated since v5.0, use custom extension instead."),!e(t.fieldGroup,t.model,t.formControl,t.options)))throw new Error("fieldTransform must return an array of fields")})}},e.prototype.onPopulate=function(r){var o=this;this.initFieldOptions(r),this.getFieldComponentInstance(r).onPopulate(),r.fieldGroup&&r.fieldGroup.forEach(function(e,t){Object.defineProperty(e,"parent",{get:function(){return r},configurable:!0}),Object.defineProperty(e,"index",{get:function(){return t},configurable:!0}),o.formId++})},e.prototype.postPopulate=function(e){this.getFieldComponentInstance(e).postPopulate()},e.prototype.initFieldOptions=function(e){var t=e.parent;if(t){if(Object.defineProperty(e,"form",{get:function(){return t.formControl},configurable:!0}),Object.defineProperty(e,"options",{get:function(){return t.options},configurable:!0}),Object.defineProperty(e,"model",{get:function(){return e.key&&e.fieldGroup?v(e):t.model},configurable:!0}),l(e,{id:function n(e,t,r){if(t.id)return t.id;var o=t.type;return!o&&t.template&&(o="template"),[e,o,t.key,r].join("_")}("formly_"+this.formId,e,e.index),hooks:{},modelOptions:{},templateOptions:e.type&&e.key?{label:"",placeholder:"",focus:!1,disabled:!1}:{}}),this.formlyConfig.extras.resetFieldOnHide&&!1!==e.resetOnHide&&(e.resetOnHide=!0),e.lifecycle&&console.warn("NgxFormly: 'lifecycle' is deprecated since v5.0, use 'hooks' instead."),"formly-template"!==e.type&&(e.template||e.expressionProperties&&e.expressionProperties.template)&&(e.type&&console.warn("NgxFormly: passing 'type' property is not allowed when 'template' is set."),e.type="formly-template"),!e.type&&e.fieldGroup&&(e.type="formly-group"),e.type&&this.formlyConfig.getMergedField(e),e.parent){var r=!C(e.key)&&!C(e.defaultValue)&&C(v(e))&&(!e.resetOnHide||!(e.hide||e.hideExpression));if(r&&e.resetOnHide){for(var o=e.parent;o&&!o.hideExpression&&!o.hide;)o=o.parent;r=!o||!(o.hideExpression||o.hide)}r&&i(e,e.defaultValue)}this.initFieldWrappers(e)}},e.prototype.initFieldWrappers=function(t){t.wrappers=t.wrappers||[];var e=c({preWrapper:[],postWrapper:[]},t.templateOptions.templateManipulators||{});t.wrappers=y(this.formlyConfig.templateManipulators.preWrapper.map(function(e){return e(t)}),e.preWrapper.map(function(e){return e(t)}),t.wrappers,this.formlyConfig.templateManipulators.postWrapper.map(function(e){return e(t)}),e.postWrapper.map(function(e){return e(t)})).filter(function(e,t,r){return e&&t===r.indexOf(e)})},e.prototype.getFieldComponentInstance=function(e){var t=this.formlyConfig.resolveFieldTypeRef(e),r=t?t.instance:{};return{prePopulate:function(){return r.prePopulate&&r.prePopulate(e)},onPopulate:function(){return r.onPopulate&&r.onPopulate(e)},postPopulate:function(){return r.postPopulate&&r.postPopulate(e)}}},e}();function U(e){return{types:[{name:"formly-group",component:$},{name:"formly-template",component:B}],extensions:[{name:"core",extension:new J(e)},{name:"field-validation",extension:new Z(e)},{name:"field-form",extension:new z(e)},{name:"field-expression",extension:new Y}]}}var X=function(){function t(t,e){void 0===e&&(e=[]),e&&e.forEach(function(e){return t.addConfig(e)})}return t.forRoot=function(e){return void 0===e&&(e={}),{ngModule:t,providers:[{provide:w,multi:!0,useFactory:U,deps:[P]},{provide:w,useValue:e,multi:!0},{provide:s.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:e,multi:!0},P,V]}},t.forChild=function(e){return void 0===e&&(e={}),{ngModule:t,providers:[{provide:w,multi:!0,useFactory:U,deps:[P]},{provide:w,useValue:e,multi:!0},{provide:s.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:e,multi:!0},V]}},t.decorators=[{type:s.NgModule,args:[{declarations:[I,T,D,$,q,B,H],entryComponents:[$,B],exports:[I,T,D,$,q],imports:[r.CommonModule]}]}],t.ctorParameters=function(){return[{type:P},{type:Array,decorators:[{type:s.Optional},{type:s.Inject,args:[w]}]}]},t}();e.FormlyForm=I,e.FormlyField=T,e.FormlyAttributes=D,e.FORMLY_CONFIG=w,e.FormlyConfig=P,e.FormlyFormBuilder=V,e.FieldType=S,e.Field=N,e.FieldArrayType=H,e.FieldWrapper=W,e.FormlyModule=X,e.ɵdefineHiddenProp=E,e.ɵreverseDeepMerge=l,e.ɵgetFieldInitialValue=function K(e){for(var t,r,o=e.options._initialModel,n=g(e);e.parent;)n=y(g(e=e.parent),n);try{for(var i=h(n),s=i.next();!s.done;s=i.next()){var a=s.value;if(!o)return undefined;o=o[a]}}catch(l){t={error:l}}finally{try{s&&!s.done&&(r=i["return"])&&r.call(i)}finally{if(t)throw t.error}}return o},e.ɵclone=_,e.ɵwrapProperty=x,e.ɵa=U,e.ɵe=J,e.ɵh=Y,e.ɵg=z,e.ɵf=Z,e.ɵd=B,e.ɵb=$,e.ɵc=q,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/platform-browser"),require("rxjs/operators"),require("@angular/forms"),require("rxjs")):"function"==typeof define&&define.amd?define("@ngx-formly/core",["exports","@angular/common","@angular/core","@angular/platform-browser","rxjs/operators","@angular/forms","rxjs"],t):t((e["ngx-formly"]=e["ngx-formly"]||{},e["ngx-formly"].core={}),e.ng.common,e.ng.core,e.ng.platformBrowser,e.rxjs.operators,e.ng.forms,e.rxjs)}(this,function(e,r,s,t,p,f,u){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function n(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var c=function(){return(c=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function d(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}function h(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function m(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(o=i.next()).done;)s.push(o.value)}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=i["return"])&&r.call(i)}finally{if(n)throw n.error}}return s}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}function g(e){if(!e.key)return[];if(!e._keyPath||e._keyPath.key!==e.key){var t=[];if("string"==typeof e.key){var r=-1===e.key.indexOf("[")?e.key:e.key.replace(/\[(\w+)\]/g,".$1");t=-1!==r.indexOf(".")?r.split("."):[r]}else t=Array.isArray(e.key)?e.key.slice(0):[""+e.key];e._keyPath={key:e.key,path:t}}return e._keyPath.path.slice(0)}var a=["required","pattern","minLength","maxLength","min","max"];function i(e,t){var r=g(e);if(0!==r.length){for(var o=e;o.parent;)r=y(g(o=o.parent),r);if(t===undefined&&e.resetOnHide){var n=r.pop();delete r.reduce(function(e,t){return e[t]||{}},o.model)[n]}else!function i(e,t,r){for(var o=0;o<t.length-1;o++){var n=t[o];e[n]&&F(e[n])||(e[n]=/^\d+$/.test(t[o+1])?[]:{}),e=e[n]}e[t[t.length-1]]=_(r)}(o.model,r,t)}}function v(e){var t,r,o=e.parent.model;try{for(var n=h(g(e)),i=n.next();!i.done;i=n.next()){var s=i.value;if(!o)return o;o=o[s]}}catch(a){t={error:a}}finally{try{i&&!i.done&&(r=n["return"])&&r.call(n)}finally{if(t)throw t.error}}return o}function l(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return e.forEach(function(e){for(var t in e)b(n[t])||""===n[t]?n[t]=_(e[t]):(r=n[t],o=e[t],F(r)&&F(o)&&Object.getPrototypeOf(r)===Object.getPrototypeOf(o)&&!Array.isArray(r)&&!Array.isArray(o)&&l(n[t],e[t]));var r,o}),n}function b(e){return e===undefined||null===e}function C(e){return e===undefined}function O(e){return"function"==typeof e}function F(e){return null!=e&&"object"==typeof e}function _(o){if(!F(o)||u.isObservable(o)||o.changingThisBreaksApplicationSecurity||-1!==["RegExp","FileList","File","Blob"].indexOf(o.constructor.name))return o;if(o instanceof Set)return new Set(o);if(o instanceof Map)return new Map(o);if(o._isAMomentObject&&O(o.clone))return o.clone();if(o instanceof f.AbstractControl)return null;if(o instanceof Date)return new Date(o.getTime());if(Array.isArray(o))return o.slice(0).map(function(e){return _(e)});var e=Object.getPrototypeOf(o),t=Object.create(e);return t=Object.setPrototypeOf(t,e),Object.keys(o).reduce(function(e,t){var r=Object.getOwnPropertyDescriptor(o,t);return r.get?Object.defineProperty(e,t,r):e[t]=_(o[t]),e},t)}function E(e,t,r){Object.defineProperty(e,t,{enumerable:!1,writable:!0,configurable:!0}),e[t]=r}function x(e,o,t){e._observers||E(e,"_observers",{}),e._observers[o]||(e._observers[o]=[]);var n=e._observers[o];return-1===n.indexOf(t)&&(n.push(t),t({currentValue:e[o],firstChange:!0}),1===n.length&&(E(e,"___$"+o,e[o]),Object.defineProperty(e,o,{configurable:!0,get:function(){return e["___$"+o]},set:function(t){if(t!==e["___$"+o]){var r=e["___$"+o];e["___$"+o]=t,n.forEach(function(e){return e({previousValue:r,currentValue:t,firstChange:!1})})}}}))),function(){return n.splice(n.indexOf(t),1)}}function k(e,t){var r=e._updateTreeValidity.bind(e),o={called:!1,emitEvent:!1};e._updateTreeValidity=function(e){var t=(void 0===e?{emitEvent:!0}:e).emitEvent;return o={called:!0,emitEvent:t||o.emitEvent}},t(),o.called&&r({emitEvent:o.emitEvent}),e._updateTreeValidity=r}var w=new s.InjectionToken("FORMLY_CONFIG"),P=function(){function e(){this.types={},this.validators={},this.wrappers={},this.messages={},this.templateManipulators={preWrapper:[],postWrapper:[]},this.extras={checkExpressionOn:"changeDetectionCheck",lazyRender:!1,showError:function(e){return e.formControl&&e.formControl.invalid&&(e.formControl.touched||e.options.parentForm&&e.options.parentForm.submitted||!(!e.field.validation||!e.field.validation.show))}},this.extensions={}}return e.prototype.addConfig=function(e){var t=this;e.types&&e.types.forEach(function(e){return t.setType(e)}),e.validators&&e.validators.forEach(function(e){return t.setValidator(e)}),e.wrappers&&e.wrappers.forEach(function(e){return t.setWrapper(e)}),e.manipulators&&(console.warn("NgxFormly: passing 'manipulators' config is deprecated, use custom extension instead."),e.manipulators.forEach(function(e){return t.setManipulator(e)})),e.validationMessages&&e.validationMessages.forEach(function(e){return t.addValidatorMessage(e.name,e.message)}),e.extensions&&e.extensions.forEach(function(e){return t.extensions[e.name]=e.extension}),e.extras&&(this.extras=c({},this.extras,e.extras))},e.prototype.setType=function(t){var r=this;Array.isArray(t)?t.forEach(function(e){return r.setType(e)}):(this.types[t.name]||(this.types[t.name]={name:t.name}),["component","extends","defaultOptions","wrappers"].forEach(function(e){t.hasOwnProperty(e)&&(r.types[t.name][e]=t[e])}))},e.prototype.getType=function(e){if(!this.types[e])throw new Error('[Formly Error] The type "'+e+'" could not be found. Please make sure that is registered through the FormlyModule declaration.');return this.mergeExtendedType(e),this.types[e]},e.prototype.getMergedField=function(r){var o=this;void 0===r&&(r={});var e=this.getType(r.type);e.defaultOptions&&l(r,e.defaultOptions);var t=e["extends"]&&this.getType(e["extends"]).defaultOptions;t&&l(r,t),r&&r.optionsTypes&&r.optionsTypes.forEach(function(e){var t=o.getType(e).defaultOptions;t&&l(r,t)});var n=this.resolveFieldTypeRef(r);n&&n.instance&&n.instance.defaultOptions&&l(r,n.instance.defaultOptions),!r.wrappers&&e.wrappers&&(r.wrappers=y(e.wrappers))},e.prototype.resolveFieldTypeRef=function(e){if(void 0===e&&(e={}),!e.type)return null;var t=this.getType(e.type);if(!t.component||t._componentRef)return t._componentRef;var r=e.parent.options,o=r._resolver,n=r._injector,i=o.resolveComponentFactory(t.component).create(n);return E(t,"_componentRef",i),i.destroy(),t._componentRef},e.prototype.setWrapper=function(t){var r=this;(this.wrappers[t.name]=t).types&&t.types.forEach(function(e){r.setTypeWrapper(e,t.name)})},e.prototype.getWrapper=function(e){if(!this.wrappers[e])throw new Error('[Formly Error] The wrapper "'+e+'" could not be found. Please make sure that is registered through the FormlyModule declaration.');return this.wrappers[e]},e.prototype.setTypeWrapper=function(e,t){this.types[e]||(this.types[e]={}),this.types[e].wrappers||(this.types[e].wrappers=[]),-1===this.types[e].wrappers.indexOf(t)&&this.types[e].wrappers.push(t)},e.prototype.setValidator=function(e){this.validators[e.name]=e},e.prototype.getValidator=function(e){if(!this.validators[e])throw new Error('[Formly Error] The validator "'+e+'" could not be found. Please make sure that is registered through the FormlyModule declaration.');return this.validators[e]},e.prototype.addValidatorMessage=function(e,t){this.messages[e]=t},e.prototype.getValidatorMessage=function(e){return this.messages[e]},e.prototype.setManipulator=function(e){(new e["class"])[e.method](this)},e.prototype.mergeExtendedType=function(e){if(this.types[e]["extends"]){var t=this.getType(this.types[e]["extends"]);this.types[e].component||(this.types[e].component=t.component),this.types[e].wrappers||(this.types[e].wrappers=t.wrappers)}},e.decorators=[{type:s.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=s.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),V=function(){function e(e,t,r){this.formlyConfig=e,this.componentFactoryResolver=t,this.injector=r}return e.prototype.buildForm=function(e,t,r,o){var n=this;if(void 0===t&&(t=[]),!this.formlyConfig.extensions.core)throw new Error("NgxFormly: missing `forRoot()` call. use `forRoot()` when registering the `FormlyModule`.");var i={fieldGroup:t,model:r,formControl:e,options:this._setOptions(o)};k(e,function(){return n._buildForm(i)}),i.options._checkField(i,!0)},e.prototype._buildForm=function(t){var r=this;this.getExtensions().forEach(function(e){return e.prePopulate&&e.prePopulate(t)}),this.getExtensions().forEach(function(e){return e.onPopulate&&e.onPopulate(t)}),t.fieldGroup&&t.fieldGroup.forEach(function(e){return r._buildForm(e)}),this.getExtensions().forEach(function(e){return e.postPopulate&&e.postPopulate(t)})},e.prototype.getExtensions=function(){var t=this;return Object.keys(this.formlyConfig.extensions).map(function(e){return t.formlyConfig.extensions[e]})},e.prototype._setOptions=function(t){var r=this;return(t=t||{}).formState=t.formState||{},t.showError||(t.showError=this.formlyConfig.extras.showError),t.fieldChanges||E(t,"fieldChanges",new u.Subject),t._resolver||E(t,"_resolver",this.componentFactoryResolver),t._injector||E(t,"_injector",this.injector),t._hiddenFieldsForCheck||(t._hiddenFieldsForCheck=[]),t._markForCheck||(t._markForCheck=function(e){e._componentRefs&&e._componentRefs.forEach(function(e){e.injector.get(s.ChangeDetectorRef).markForCheck()}),e.fieldGroup&&e.fieldGroup.forEach(function(e){return t._markForCheck(e)})}),t._buildField||(t._buildField=function(e){return r.buildForm(e.form,e.fieldGroup,e.model,e.options),e}),t},e.decorators=[{type:s.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:P},{type:s.ComponentFactoryResolver},{type:s.Injector}]},e.ngInjectableDef=s.defineInjectable({factory:function(){return new e(s.inject(P),s.inject(s.ComponentFactoryResolver),s.inject(s.INJECTOR))},token:e,providedIn:"root"}),e}();function j(e,t){void 0===t&&(t=!1);var r=e.formControl.parent;if(r){var o=e.formControl,n={emitEvent:t};if(r instanceof f.FormArray){var i=r.controls.findIndex(function(e){return e===o});-1!==i&&M(r,n,function(){return r.removeAt(i)})}else if(r instanceof f.FormGroup){var s=g(e),a=s[s.length-1];r.get([a])===o&&M(r,n,function(){return r.removeControl(a)})}o.setParent(null)}}function R(e){if(e.formControl)return e.formControl;if(!1===e.shareFormControl)return null;var t=e.parent.formControl;return t?t.get(g(e)):null}function A(o,e,r){void 0===r&&(r=!1),(e=e||o.formControl)._fields||E(e,"_fields",[]),-1===e._fields.indexOf(o)&&e._fields.push(o),!o.formControl&&e&&(E(o,"formControl",e),e.setValidators(null),e.setAsyncValidators(null),o.templateOptions.disabled=!!o.templateOptions.disabled,x(o.templateOptions,"disabled",function(e){var t=e.firstChange,r=e.currentValue;t||(r?o.formControl.disable():o.formControl.enable())}),e.registerOnDisabledChange&&e.registerOnDisabledChange(function(e){o.templateOptions.___$disabled=e,o.options&&o.options._markForCheck(o)}));var n=o.parent.formControl;if(n&&o.key){var i=g(o),t=v(o);b(e.value)&&b(t)||e.value===t||!(e instanceof f.FormControl)||e.patchValue(t);for(var s=function(e){var t=i[e];n.get([t])||M(n,{emitEvent:r},function(){return n.setControl(t,new f.FormGroup({}))}),n=n.get([t])},a=0;a<i.length-1;a++)s(a);var l=i[i.length-1];o._hide||n.get([l])===e||M(n,{emitEvent:r},function(){return n.setControl(l,e)})}}function G(e){var t=e.status;e.updateValueAndValidity({emitEvent:!1}),t!==e.status&&e.statusChanges.emit(e.status)}function M(r,e,t){r instanceof f.FormGroup&&!r.__patchForEachChild&&(E(r,"__patchForEachChild",!0),r._forEachChild=function(t){Object.keys(r.controls).forEach(function(e){return r.controls[e]&&t(r.controls[e],e)})});var o=r.updateValueAndValidity.bind(r);!1===e.emitEvent&&(r.updateValueAndValidity=function(e){o(c({},e||{},{emitEvent:!1}))}),t(),!1===e.emitEvent&&(r.updateValueAndValidity=o)}var I=function(){function e(e,t,r,o,n){var i=this;this.formlyBuilder=e,this.formlyConfig=t,this.ngZone=r,this.parentFormGroup=n,this.modelChange=new s.EventEmitter,this.immutable=!1,this._modelChangeValue={},this.modelChangeSubs=[],this.modelChange$=new u.Subject,this.modelChangeSub=this.modelChange$.pipe(p.switchMap(function(){return i.ngZone.onStable.asObservable().pipe(p.take(1))})).subscribe(function(){return i.ngZone.runGuarded(function(){i.checkExpressionChange(),i.modelChange.emit(i._modelChangeValue=_(i.model))})}),null!==o&&console.warn("NgxFormly: passing 'immutable' attribute to 'formly-form' component is deprecated since v5.5, enable immutable mode through NgModule declaration instead."),this.immutable=null!==o||!!t.extras.immutable}return Object.defineProperty(e.prototype,"model",{get:function(){return this._model||(this._model={}),this._model},set:function(e){this._model=this.immutable?_(e):e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fields",{get:function(){return this._fields||[]},set:function(e){this._fields=this.immutable?_(e):e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(e){this._options=this.immutable?_(e):e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"content",{set:function(e){if(e){for(var t=!1,r=e.nativeElement.nextSibling;r&&!t;)(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE&&r.textContent&&""!==r.textContent.trim())&&(t=!0),r=r.nextSibling;t&&console.warn("NgxFormly: content projection for 'formly-form' component is deprecated since v5.5, you should avoid passing content inside the 'formly-form' tag.")}},enumerable:!0,configurable:!0}),e.prototype.ngDoCheck=function(){"changeDetectionCheck"===this.formlyConfig.extras.checkExpressionOn&&this.checkExpressionChange()},e.prototype.ngOnChanges=function(e){e.model&&this.field&&(this.field.model=this.model),e.fields&&this.form&&function r(t){t._fields&&delete t._fields,(t instanceof f.FormGroup||t instanceof f.FormArray)&&Object.keys(t.controls).forEach(function(e){return r(t.controls[e])})}(this.form),(e.fields||e.form||e.model&&this._modelChangeValue!==e.model.currentValue)&&(this.form=this.form||new f.FormGroup({}),this.setOptions(),this.options.updateInitialValue(),this.clearModelSubscriptions(),this.formlyBuilder.buildForm(this.form,this.fields,this.model,this.options),this.trackModelChanges(this.fields))},e.prototype.ngOnDestroy=function(){this.modelChangeSub.unsubscribe(),this.clearModelSubscriptions()},e.prototype.changeModel=function(e){e.key;var t=e.value;i(e.field,t),this.modelChange$.next()},e.prototype.setOptions=function(){var t=this;this.options||(this.options={}),this.options.resetModel||(this.options.resetModel=function(e){e=_(b(e)?t.options._initialModel:e),t.model&&(Object.keys(t.model).forEach(function(e){return delete t.model[e]}),Object.assign(t.model,e||{})),t.options._buildForm(),t.options.parentForm&&t.options.parentForm.control===t.form?t.options.parentForm.resetForm(t.model):t.form.reset(t.model)}),!this.options.parentForm&&this.parentFormGroup&&(E(this.options,"parentForm",this.parentFormGroup),x(this.options.parentForm,"submitted",function(e){e.firstChange||(t.checkExpressionChange(),t.options._markForCheck({fieldGroup:t.fields,model:t.model,formControl:t.form,options:t.options}))})),this.options.updateInitialValue||(this.options.updateInitialValue=function(){return t.options._initialModel=_(t.model)}),this.options._buildForm||(this.options._buildForm=function(e){void 0===e&&(e=!1),t.clearModelSubscriptions(),t.formlyBuilder.buildForm(t.form,t.fields,t.model,t.options),t.trackModelChanges(t.fields),e&&t.modelChange.emit(t._modelChangeValue=_(t.model))})},e.prototype.checkExpressionChange=function(){this.options&&this.options._checkField&&this.options._checkField({fieldGroup:this.fields,model:this.model,formControl:this.form,options:this.options})},e.prototype.trackModelChanges=function(e,a){var l=this;void 0===a&&(a=[]),e.forEach(function(e){if(e.key&&!e.fieldGroup&&e.formControl){var r=e.formControl,t=r.valueChanges.pipe(p.distinctUntilChanged(function(e,t){return e===t&&!Array.isArray(e)&&!F(e)})),o=e.modelOptions,n=o.updateOn,i=o.debounce;(!n||"change"===n)&&i&&0<i["default"]&&(t=r.valueChanges.pipe(p.debounceTime(i["default"]))),l.modelChangeSubs.push(t.subscribe(function(t){r instanceof f.FormControl&&r._fields&&1<r._fields.length&&r.patchValue(t,{emitEvent:!1,onlySelf:!0}),e.parsers&&0<e.parsers.length&&e.parsers.forEach(function(e){return t=e(t)}),l.changeModel({key:y(a,g(e)).join("."),value:t,field:e})}));var s=r.valueChanges.observers;s&&1<s.length&&s.unshift(s.pop())}e.fieldGroup&&0<e.fieldGroup.length&&l.trackModelChanges(e.fieldGroup,e.key?y(a,g(e)):a)})},e.prototype.clearModelSubscriptions=function(){this.modelChangeSubs.forEach(function(e){return e.unsubscribe()}),this.modelChangeSubs=[]},Object.defineProperty(e.prototype,"field",{get:function(){return this.fields&&this.fields[0]&&this.fields[0].parent},enumerable:!0,configurable:!0}),e.decorators=[{type:s.Component,args:[{selector:"formly-form",template:'\n <formly-field *ngFor="let field of fields"\n hide-deprecation\n [form]="field.form"\n [options]="field.options"\n [model]="field.model"\n [field]="field">\n </formly-field>\n <ng-container #content>\n <ng-content></ng-content>\n </ng-container>\n ',providers:[V]}]}],e.ctorParameters=function(){return[{type:V},{type:P},{type:s.NgZone},{type:undefined,decorators:[{type:s.Attribute,args:["immutable"]}]},{type:f.FormGroupDirective,decorators:[{type:s.Optional}]}]},e.propDecorators={form:[{type:s.Input}],model:[{type:s.Input}],fields:[{type:s.Input}],options:[{type:s.Input}],modelChange:[{type:s.Output}],content:[{type:s.ViewChild,args:["content"]}]},e}(),T=function(){function e(e,t,r,o,n){this.formlyConfig=e,this.renderer=t,this.resolver=r,this.elementRef=o,this.warnDeprecation=!1,this.modelChange=new s.EventEmitter,this.hostObservers=[],this.componentRefs=[],this.hooksObservers=[],this.detectFieldBuild=!1,this.warnDeprecation=null===n}return Object.defineProperty(e.prototype,"model",{set:function(e){this.warnDeprecation&&console.warn("NgxFormly: passing 'model' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"form",{set:function(e){this.warnDeprecation&&console.warn("NgxFormly: passing 'form' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{set:function(e){this.warnDeprecation&&console.warn("NgxFormly: passing 'options' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),e.prototype.ngAfterContentInit=function(){this.triggerHook("afterContentInit")},e.prototype.ngAfterContentChecked=function(){this.triggerHook("afterContentChecked")},e.prototype.ngAfterViewInit=function(){this.triggerHook("afterViewInit")},e.prototype.ngAfterViewChecked=function(){this.triggerHook("afterViewChecked")},e.prototype.ngDoCheck=function(){this.triggerHook("doCheck"),this.detectFieldBuild&&this.field&&this.field.options&&this.render()},e.prototype.ngOnInit=function(){this.triggerHook("onInit")},e.prototype.ngOnChanges=function(e){this.triggerHook("onChanges",e)},e.prototype.ngOnDestroy=function(){this.resetRefs(this.field),this.hostObservers.forEach(function(e){return e()}),this.hooksObservers.forEach(function(e){return e()}),this.triggerHook("onDestroy")},e.prototype.renderField=function(e,i,t){var s=this;if(void 0===t&&(t=[]),this.containerRef===e&&(this.resetRefs(this.field),this.containerRef.clear(),t=this.field?this.field.wrappers:[]),t&&0<t.length){var r=m(t),o=r[0],a=r.slice(1),n=this.formlyConfig.getWrapper(o).component,l=e.createComponent(this.resolver.resolveComponentFactory(n));this.attachComponentRef(l,i),x(l.instance,"fieldComponent",function(e){var t=e.firstChange,r=e.previousValue,o=e.currentValue;if(o){if(r&&r._lContainer===o._lContainer)return;var n=r?r.detach():null;n&&!n.destroyed?o.insert(n):s.renderField(o,i,a),!t&&l.changeDetectorRef.detectChanges()}})}else if(i&&i.type){n=this.formlyConfig.getType(i.type).component;var p=e.createComponent(this.resolver.resolveComponentFactory(n));this.attachComponentRef(p,i)}},e.prototype.triggerHook=function(e,t){if(this.field&&this.field.hooks&&this.field.hooks[e]&&(!t||t.field)){var r=this.field.hooks[e](this.field);if(u.isObservable(r)&&-1!==["onInit","afterContentInit","afterViewInit"].indexOf(e)){var o=r.subscribe();this.hooksObservers.push(function(){return o.unsubscribe()})}}this.field&&this.field.lifecycle&&this.field.lifecycle[e]&&this.field.lifecycle[e](this.field.form,this.field,this.field.model,this.field.options),"onChanges"===e&&t.field&&(this.resetRefs(t.field.previousValue),this.render())},e.prototype.attachComponentRef=function(e,t){this.componentRefs.push(e),t._componentRefs.push(e),Object.assign(e.instance,{field:t})},e.prototype.render=function(){var o=this;this.field&&(this.field.options?(this.detectFieldBuild=!1,this.hostObservers.forEach(function(e){return e()}),this.hostObservers=[x(this.field,"hide",function(e){var t=e.firstChange,r=e.currentValue;o.formlyConfig.extras.lazyRender?r?(o.containerRef.clear(),o.field.className&&o.renderer.removeAttribute(o.elementRef.nativeElement,"class")):(o.renderField(o.containerRef,o.field),o.field.className&&o.renderer.setAttribute(o.elementRef.nativeElement,"class",o.field.className)):(t&&o.renderField(o.containerRef,o.field),(!t||t&&r)&&o.renderer.setStyle(o.elementRef.nativeElement,"display",r?"none":""))}),x(this.field,"className",function(e){var t=e.firstChange,r=e.currentValue;!(!t||t&&r)||o.formlyConfig.extras.lazyRender&&!0===o.field.hide||o.renderer.setAttribute(o.elementRef.nativeElement,"class",r)})]):this.detectFieldBuild=!0)},e.prototype.resetRefs=function(e){var t=this;e&&(e._componentRefs?e._componentRefs=e._componentRefs.filter(function(e){return-1===t.componentRefs.indexOf(e)}):E(this.field,"_componentRefs",[])),this.componentRefs=[]},e.decorators=[{type:s.Component,args:[{selector:"formly-field",template:"<ng-template #container></ng-template>"}]}],e.ctorParameters=function(){return[{type:P},{type:s.Renderer2},{type:s.ComponentFactoryResolver},{type:s.ElementRef},{type:undefined,decorators:[{type:s.Attribute,args:["hide-deprecation"]}]}]},e.propDecorators={field:[{type:s.Input}],model:[{type:s.Input}],form:[{type:s.Input}],options:[{type:s.Input}],modelChange:[{type:s.Output}],containerRef:[{type:s.ViewChild,args:["container",{read:s.ViewContainerRef,"static":!0}]}]},e}(),D=function(){function e(e,t,r){this.renderer=e,this.elementRef=t,this.uiAttributesCache={},this.uiAttributes=y(a,["tabindex","placeholder","readonly","disabled","step"]),this.uiEvents={listeners:[],events:["click","keyup","keydown","keypress"]},this.document=r}return Object.defineProperty(e.prototype,"to",{get:function(){return this.field.templateOptions||{}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fieldAttrElements",{get:function(){return this.field&&this.field._elementRefs||[]},enumerable:!0,configurable:!0}),e.prototype.ngOnChanges=function(e){var o=this;e.field&&(this.field.name&&this.setAttribute("name",this.field.name),this.uiEvents.listeners.forEach(function(e){return e()}),this.uiEvents.events.forEach(function(t){o.to&&o.to[t]&&o.uiEvents.listeners.push(o.renderer.listen(o.elementRef.nativeElement,t,function(e){return o.to[t](o.field,e)}))}),this.to&&this.to.attributes&&x(this.to,"attributes",function(e){var t=e.currentValue,r=e.previousValue;r&&Object.keys(r).forEach(function(e){return o.removeAttribute(e)}),t&&Object.keys(t).forEach(function(e){null!=t[e]&&o.setAttribute(e,t[e])})}),this.detachElementRef(e.field.previousValue),this.attachElementRef(e.field.currentValue),1===this.fieldAttrElements.length&&(!this.id&&this.field.id&&this.setAttribute("id",this.field.id),x(this.field,"focus",function(e){var t=e.currentValue;o.toggleFocus(t)}))),e.id&&this.setAttribute("id",this.id)},e.prototype.ngDoCheck=function(){var r=this;this.uiAttributes.forEach(function(e){var t=r.to[e];r.uiAttributesCache[e]===t||r.to.attributes&&r.to.attributes.hasOwnProperty(e.toLowerCase())||((r.uiAttributesCache[e]=t)||0===t?r.setAttribute(e,!0===t?e:""+t):r.removeAttribute(e))})},e.prototype.ngOnDestroy=function(){this.uiEvents.listeners.forEach(function(e){return e()}),this.detachElementRef(this.field)},e.prototype.toggleFocus=function(e){var r=this,t=this.fieldAttrElements?this.fieldAttrElements[0]:null;if(t&&t.nativeElement.focus){var o=!!this.document.activeElement&&this.fieldAttrElements.some(function(e){var t=e.nativeElement;return r.document.activeElement===t||t.contains(r.document.activeElement)});e&&!o?t.nativeElement.focus():!e&&o&&t.nativeElement.blur()}},e.prototype.onFocus=function(e){this.field.___$focus=!0,this.to.focus&&this.to.focus(this.field,e)},e.prototype.onBlur=function(e){this.field.___$focus=!1,this.to.blur&&this.to.blur(this.field,e)},e.prototype.onChange=function(e){this.to.change&&this.to.change(this.field,e),this.field.formControl&&this.field.formControl.markAsDirty()},e.prototype.attachElementRef=function(e){e&&(e._elementRefs&&-1===e._elementRefs.indexOf(this.elementRef)?e._elementRefs.push(this.elementRef):E(e,"_elementRefs",[this.elementRef]))},e.prototype.detachElementRef=function(e){var t=e&&e._elementRefs?this.fieldAttrElements.indexOf(this.elementRef):-1;-1!==t&&this.field._elementRefs.splice(t,1)},e.prototype.setAttribute=function(e,t){this.renderer.setAttribute(this.elementRef.nativeElement,e,t)},e.prototype.removeAttribute=function(e){this.renderer.removeAttribute(this.elementRef.nativeElement,e)},e.decorators=[{type:s.Directive,args:[{selector:"[formlyAttributes]",host:{"(focus)":"onFocus($event)","(blur)":"onBlur($event)","(change)":"onChange($event)"}}]}],e.ctorParameters=function(){return[{type:s.Renderer2},{type:s.ElementRef},{type:undefined,decorators:[{type:s.Inject,args:[r.DOCUMENT]}]}]},e.propDecorators={field:[{type:s.Input,args:["formlyAttributes"]}],id:[{type:s.Input}]},e}(),N=function(){function e(){}return Object.defineProperty(e.prototype,"model",{get:function(){return this.field.model},set:function(e){console.warn("NgxFormly: passing 'model' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"form",{get:function(){return this.field.parent.formControl},set:function(e){console.warn("NgxFormly: passing 'form' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.field.options},set:function(e){console.warn("NgxFormly: passing 'options' input to '"+this.constructor.name+"' component is not required anymore, you may remove it!")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this.field.key},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formControl",{get:function(){return this.field.formControl},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this.field.templateOptions||{}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showError",{get:function(){return this.options.showError(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.field.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formState",{get:function(){return this.options.formState||{}},enumerable:!0,configurable:!0}),e.propDecorators={field:[{type:s.Input}],model:[{type:s.Input}],form:[{type:s.Input}],options:[{type:s.Input}]},e}(),S=function(t){function e(){var e=t.call(this)||this;return console.warn("NgxFormly: 'Field' has been renamed to 'FieldType', extend 'FieldType' instead."),e}return n(e,t),e}(N),H=function(r){function e(e){var t=r.call(this)||this;return t.defaultOptions={defaultValue:[]},e instanceof V&&console.warn("NgxFormly: passing 'FormlyFormBuilder' to '"+t.constructor.name+"' type is not required anymore, you may remove it!"),t}return n(e,r),Object.defineProperty(e.prototype,"formControl",{get:function(){return this.field.formControl},enumerable:!0,configurable:!0}),e.prototype.onPopulate=function(e){if(!e.formControl&&e.key){var t=R(e);A(e,t||new f.FormArray([],{updateOn:e.modelOptions.updateOn}))}e.fieldGroup=e.fieldGroup||[];var r=e.model?e.model.length:0;if(e.fieldGroup.length>r)for(var o=e.fieldGroup.length-1;r<=o;--o)j(e.fieldGroup[o]),e.fieldGroup.splice(o,1);for(o=e.fieldGroup.length;o<r;o++){var n=c({},_(e.fieldArray),{key:""+o});e.fieldGroup.push(n)}},e.prototype.add=function(e,t,r){var o=(void 0===r?{markAsDirty:!0}:r).markAsDirty;e=b(e)?this.field.fieldGroup.length:e,this.model||i(this.field,[]),this.model.splice(e,0,t?_(t):undefined),this.options._buildForm(!0),o&&this.formControl.markAsDirty()},e.prototype.remove=function(e,t){var r=(void 0===t?{markAsDirty:!0}:t).markAsDirty;this.model.splice(e,1),j(this.field.fieldGroup[e],!0),this.field.fieldGroup.splice(e,1),this.field.fieldGroup.forEach(function(e,t){return e.key=""+t}),this.options._buildForm(!0),r&&this.formControl.markAsDirty()},e.decorators=[{type:s.Directive,args:[{selector:"[ɵfieldArray]"}]}],e.ctorParameters=function(){return[{type:V,decorators:[{type:s.Inject,args:[w]},{type:s.Optional}]}]},e}(N),W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.propDecorators={fieldComponent:[{type:s.ViewChild,args:["fieldComponent",{read:s.ViewContainerRef,"static":!1}]}]},t}(N),$=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.defaultOptions={defaultValue:{}},e}return n(e,t),e.decorators=[{type:s.Component,args:[{selector:"formly-group",template:'\n <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>\n <ng-content></ng-content>\n ',host:{"[class]":'field.fieldGroupClassName || ""'}}]}],e}(N),q=function(){function e(e){this.formlyConfig=e}return e.prototype.ngOnChanges=function(){var e=this;this.errorMessage$=this.field.formControl.statusChanges.pipe(p.startWith(null),p.switchMap(function(){return u.isObservable(e.errorMessage)?e.errorMessage:u.of(e.errorMessage)}))},Object.defineProperty(e.prototype,"errorMessage",{get:function(){var e=this.field.formControl;for(var t in e.errors)if(e.errors.hasOwnProperty(t)){var r=this.formlyConfig.getValidatorMessage(t);if(F(e.errors[t])){if(e.errors[t].errorPath)return;e.errors[t].message&&(r=e.errors[t].message)}return this.field.validation&&this.field.validation.messages&&this.field.validation.messages[t]&&(r=this.field.validation.messages[t]),this.field.validators&&this.field.validators[t]&&this.field.validators[t].message&&(r=this.field.validators[t].message),this.field.asyncValidators&&this.field.asyncValidators[t]&&this.field.asyncValidators[t].message&&(r=this.field.asyncValidators[t].message),"function"==typeof r?r(e.errors[t],this.field):r}},enumerable:!0,configurable:!0}),e.decorators=[{type:s.Component,args:[{selector:"formly-validation-message",template:"{{ errorMessage$ | async }}",changeDetection:s.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:P}]},e.propDecorators={field:[{type:s.Input}]},e}(),B=function(r){function e(e){var t=r.call(this)||this;return t.sanitizer=e,t.innerHtml={content:null,template:null},t}return n(e,r),Object.defineProperty(e.prototype,"template",{get:function(){return this.field&&this.field.template!==this.innerHtml.template&&(this.innerHtml={template:this.field.template,content:this.to.safeHtml?this.sanitizer.bypassSecurityTrustHtml(this.field.template):this.field.template}),this.innerHtml.content},enumerable:!0,configurable:!0}),e.decorators=[{type:s.Component,args:[{selector:"formly-template",template:'<div [innerHtml]="template"></div>'}]}],e.ctorParameters=function(){return[{type:t.DomSanitizer}]},e}(N);function L(e,t,r){return e instanceof Function?e.apply(t,r):!!e}var z=function(){function e(){}return e.prototype.prePopulate=function(e){var r=this;if(!e.parent&&!e.options._checkField){var o=!1;e.options._checkField=function(e,t){o||(o=!0,k(e.formControl,function(){return r.checkField(e,t)}),o=!1)}}},e.prototype.postPopulate=function(s){var a=this;if(s.parent&&!s._expressionProperties){if(E(s,"_expressionProperties",{}),s.expressionProperties){var e=function(t){var e=s.expressionProperties[t];if("string"==typeof e||O(e))s._expressionProperties[t]={expression:l._evalExpression(t,e,"templateOptions.disabled"===t&&s.parent.expressionProperties&&s.parent.expressionProperties.hasOwnProperty("templateOptions.disabled")?function(){return s.parent.templateOptions.disabled}:undefined)},"templateOptions.disabled"===t&&Object.defineProperty(s._expressionProperties[t],"expressionValue",{get:function(){return s.templateOptions.disabled},set:function(){},enumerable:!0,configurable:!0});else if(e instanceof u.Observable){var r=function(){return e.subscribe(function(e){a.setExprValue(s,t,e),s.options&&s.options._markForCheck&&s.options._markForCheck(s)})},o=r(),n=s.hooks.onInit;s.hooks.onInit=function(){return null===o&&(o=r()),n&&n(s)};var i=s.hooks.onDestroy;s.hooks.onDestroy=function(){i&&i(s),o.unsubscribe(),o=null}}},l=this;for(var t in s.expressionProperties)e(t)}s.hideExpression?(delete s.hide,s.hideExpression=this._evalExpression("hide",s.hideExpression,function(){for(var e=s.parent;e.parent&&!e.hide;)e=e.parent;return e.hide})):x(s,"hide",function(e){var t=e.currentValue,r=e.firstChange;s._hide=t,(!r||r&&!0===t)&&s.options._hiddenFieldsForCheck.push(s)})}},e.prototype._evalExpression=function(i,s,a){return function(e,t,r){try{return"string"==typeof s&&(s=function o(e,t){try{return-1!==e.indexOf("this.field")&&console.warn("NgxFormly: using 'this.field' in expressionProperties is deprecated since v5.1, use 'field' instead."),Function.apply(void 0,y(t,["return "+e+";"]))}catch(r){console.error(r)}}(s,["model","formState","field"])),"function"!=typeof s&&(s=function(){return!!s}),a&&a()||s(e,t,r)}catch(n){throw n.message='[Formly Error] [Expression "'+i+'"] '+n.message,n}}},e.prototype.checkField=function(e,t){var r=this;void 0===t&&(t=!1);var o=this._checkField(e,t);e.options._hiddenFieldsForCheck.sort(function(e){return e.hide?-1:1}).forEach(function(e){return r.toggleFormControl(e,!!e.hide,!t)}),e.options._hiddenFieldsForCheck=[],o&&(this.checkField(e),e.options&&e.options._markForCheck&&e.options._markForCheck(e))},e.prototype._checkField=function(t,r){var o=this;void 0===r&&(r=!1);var n=!1;return t.fieldGroup.forEach(function(e){e.options&&(o.checkFieldExpressionChange(e,r)&&(n=!0),o.checkFieldVisibilityChange(e,r)&&(t.options._hiddenFieldsForCheck.push(e),n=!0),e.fieldGroup&&0<e.fieldGroup.length&&o._checkField(e,r)&&(n=!0))}),n},e.prototype.checkFieldExpressionChange=function(e,t){if(!e||!e._expressionProperties)return!1;var r=!1,o=e._expressionProperties;for(var n in o){var i=L(o[n].expression,{field:e},[e.model,e.options.formState,e]);"templateOptions.disabled"===n&&(i=!!i),(t||o[n].expressionValue!==i&&(!F(i)||u.isObservable(i)||JSON.stringify(i)!==JSON.stringify(o[n].expressionValue)))&&(r=!0,o[n].expressionValue=i,this.setExprValue(e,n,i))}return r},e.prototype.checkFieldVisibilityChange=function(e,t){if(!e||b(e.hideExpression))return!1;var r=!!L(e.hideExpression,{field:e},[e.model,e.options.formState,e]),o=!1;return(r!==e.hide||t)&&(o=!0,e.hide=r,e.templateOptions.hidden=r),o},e.prototype.setDisabledState=function(e,t){var r=this;e.fieldGroup&&e.fieldGroup.filter(function(e){return!e.expressionProperties||!e.expressionProperties.hasOwnProperty("templateOptions.disabled")}).forEach(function(e){return r.setDisabledState(e,t)}),e.key&&e.templateOptions.disabled!==t&&(e.templateOptions.disabled=t)},e.prototype.toggleFormControl=function(e,t,r){var o=this;if(e.formControl&&e.key){E(e,"_hide",!(!t&&!e.hide));var n=e.formControl;n._fields&&1<n._fields.length&&G(n),!0!==t||n._fields&&!n._fields.every(function(e){return!!e._hide})?!1===t&&(e.resetOnHide&&e.parent&&!C(e.defaultValue)&&C(v(e))&&i(e,e.defaultValue),A(e,undefined,!0),e.resetOnHide&&e.fieldArray&&(e.fieldGroup||[]).length!==(e.model||[]).length&&e.options._buildForm(!0)):(j(e,!0),r&&e.resetOnHide&&(e.formControl.reset({value:undefined,disabled:e.formControl.disabled}),e.fieldGroup&&(i(e,undefined),e.formControl instanceof f.FormArray&&(e.fieldGroup.length=0))))}e.fieldGroup&&e.fieldGroup.filter(function(e){return!e.hideExpression}).forEach(function(e){return o.toggleFormControl(e,t,r)}),e.options.fieldChanges&&e.options.fieldChanges.next({field:e,type:"hidden",value:t})},e.prototype.setExprValue=function(e,t,r){try{for(var o=e,n=-1===t.indexOf("[")?t.split("."):t.replace(/\'|\"/g,"").split(/[[\]]{1,2}/).filter(function(e){return e}),i=n.length-1,s=0;s<i;s++)o=o[n[s]];o[n[i]]=r}catch(p){throw p.message='[Formly Error] [Expression "'+t+'"] '+p.message,p}if("templateOptions.disabled"===t&&e.key&&this.setDisabledState(e,r),0===t.indexOf("model.")){var a=t.replace(/^model\./,""),l=e.key&&t===a?e.formControl:e.parent.formControl.get(a);!l||b(l.value)&&b(r)||l.value===r||l.patchValue(r)}this.emitExpressionChanges(e,t,r)},e.prototype.emitExpressionChanges=function(e,t,r){e.options.fieldChanges&&e.options.fieldChanges.next({field:e,type:"expressionChanges",property:t,value:r})},e}(),Y=function(){function e(e){this.formlyConfig=e}return e.prototype.onPopulate=function(e){this.initFieldValidation(e,"validators"),this.initFieldValidation(e,"asyncValidators")},e.prototype.initFieldValidation=function(t,e){var r=this,o=[];if("validators"!==e||t.hasOwnProperty("fieldGroup")&&!t.key||o.push(this.getPredefinedFieldValidation(t)),t[e])for(var n in t[e])"validation"!==n||Array.isArray(t[e].validation)||(t[e].validation=[t[e].validation],console.warn("NgxFormly("+t.key+"): passing a non array value to the 'validation' is deprecated, pass an array instead")),"validation"===n?o.push.apply(o,y(t[e].validation.map(function(e){return r.wrapNgValidatorFn(t,e)}))):o.push(this.wrapNgValidatorFn(t,t[e][n],n));E(t,"_"+e,o)},e.prototype.getPredefinedFieldValidation=function(n){var i=[];return a.forEach(function(o){return x(n.templateOptions,o,function(e){var t=e.currentValue,r=e.firstChange;i=i.filter(function(e){return e!==o}),null!=t&&!1!==t&&i.push(o),!r&&n.formControl&&G(n.formControl)})}),function(r){return 0===i.length?null:f.Validators.compose(i.map(function(t){return function(){var e=n.templateOptions[t];switch(t){case"required":return f.Validators.required(r);case"pattern":return f.Validators.pattern(e)(r);case"minLength":return f.Validators.minLength(e)(r);case"maxLength":return f.Validators.maxLength(e)(r);case"min":return f.Validators.min(e)(r);case"max":return f.Validators.max(e)(r)}}}))(r)}},e.prototype.wrapNgValidatorFn=function(o,e,n){var i=this,s=null;if("string"==typeof e&&(s=_(this.formlyConfig.getValidator(e))),"object"==typeof e&&e.name&&(s=_(this.formlyConfig.getValidator(e.name)),e.options&&(s.options=e.options)),"object"==typeof e&&e.expression){var t=e.expression,r=d(e,["expression"]);s={name:n,validation:t,options:0<Object.keys(r).length?r:null}}return"function"==typeof e&&(s={name:n,validation:e}),function(e){var t=s.validation(e,o,s.options);return function r(e){return!!e&&"function"==typeof e.then}(t)?t.then(function(e){return i.handleAsyncResult(o,n?!!e:e,s)}):u.isObservable(t)?t.pipe(p.map(function(e){return i.handleAsyncResult(o,n?!!e:e,s)})):i.handleResult(o,n?!!t:t,s)}},e.prototype.handleAsyncResult=function(e,t,r){return e.options&&e.options._markForCheck&&e.options._markForCheck(e),this.handleResult(e,t,r)},e.prototype.handleResult=function(s,a,e){var t,r=e.name,l=e.options;"boolean"==typeof a&&(a=a?null:((t={})[r]=l||!0,t));var p=s.formControl;return p._childrenErrors&&p._childrenErrors[r]&&p._childrenErrors[r](),F(a)&&Object.keys(a).forEach(function(o){var e,t=a[o].errorPath?a[o].errorPath:(l||{}).errorPath,n=t?s.formControl.get(t):null;if(n){var r=a[o],i=(r.errorPath,d(r,["errorPath"]));n.setErrors(c({},n.errors||{},((e={})[o]=i,e))),!p._childrenErrors&&E(p,"_childrenErrors",{}),p._childrenErrors[o]=function(){var e=n.errors||{},t=o,r=(e[t],d(e,["symbol"==typeof t?t:t+""]));n.setErrors(0===Object.keys(r).length?null:r)}}}),a},e}(),Z=function(){function e(e){this.config=e}return e.prototype.onPopulate=function(e){e.parent&&(e.fieldGroup&&!e.key?E(e,"formControl",e.parent.formControl):this.addFormControl(e))},e.prototype.postPopulate=function(e){if(!e.parent){var t=this.setValidators(e);if(0!==t.length)if(1===t.length)for(var r=t[0].formControl;r;)r._updateTreeValidity({onlySelf:!0}),r=r.parent;else e.formControl._updateTreeValidity()}},e.prototype.addFormControl=function(e){var t=R(e);if(!t){var r={updateOn:e.modelOptions.updateOn},o=e.key?v(e):e.defaultValue,n=this.config?this.config.resolveFieldTypeRef(e):null;if(n&&n.componentType&&n.componentType.createControl){var i=n.componentType;console.warn("NgxFormly: '"+i.name+"::createControl' is deprecated since v5.0, use 'prePopulate' hook instead."),t=i.createControl(o,e)}else t=e.fieldGroup?new f.FormGroup({},r):new f.FormControl(o,r)}A(e,t)},e.prototype.setValidators=function(t){var r=this,o=!1;if(t.key||!t.parent||!t.key&&!t.fieldGroup){var n=t.formControl,e=!!t.templateOptions&&t.templateOptions.disabled;t.key&&n&&(e&&n.enabled&&(n.disable({emitEvent:!1,onlySelf:!0}),n.parent?o=!0:G(n)),!e&&n.disabled&&(n.enable({emitEvent:!1,onlySelf:!0}),n.parent?o=!0:G(n))),!n||null!==n.validator&&null!==n.asyncValidator||(n.setValidators(function(){var e=f.Validators.compose(r.mergeValidators(t,"_validators"));return e?e(n):null}),n.setAsyncValidators(function(){var e=f.Validators.composeAsync(r.mergeValidators(t,"_asyncValidators"));return e?e(n):u.of(null)}),n.parent?o=!0:G(n))}var i=o?[t]:[];return(t.fieldGroup||[]).forEach(function(e){var t=r.setValidators(e);o||i.push.apply(i,y(t))}),i},e.prototype.mergeValidators=function(e,t){var r=this,o=[],n=e.formControl;return n&&n._fields&&1<n._fields.length?n._fields.filter(function(e){return!e._hide}).forEach(function(e){return o.push.apply(o,y(e[t]))}):e[t]&&o.push.apply(o,y(e[t])),e.fieldGroup&&e.fieldGroup.filter(function(e){return!e.key&&e.fieldGroup}).forEach(function(e){return o.push.apply(o,y(r.mergeValidators(e,t)))}),o},e}(),J=function(){function e(e){this.formlyConfig=e,this.formId=0}return e.prototype.prePopulate=function(t){if(this.getFieldComponentInstance(t).prePopulate(),!t.parent){var e=t.options&&t.options.fieldTransform||this.formlyConfig.extras.fieldTransform;(Array.isArray(e)?e:[e]).forEach(function(e){if(e&&(console.warn("NgxFormly: fieldTransform is deprecated since v5.0, use custom extension instead."),!e(t.fieldGroup,t.model,t.formControl,t.options)))throw new Error("fieldTransform must return an array of fields")})}},e.prototype.onPopulate=function(r){var o=this;this.initFieldOptions(r),this.getFieldComponentInstance(r).onPopulate(),r.fieldGroup&&r.fieldGroup.forEach(function(e,t){Object.defineProperty(e,"parent",{get:function(){return r},configurable:!0}),Object.defineProperty(e,"index",{get:function(){return t},configurable:!0}),o.formId++})},e.prototype.postPopulate=function(e){this.getFieldComponentInstance(e).postPopulate()},e.prototype.initFieldOptions=function(e){var t=e.parent;if(t){if(Object.defineProperty(e,"form",{get:function(){return t.formControl},configurable:!0}),Object.defineProperty(e,"options",{get:function(){return t.options},configurable:!0}),Object.defineProperty(e,"model",{get:function(){return e.key&&e.fieldGroup?v(e):t.model},configurable:!0}),l(e,{id:function n(e,t,r){if(t.id)return t.id;var o=t.type;return!o&&t.template&&(o="template"),[e,o,t.key,r].join("_")}("formly_"+this.formId,e,e.index),hooks:{},modelOptions:{},templateOptions:e.type&&e.key?{label:"",placeholder:"",focus:!1,disabled:!1}:{}}),this.formlyConfig.extras.resetFieldOnHide&&!1!==e.resetOnHide&&(e.resetOnHide=!0),e.lifecycle&&console.warn("NgxFormly: 'lifecycle' is deprecated since v5.0, use 'hooks' instead."),"formly-template"!==e.type&&(e.template||e.expressionProperties&&e.expressionProperties.template)&&(e.type&&console.warn("NgxFormly: passing 'type' property is not allowed when 'template' is set."),e.type="formly-template"),!e.type&&e.fieldGroup&&(e.type="formly-group"),e.type&&this.formlyConfig.getMergedField(e),e.parent){var r=!C(e.key)&&!C(e.defaultValue)&&C(v(e))&&(!e.resetOnHide||!(e.hide||e.hideExpression));if(r&&e.resetOnHide){for(var o=e.parent;o&&!o.hideExpression&&!o.hide;)o=o.parent;r=!o||!(o.hideExpression||o.hide)}r&&i(e,e.defaultValue)}this.initFieldWrappers(e)}},e.prototype.initFieldWrappers=function(t){t.wrappers=t.wrappers||[];var e=c({preWrapper:[],postWrapper:[]},t.templateOptions.templateManipulators||{});t.wrappers=y(this.formlyConfig.templateManipulators.preWrapper.map(function(e){return e(t)}),e.preWrapper.map(function(e){return e(t)}),t.wrappers,this.formlyConfig.templateManipulators.postWrapper.map(function(e){return e(t)}),e.postWrapper.map(function(e){return e(t)})).filter(function(e,t,r){return e&&t===r.indexOf(e)})},e.prototype.getFieldComponentInstance=function(e){var t=this.formlyConfig.resolveFieldTypeRef(e),r=t?t.instance:{};return{prePopulate:function(){return r.prePopulate&&r.prePopulate(e)},onPopulate:function(){return r.onPopulate&&r.onPopulate(e)},postPopulate:function(){return r.postPopulate&&r.postPopulate(e)}}},e}();function U(e){return{types:[{name:"formly-group",component:$},{name:"formly-template",component:B}],extensions:[{name:"core",extension:new J(e)},{name:"field-validation",extension:new Y(e)},{name:"field-form",extension:new Z(e)},{name:"field-expression",extension:new z}]}}var X=function(){function t(t,e){void 0===e&&(e=[]),e&&e.forEach(function(e){return t.addConfig(e)})}return t.forRoot=function(e){return void 0===e&&(e={}),{ngModule:t,providers:[{provide:w,multi:!0,useFactory:U,deps:[P]},{provide:w,useValue:e,multi:!0},{provide:s.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:e,multi:!0},P,V]}},t.forChild=function(e){return void 0===e&&(e={}),{ngModule:t,providers:[{provide:w,multi:!0,useFactory:U,deps:[P]},{provide:w,useValue:e,multi:!0},{provide:s.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:e,multi:!0},V]}},t.decorators=[{type:s.NgModule,args:[{declarations:[I,T,D,$,q,B,H],entryComponents:[$,B],exports:[I,T,D,$,q],imports:[r.CommonModule]}]}],t.ctorParameters=function(){return[{type:P},{type:Array,decorators:[{type:s.Optional},{type:s.Inject,args:[w]}]}]},t}();e.FormlyForm=I,e.FormlyField=T,e.FormlyAttributes=D,e.FORMLY_CONFIG=w,e.FormlyConfig=P,e.FormlyFormBuilder=V,e.FieldType=N,e.Field=S,e.FieldArrayType=H,e.FieldWrapper=W,e.FormlyModule=X,e.ɵdefineHiddenProp=E,e.ɵreverseDeepMerge=l,e.ɵgetFieldInitialValue=function K(e){for(var t,r,o=e.options._initialModel,n=g(e);e.parent;)n=y(g(e=e.parent),n);try{for(var i=h(n),s=i.next();!s.done;s=i.next()){var a=s.value;if(!o)return undefined;o=o[a]}}catch(l){t={error:l}}finally{try{s&&!s.done&&(r=i["return"])&&r.call(i)}finally{if(t)throw t.error}}return o},e.ɵclone=_,e.ɵwrapProperty=x,e.ɵa=U,e.ɵe=J,e.ɵh=z,e.ɵg=Z,e.ɵf=Y,e.ɵd=B,e.ɵb=$,e.ɵc=q,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=ngx-formly-core.umd.min.js.map
|