UNPKG

ngx-schema-forms

Version:

New features: - Ajv schema validator. - Angular forms compatible: Property tree is created using FormGroup, FormArray and FormControl classes. - Array now properly loads initial data from model. - WidgetTyep: WidgetRegistry now supports WidgetType, now wo

2 lines 47.8 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/forms"),require("z-schema"),require("ajv"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-schema-forms",["exports","@angular/core","rxjs","rxjs/operators","@angular/forms","z-schema","ajv","@angular/common"],e):e(t["ngx-schema-forms"]={},t.ng.core,t.rxjs,t.rxjs.operators,t.ng.forms,null,null,t.ng.common)}(this,function(t,a,u,f,r,n,o,e){"use strict";var l=function(){function t(){this.actions={}}return t.prototype.clear=function(){this.actions={}},t.prototype.register=function(t,e){this.actions[t]=e},t.prototype.get=function(t){return this.actions[t]},t}(),i=function(){function t(){this.validators={}}return t.prototype.register=function(t,e){this.validators[t]=e},t.prototype.get=function(t){return this.validators[t]},t.prototype.clear=function(){this.validators={}},t}(),c="string",p="object",s="array",h="boolean",d="integer",m="number",y=function Ht(){},g={Field:"field",Fieldset:"fieldset",Button:"button"},v=function(){function t(){this.widgets={},this.defaultWidget={}}return t.prototype.setDefaultWidget=function(t,e){void 0===e&&(e=g.Field),this.defaultWidget[e]=t},t.prototype.getDefaultWidget=function(t){return void 0===t&&(t=g.Field),this.defaultWidget[t]},t.prototype.hasWidget=function(t,e){return void 0===e&&(e=g.Field),!!this.widgets.hasOwnProperty(e)&&this.widgets[e].hasOwnProperty(t)},t.prototype.register=function(t,e,r){void 0===r&&(r=g.Field),this.widgets.hasOwnProperty(r)||(this.widgets[r]={}),this.widgets[r][t]=e},t.prototype.getWidgetType=function(t,e){return void 0===e&&(e=g.Field),this.hasWidget(t,e)?this.widgets[e][t]:this.getDefaultWidget(e)},t}(),b=function(){function t(t,e){this.widgetRegistry=t,this.factoryResolver=e}return t.prototype.createWidget=function(t,e,r){void 0===r&&(r={type:g.Field});var n=this.widgetRegistry.getWidgetType(e,r.type),o=this.factoryResolver.resolveComponentFactory(n);return t.createComponent(o,undefined,r.injector)},t.decorators=[{type:a.Injectable}],t.ctorParameters=function(){return[{type:v},{type:a.ComponentFactoryResolver}]},t}(),P=function(t,e){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function w(t,e){function r(){this.constructor=t}P(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function C(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;0<=a;a--)(o=t[a])&&(s=(i<3?o(s):3<i?o(e,r,s):o(e,r))||s);return 3<i&&s&&Object.defineProperty(e,r,s),s}function F(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function R(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function O(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i["return"])&&r.call(i)}finally{if(o)throw o.error}}return s}function I(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(O(arguments[e]));return t}var V=function(){function t(t){this.errors=t}return t.prototype.getMessages=function(){var n=this,t=Object.keys(this.errors);return t.length?t.reduce(function(t,e){var r=n.errors[e].message;return r?t.push(r):t.push('Missing validation error "message" for property '+e),t},[]):[]},t}();function E(t){return function(n){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.apply(this,I(t))||this;return r.nonEmptyValueChanges=new a.EventEmitter,r.visibilityChanges=new u.BehaviorSubject(!0),r._visible=!0,r}return w(t,n),Object.defineProperty(t.prototype,"id",{get:function(){return this.path.toLowerCase().slice(1).replace(/\//g,"-")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return this===this.root},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.path.split("/").pop()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},enumerable:!0,configurable:!0}),t.prototype.getErrors=function(){var t,e=this.errors;return e?new V(((t={})[this.path]=e,t)):null},t.prototype.setVisible=function(t,e){void 0===e&&(e={disable:!1}),this._visible=t,e.disable&&(this.visible?this.enable():this.disable()),this.visibilityChanges.next(this.visible)},t.prototype.bindVisibility=function(){var e=this,o=this.schema.visibleIf;if(o!==undefined){var t=Object.keys(o);if("object"!=typeof o||0!==t.length){var r,n,i=[],s=function(t){if(!o.hasOwnProperty(t))return"continue";var e=a.root.get(t);if(!e)return console.warn("Couldn't find property "+t+" for visibility check of "+a.path),"continue";var r=o[t],n=e.valueChanges.pipe(f.startWith(r.includes(e.value)),f.map(function(t){return r.includes("$ANY$")||r.includes(t)}));i.push(n)},a=this;try{for(var l=R(t),c=l.next();!c.done;c=l.next()){s(c.value)}}catch(p){r={error:p}}finally{try{c&&!c.done&&(n=l["return"])&&n.call(l)}finally{if(r)throw r.error}}u.combineLatest(i).subscribe(function(t){e.setVisible(t.includes(!0))})}else this.setVisible(!1)}},t.prototype.get=function(t){return"string"==typeof t&&t.includes("/")&&(t=this.normalizePath(t)),n.prototype.get.call(this,t)},t.prototype.normalizePath=function(t){return"/"===t[0]&&(t=t.slice(1)),t.split("/")},t}(t)}var x=function(n){function t(t,e){var r=n.call(this,e["default"])||this;return r.path=t,r.schema=e,r}return w(t,n),t.prototype._updateValue=function(){null!==this.value&&""!==this.value?this.nonEmptyValue=this.value:this.nonEmptyValue=undefined},t}(E(r.FormControl)),k=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return w(t,r),t.prototype.setValue=function(t,e){void 0===e&&(e={}),r.prototype.setValue.call(this,+t,e)},t}(x),j=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return w(t,r),t.prototype.setValue=function(t,e){void 0===e&&(e={}),"boolean"!=typeof t&&(t=Boolean(t)),r.prototype.setValue.call(this,t,e)},t}(x),S=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return w(t,r),t.prototype.setValue=function(t,e){void 0===e&&(e={}),"string"!=typeof t&&(t=""+t),r.prototype.setValue.call(this,t,e)},t}(x),W=function(o){function t(t,e,r){var n=o.call(this,[])||this;return n.formPropertyFactory=t,n.path=e,n.schema=r,n}return w(t,o),t.prototype._updateValue=function(){var r=this;o.prototype._updateValue.call(this),this.nonEmptyValue=this.controls.filter(function(t){var e=t.enabled||r.disabled;return t.nonEmptyValue!==undefined&&e}).map(function(t){return t.value})},t.prototype.getErrors=function(){var t=this.controls.reduce(function(t,e){var r=e.getErrors();return r?Object.assign(t,r.errors):t},{});return this.errors&&(t[this.path]=this.errors),Object.keys(t).length?new V(t):null},t.prototype.patchValue=function(t,r){var n=this;void 0===r&&(r={}),t.forEach(function(t,e){n.addPropertyAt(e),n.at(e)&&n.at(e).patchValue(t,{onlySelf:!0,emitEvent:r.emitEvent})}),this.updateValueAndValidity(r)},t.prototype.addProperty=function(){var t=this.getPropertyFromSchemaItems();o.prototype.push.call(this,t),t.bindVisibility()},t.prototype.addPropertyAt=function(t){var e=this.getPropertyFromSchemaItems();this.insert(t,e),e.bindVisibility()},t.prototype.bindVisibility=function(){o.prototype.bindVisibility.call(this),this.controls.forEach(function(t){t.bindVisibility()})},t.prototype.forEach=function(t,e){void 0===e&&(e={includeSelf:!0}),e.includeSelf&&t(this);try{for(var r=R(this.controls),n=r.next();!n.done;n=r.next()){var o=n.value;o.forEach instanceof Function?o.forEach(t,{includeSelf:!0}):t(o)}}catch(a){i={error:a}}finally{try{n&&!n.done&&(s=r["return"])&&s.call(r)}finally{if(i)throw i.error}}var i,s},t.prototype.getPropertyFromSchemaItems=function(){return this.formPropertyFactory.createProperty(this.schema.items,this)},t}(E(r.FormArray)),D=function(o){function t(t,e){var r=o.call(this,{})||this;return r.path=t,r.schema=e,r}return w(t,o),t.prototype._updateValue=function(){var n=this;o.prototype._updateValue.call(this),this.nonEmptyValue=this._reduceChildren({},function(t,e,r){return e.nonEmptyValue===undefined||(e.enabled||n.disabled)&&(t[r]=e.nonEmptyValue),t})},t.prototype.getErrors=function(){var n=this,t=Object.keys(this.controls).reduce(function(t,e){var r=n.controls[e].getErrors();return r?Object.assign(t,r.errors):t},{});return this.errors&&(t[this.path]=this.errors),Object.keys(t).length?new V(t):null},t.prototype.bindVisibility=function(){for(var t in o.prototype.bindVisibility.call(this),this.controls)this.controls.hasOwnProperty(t)&&this.controls[t].bindVisibility()},t.prototype.forEach=function(t,e){for(var r in void 0===e&&(e={includeSelf:!0}),e.includeSelf&&t(this),this.controls)if(this.controls.hasOwnProperty(r)){var n=this.controls[r];if(n.forEach instanceof Function){n.forEach(t,{includeSelf:!0});continue}t(n)}},t}(E(r.FormGroup));function A(t,e){return"Parsing error on "+e+": "+t}function B(t,e){var r=A(t,e);throw new Error(r)}function T(t,e){var r=A(t,e);throw new Error(r)}var q=function(){function o(){}return o.preprocess=function(t,e){void 0===e&&(e="/"),"object"===(t=t||{}).type?(o.checkProperties(t,e),o.checkAndCreateFieldsets(t,e)):"array"===t.type&&o.checkItems(t,e),o.normalizeWidget(t),o.recursiveCheck(t,e)},o.checkProperties=function(t,e){(function r(t){return null===t||t===undefined})(t.properties)&&(t.properties={},T("Provided json schema does not contain a 'properties' entry. Output schema will be empty",e))},o.checkAndCreateFieldsets=function(t,e){t.fieldsets===undefined&&(t.order!==undefined?o.replaceOrderByFieldsets(t):o.createFieldsets(t)),o.checkFieldsUsage(t,e)},o.checkFieldsUsage=function(t,e){var r,n,o,i,s,a,l=Object.keys(t.properties),c={};try{for(var p=R(t.fieldsets),u=p.next();!u.done;u=p.next()){var f=u.value;try{for(var h=R(f.fields),d=h.next();!d.done;d=h.next()){c[g=d.value]===undefined&&(c[g]=[]),c[g].push(f.id)}}catch(b){o={error:b}}finally{try{d&&!d.done&&(i=h["return"])&&i.call(h)}finally{if(o)throw o.error}}}}catch(P){r={error:P}}finally{try{u&&!u.done&&(n=p["return"])&&n.call(p)}finally{if(r)throw r.error}}try{for(var m=R(l),y=m.next();!y.done;y=m.next()){var g=y.value;c.hasOwnProperty(g)?(1<c[g].length&&B(g+" is referenced by more than one fieldset: "+c[g],e),delete c[g]):-1<t.required.indexOf(g)?B(g+" is a required field but it is not referenced as part of a 'order' or a 'fieldset' property",e):(delete t[g],T("Removing unreferenced field "+g,e))}}catch(w){s={error:w}}finally{try{y&&!y.done&&(a=m["return"])&&a.call(m)}finally{if(s)throw s.error}}for(var v in c)c.hasOwnProperty(v)&&T("Referencing non-existent field "+v+" in one or more fieldsets",e)},o.createFieldsets=function(t){t.order=Object.keys(t.properties),o.replaceOrderByFieldsets(t)},o.replaceOrderByFieldsets=function(t){t.fieldsets=[{id:"fieldset-default",title:t.title||"",description:t.description||"",name:t.name||"",fields:t.order}],delete t.order},o.normalizeWidget=function(t){var e=t.widget;e===undefined?e={id:t.type}:"string"==typeof e&&(e={id:e}),t.widget=e},o.checkItems=function(t,e){t.items===undefined&&B("No 'items' property in array",e)},o.recursiveCheck=function(t,e){if("object"===t.type&&t.hasOwnProperty("definitions"))for(var r in t.definitions)if(t.definitions.hasOwnProperty(r)){var n=t.definitions[r];o.removeRecursiveRefProperties(n,"#/definitions/"+r)}},o.removeRecursiveRefProperties=function(t,e){if("object"===t.type)for(var r in t.properties)t.properties.hasOwnProperty(r)&&(t.properties[r].$ref&&t.properties[r].$ref===e?delete t.properties[r]:"object"===t.properties[r].type&&o.removeRecursiveRefProperties(t.properties[r],e))},o}(),z=function(){function t(t,e){this.schemaValidatorFactory=t,this.validatorRegistry=e}return t.prototype.createProperty=function(t,e,r){var n,o=this.generatePath(e,r);if(q.preprocess(t,o),t.$ref){var i=this.schemaValidatorFactory.getSchema(e.root.schema,t.$ref);n=this.createProperty(i,e,r||o)}else switch(t.type){case d:case m:n=new k(o,t);break;case c:n=new S(o,t);break;case h:n=new j(o,t);break;case p:n=new D(o,t);break;case s:"array"===t.widget.id?n=new W(this,o,t):(t["default"]=[],n=new x(o,t));break;default:throw new TypeError("Undefined type "+t.type)}return this.initializeFormProperty(n,e),n},t.prototype.initializeFormProperty=function(t,e){if(e&&t.setParent(e),this.bindCustomValidator(t),t instanceof D)for(var r in t.schema.properties)if(t.schema.properties.hasOwnProperty(r)){var n=t.schema.properties[r],o=this.createProperty(n,t,r);t.addControl(r,o)}t.isRoot&&(this.bindSchemaValidator(t),t.bindVisibility())},t.prototype.bindSchemaValidator=function(n){var e=this.schemaValidatorFactory.createValidatorFn(n.schema);n.valueChanges.pipe(f.startWith(null)).subscribe(function(){var t=n.nonEmptyValue;n.nonEmptyValueChanges.emit(t);var r=e(t);r&&Object.keys(r).forEach(function(t){var e=n.get(t);e&&e.setErrors(r[t],{emitEvent:!0})})})},t.prototype.bindCustomValidator=function(t){var e=this.validatorRegistry.get(t.path);e&&t.setValidators(e)},t.prototype.generatePath=function(t,e){if(!t)return"/";var r="";switch(r+=t.path,t.parent!==undefined&&(r+="/"),t.schema.type){case p:r+=e;break;case s:r+=t.controls.length;break;default:throw new Error("Instantiation of a FormProperty with an unknown parent type: "+t.schema.type)}return r},t}(),_="field",L="button",M=function(){function t(){this.elements={}}return t.prototype.hasElement=function(t,e){return void 0===e&&(e=_),!!this.elements.hasOwnProperty(e)&&this.elements[e].hasOwnProperty(t)},t.prototype.register=function(t,e,r){void 0===r&&(r=_),this.elements.hasOwnProperty(r)||(this.elements[r]={}),this.elements[r][t]=e},t.prototype.getElement=function(t,e){if(void 0===e&&(e=_),this.hasElement(t,e))return this.elements[e][t]},t.prototype.clear=function(){this.elements={}},t}();function N(t,e){return new z(t,e)}var H=function(){function t(t,e,r,n){this.changeDetectorRef=t,this.formPropertyFactory=e,this.actionRegistry=r,this.validatorRegistry=n,this.schema=null,this.actions={},this.validators={},this.rootFormProperty=null}return t.prototype.writeValue=function(t){this.rootFormProperty&&t&&this.rootFormProperty.patchValue(t)},t.prototype.registerOnChange=function(t){this.onChangeCallback=t,this.rootFormProperty&&this.rootFormProperty.nonEmptyValueChanges.subscribe(t)},t.prototype.registerOnTouched=function(t){},t.prototype.setDisabledState=function(t){this.rootFormProperty&&(t?this.rootFormProperty.disable():this.rootFormProperty.enable())},t.prototype.ngOnChanges=function(t){if(t.validators&&this.registerValidators(),t.actions&&this.registerActions(),this.schema&&!this.schema.type&&(this.schema.type=p),this.schema&&t.schema){var e=void 0;this.rootFormProperty&&(e=this.rootFormProperty.nonEmptyValue),this.rootFormProperty=null,this.changeDetectorRef.detectChanges();var r=this.formPropertyFactory.createProperty(this.schema);this.onChangeCallback&&(r.nonEmptyValueChanges.subscribe(this.onChangeCallback),e&&r.patchValue(e)),this.rootFormProperty=r}},t.prototype.ngOnInit=function(){},t.prototype.registerValidators=function(){if(this.validatorRegistry.clear(),this.validators)for(var t in this.validators)this.validators.hasOwnProperty(t)&&this.validatorRegistry.register(t,this.validators[t])},t.prototype.registerActions=function(){if(this.actionRegistry.clear(),this.actions)for(var t in this.actions)this.actions.hasOwnProperty(t)&&this.actionRegistry.register(t,this.actions[t])},t.decorators=[{type:a.Component,args:[{selector:"sf-form",template:'\n <form #form="ngForm">\n <sf-form-element *ngIf="rootFormProperty; else noSchema" [formProperty]="rootFormProperty">\n </sf-form-element>\n <ng-template #noSchema>\n You need to provide a json or a template schema!\n </ng-template>\n </form>\n ',providers:[{provide:r.NG_VALUE_ACCESSOR,useExisting:a.forwardRef(function(){return t}),multi:!0},l,i,b,{provide:z,useFactory:N,deps:[y,i]},M],encapsulation:a.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:a.ChangeDetectorRef},{type:z},{type:l},{type:i}]},t.propDecorators={schema:[{type:a.Input}],actions:[{type:a.Input}],validators:[{type:a.Input}]},t}(),$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(a.TemplateRef),U=function(){function t(){}return t.decorators=[{type:a.Component,args:[{selector:"sf-form-element",template:'<div *ngIf="formProperty.visible && formProperty.schema.widget?.id !== \'none\'"\n [class.has-error]="!formProperty.hasOwnProperty(\'controls\') && !formProperty.valid"\n\t [class.has-success]="!formProperty.hasOwnProperty(\'controls\') && formProperty.valid">\n <ng-template sfFormPropertyWidgetChooser [formProperty]="formProperty"> </ng-template>\n <ng-container *ngIf="formProperty.schema.buttons as buttons">\n <div class="button-container" >\n <ng-template sfFormButtonWidgetChooser\n *ngFor="let button of buttons"\n [button]="button"\n [formProperty]="formProperty">\n </ng-template>\n </div>\n </ng-container>\n </div>',encapsulation:a.ViewEncapsulation.None}]}],t.propDecorators={formProperty:[{type:a.Input}]},t}();function G(){return function(e,t){var r="__"+t;Object.defineProperty(e,t,{get:function(){return this[r]},set:function(t){this[r]||(this[r]=[]),this[r].push(t)},enumerable:!0,configurable:!0});var n=e.ngOnDestroy;e.ngOnDestroy=function(){if(n&&n.call(e),this[r]&&this[r].length){for(;this[r].length;){var t=this[r].pop();t&&t.unsubscribe&&t.unsubscribe()}this[r]=undefined}}}}var Y=function(){function t(t,e,r,n){this.viewContainerRef=t,this.widgetFactory=e,this.actionRegistry=r,this.templateRegistry=n}return t.prototype.getWidget=function(){return this.button.widget?(this.button.widget.id||(this.button.widget.id="button"),this.button.widget):{id:"button"}},t.prototype.getButtonAction=function(t){var o=this;return function(t,e){var r=o.button.options;if(!o.formProperty.invalid||!r.onInvalidFormProperty.preventClick){var n=o.actionRegistry.get(o.button.id);n&&(n({event:t,formProperty:o.formProperty},e),t.hasOwnProperty("preventDefault")&&t.preventDefault())}}},t.prototype.bindTemplateChanges=function(){var r=this,t=this.templateRegistry.getElement(this.button.id,L);t&&(this.subs=t.changes.subscribe(function(t){var e=r.componentRef.instance;e.label=t.label,"string"!=typeof t.widget&&Object.assign(e.widget,t.widget),Object.assign(e.options,t.options),e.action=r.getButtonAction(e),r.componentRef.changeDetectorRef.detectChanges()}))},t.prototype.ngOnInit=function(){var t=this.getWidget();this.componentRef=this.widgetFactory.createWidget(this.viewContainerRef,t.id,{type:g.Button});var e=this.componentRef.instance;e.label=this.button.label,e.formProperty=this.formProperty,e.widget?Object.assign(e.widget,t):e.widget=t,Object.assign(e.options,this.button.options),e.action=this.getButtonAction(e),this.bindTemplateChanges()},t.prototype.ngOnDestroy=function(){this.componentRef&&this.componentRef.destroy(),this.viewContainerRef&&this.viewContainerRef.clear()},t.decorators=[{type:a.Directive,args:[{selector:"[sfFormButtonWidgetChooser]"}]}],t.ctorParameters=function(){return[{type:a.ViewContainerRef},{type:b},{type:l},{type:M}]},t.propDecorators={button:[{type:a.Input}],formProperty:[{type:a.Input}]},C([G(),F("design:type",Object)],t.prototype,"subs",void 0),t}(),J=function(){function t(t){this.templateRef=t}return t.decorators=[{type:a.Component,args:[{selector:"sf-form-field",template:'\n <ng-container\n *ngTemplateOutlet="templateRef; context: { formProperty: formProperty }">\n </ng-container>\n ',encapsulation:a.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:$}]},t.propDecorators={formProperty:[{type:a.Input}]},t}(),Q=function(){function t(t,e){this.viewContainerRef=t,this.widgetFactory=e}return t.prototype.ngOnInit=function(){var e=this,t=a.Injector.create({providers:[{provide:$,useValue:this.templateRef}]}),r=this.getFieldsetWidget();this.componentRef=this.widgetFactory.createWidget(this.viewContainerRef,r.id,{type:g.Fieldset,injector:t});var n=this.componentRef.instance;n.formProperty=this.formProperty,n.title=this.fieldset.title,n.description=this.fieldset.description,n.formProperties=this.fieldset.fields.map(function(t){return e.formProperty.get(t)}),n.widget=r,this.formProperty.fieldsetWidgetInstance=n},t.prototype.ngOnDestroy=function(){this.componentRef.destroy(),this.viewContainerRef.clear()},t.prototype.getFieldsetWidget=function(){return this.fieldset.widget?"string"==typeof this.fieldset.widget?{id:this.fieldset.widget}:(this.fieldset.widget.id||(this.fieldset.widget.id="fieldset"),this.fieldset.widget):{id:"fieldset"}},t.decorators=[{type:a.Directive,args:[{selector:"[sfFormFieldsetWidgetChooser]"}]}],t.ctorParameters=function(){return[{type:a.ViewContainerRef},{type:b}]},t.propDecorators={formProperty:[{type:a.Input}],fieldset:[{type:a.Input}],templateRef:[{type:a.Input}]},t}(),X=function(){function t(t,e,r){this.viewContainerRef=t,this.widgetFactory=e,this.templateRegistry=r}return t.prototype.isWidgetRequired=function(){var t=this.formProperty.parent;return!(!t||!t.schema.required)&&t.schema.required.includes(this.formProperty.name)},t.prototype.ngOnInit=function(){var r=this;this.componentRef=this.widgetFactory.createWidget(this.viewContainerRef,this.formProperty.schema.widget.id);var n=this.componentRef.instance;n.formProperty=this.formProperty,n.schema=this.formProperty.schema,n.id=this.formProperty.id;var t=this.templateRegistry.getElement(this.formProperty.path);t&&(this.subs=t.changes.subscribe(function(t){n.schema=Object.assign(r.formProperty.schema,t),r.componentRef.changeDetectorRef.detectChanges()})),n.required=this.isWidgetRequired(),this.formProperty.widgetInstance=n,this.formProperty instanceof x&&(this.subs=this.formProperty.statusChanges.pipe(f.startWith("INVALID"),f.filter(function(t){var e=n.errorMessages,r=e&&0<e.length;return!("VALID"!==t||!r)||"INVALID"===t}),f.distinctUntilChanged()).subscribe(function(){var t=r.formProperty.getErrors();if(t){var e=t.getMessages();r.componentRef.instance.errorMessages=e,r.componentRef.changeDetectorRef.detectChanges()}else r.componentRef.instance.errorMessages=[]}))},t.prototype.ngOnDestroy=function(){this.componentRef&&this.componentRef.destroy(),this.viewContainerRef&&this.viewContainerRef.clear()},t.decorators=[{type:a.Directive,args:[{selector:"[sfFormPropertyWidgetChooser]"}]}],t.ctorParameters=function(){return[{type:a.ViewContainerRef},{type:b},{type:M}]},t.propDecorators={formProperty:[{type:a.Input}]},C([G(),F("design:type",Object)],t.prototype,"subs",void 0),t}(),Z=function(e){function t(){var t=e.call(this)||this;return t.zschema=new n({breakOnFirstError:!1}),t}return w(t,e),t.prototype.createValidatorFn=function(r){var n=this;return function(t){"number"!==r.type&&"integer"!==r.type||(t=+t),n.zschema.validate(t,r);var e=n.zschema.getLastErrors();return e?(n.denormalizeRequiredPropertyPaths(e),e.reduce(function(t,e){return e.path=e.path.slice(1),t[e.path]=e,t},{})||null):null}},t.prototype.getSchema=function(t,e){if(this.zschema.compileSchema(t))return this.getDefinition(t,e);throw this.zschema.getLastError()},t.prototype.denormalizeRequiredPropertyPaths=function(t){t&&t.length&&(t=t.map(function(t){return"#/"===t.path&&"OBJECT_MISSING_REQUIRED_PROPERTY"===t.code&&(t.path=""+t.path+t.params[0]),t}))},t.prototype.getDefinition=function(t,e){var r=t;return e.split("/").slice(1).forEach(function(t){t&&(r=r[t])}),r},t}(y),K=function(e){function t(){var t=e.call(this)||this;return t.ajv=new o({schemaId:"auto",allErrors:!0}),t}return w(t,e),t.prototype.createValidatorFn=function(t){var e=this.ajv.compile(t);return function(t){return e(t)?null:e.errors.reduce(function(t,e){return t["#/required"===e.schemaPath?"/"+e.params.missingProperty:e.dataPath.replace(/(\.|\[|\].)/g,"/")]={code:e.keyword,message:e.message},t},{})||null}},t.prototype.getSchema=function(t,e){return this.ajv.compile(t),this.getDefinition(t,e)},t.prototype.getDefinition=function(t,e){var r=t;return e.split("/").slice(1).forEach(function(t){t&&(r=r[t])}),r},t}(y),tt=function $t(){},et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(tt),rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(tt),nt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(tt),ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),it=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.prototype.addItem=function(){this.formProperty.addProperty()},e.prototype.removeItem=function(t){this.formProperty.removeAt(t)},e}(ot),at=function Ut(){this.onInvalidFormProperty={disable:!1,preventClick:!1}},lt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.options=new at,t}return w(t,e),t}(rt),ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(it),pt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.checked={},t}return w(t,e),t.prototype.ngOnInit=function(){var e=this;"array"===this.schema.type&&this.formProperty.valueChanges.subscribe(function(t){t.forEach(function(t){e.checked[t]||(e.checked[t]=!0)})})},t.prototype.check=function(t,e){var r=this;t?this.checked[e]=!0:delete this.checked[e],this.formProperty.patchValue(Object.keys(this.checked).filter(function(t){return r.checked[t]}))},t}(nt),ut=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.reader=new FileReader,t.filedata={},t.fileName=new r.FormControl,t}return w(t,e),t.prototype.ngAfterViewInit=function(){var t=this;this.reader.onloadend=function(){t.filedata.data=btoa(t.reader.result),t.formProperty.setValue(t.filedata)}},t.prototype.onFileChange=function(t){var e=t.target.files[0];this.filedata.filename=e.name,this.filedata.size=e.size,this.filedata["content-type"]=e.type,this.filedata.encoding="base64",this.reader.readAsBinaryString(e)},t}(nt),ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),ht=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(nt),gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.prototype.getInputType=function(){return this.schema.widget.id&&"string"!==this.schema.widget.id?this.schema.widget.id:"text"},e}(nt),vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e}(et),bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-array-widget",template:'<div class="widget form-group">\n\t<label [attr.for]="id" class="horizontal control-label">\n\t\t{{ schema.title }}\n\t</label>\n\t<span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\n\t<div *ngFor="let formProperty of formProperty.controls; let i=index">\n\t\t<sf-form-element [formProperty]="formProperty"></sf-form-element>\n\t\t<button (click)="removeItem(i)" class="btn btn-default array-remove-button">\n\t\t\t<span class="glyphicon glyphicon-minus" aria-hidden="true"></span> Remove\n\t\t</button>\n\t</div>\n\t<button (click)="addItem()" class="btn btn-default array-add-button">\n\t\t<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add\n\t</button>\n</div>'}]}],e}(st),Pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-button-component",template:'<button (click)="action($event)">{{label}}</button>'}]}],e}(lt),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-form-object",template:'\n <ng-template #formElement let-formProperty="formProperty">\n <sf-form-element [formProperty]="formProperty"></sf-form-element>\n </ng-template>\n\n <ng-container *ngFor="let fieldset of formProperty.schema.fieldsets">\n <ng-template\n sfFormFieldsetWidgetChooser\n [formProperty]="formProperty"\n [fieldset]="fieldset"\n [templateRef]="formElement">\n </ng-template>\n </ng-container>\n '}]}],e}(ct),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-checkbox-widget",template:'<div class="widget form-group">\n <label [attr.for]="id" class="horizontal control-label">\n {{ schema.title }}\n </label>\n <div *ngIf="schema.type!=\'array\'" class="checkbox">\n <label class="horizontal control-label">\n <input\n [formControl]="formProperty"\n [indeterminate]="formProperty.value !== false && formProperty.value !== true ? true :null"\n type="checkbox" [attr.disabled]="schema.readOnly">\n <input *ngIf="schema.readOnly" type="hidden" [formControl]="formProperty">\n {{schema.description}}\n </label>\n </div>\n <ng-container *ngIf="schema.type===\'array\'">\n <div *ngFor="let option of schema.items.oneOf" class="checkbox">\n <label class="horizontal control-label">\n <input\n value="{{option.enum[0]}}" type="checkbox"\n [attr.disabled]="schema.readOnly"\n (change)="check($event.target.checked, $event.target.value)"\n [attr.checked]="checked[option.enum[0]] ? true : null">\n {{option.description}}\n </label>\n </div>\n </ng-container>\n</div>'}]}],e}(pt),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-file-widget",template:'<div class="widget form-group">\n\t<label [attr.for]="id" class="horizontal control-label">\n\t\t{{ schema.title }}\n\t</label>\n <span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\n <input [name]="formProperty.name" class="text-widget file-widget" [attr.id]="id"\n type="file" [attr.disabled]="schema.readOnly?true:null"\n (change)="onFileChange($event)">\n\t<input *ngIf="schema.readOnly" [attr.name]="formProperty.name" type="hidden" [formControl]="fileName">\n</div>'}]}],e}(ut),Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-integer-widget",template:'<div class="widget form-group">\n\t<label [attr.for]="id" class="horizontal control-label">\n\t\t{{ schema.title }}\n\t</label>\n <span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\n\t<input [attr.readonly]="schema.readOnly?true:null" [name]="formProperty.name"\n\tclass="text-widget integer-widget form-control" [formControl]="formProperty"\n\t[attr.type]="\'number\'" [attr.min]="schema.minimum" [attr.max]="schema.maximum"\n\t[attr.placeholder]="schema.placeholder"\n\t[attr.maxLength]="schema.maxLength || null"\n [attr.minLength]="schema.minLength || null">\n</div>'}]}],e}(ft),Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-textarea-widget",template:'<div class="widget form-group">\n\t<label [attr.for]="id" class="horizontal control-label">\n\t\t{{ schema.title }}\n\t</label>\n <span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\n\t<textarea [attr.readonly]="schema.readOnly" [name]="formProperty.name"\n\t\tclass="text-widget textarea-widget form-control"\n\t\t[attr.placeholder]="schema.placeholder"\n\t\t[attr.maxLength]="schema.maxLength || null"\n [attr.minLength]="schema.minLength || null"\n\t\t[formControl]="formProperty"></textarea>\n</div>'}]}],e}(ht),It=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-radio-widget",template:'<div class="widget form-group">\n\t<label>{{schema.title}}</label>\n <span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\n\t<div *ngFor="let option of schema.oneOf" class="radio">\n\t\t<label class="horizontal control-label">\n\t\t\t<input [formControl]="formProperty" value="{{option.enum[0]}}" type="radio" [attr.disabled]="schema.readOnly">\n\t\t\t{{option.description}}\n\t\t</label>\n\t</div>\n\t<input *ngIf="schema.readOnly" type="hidden" [formControl]="formProperty">\n</div>'}]}],e}(dt),Vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-range-widget",template:'<div class="widget form-group">\n\t<label [attr.for]="id" class="horizontal control-label">\n\t\t{{ schema.title }}\n\t</label>\n <span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\t\n <input\n [name]="formProperty.name" class="text-widget range-widget"\n [attr.id]="id"\n [formControl]="formProperty"\n [attr.type]="\'range\'"\n [attr.min]="schema.minimum"\n [attr.max]="schema.maximum"\n [attr.disabled]="schema.readOnly?true:null" >\n\t<input *ngIf="schema.readOnly" [attr.name]="formProperty.name" type="hidden">\n</div>'}]}],e}(mt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-select-widget",template:'<div class="widget form-group">\n <label [attr.for]="id" class="horizontal control-label">\n {{ schema.title }}\n </label>\n\n <span *ngIf="schema.description" class="formHelp">\n {{schema.description}}\n </span>\n\n <select\n *ngIf="schema.type!=\'array\'"\n [formControl]="formProperty"\n [attr.disabled]="schema.readOnly"\n class="form-control">\n <option *ngFor="let option of schema.oneOf" [ngValue]="option.enum[0]" >\n {{option.description}}\n </option>\n </select>\n\n <select *ngIf="schema.type===\'array\'" multiple [formControl]="formProperty" [attr.disabled]="schema.readOnly" class="form-control">\n <option *ngFor="let option of schema.items.oneOf" [ngValue]="option.enum[0]" >{{option.description}}</option>\n </select>\n\n <input *ngIf="schema.readOnly" type="hidden" [formControl]="formProperty">\n</div>'}]}],e}(yt),xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-string-widget",template:'<input *ngIf="getInputType() === \'hidden\'; else notHiddenFieldBlock"\n [attr.name]="formProperty.name" type="hidden" [formControl]="formProperty">\n <ng-template #notHiddenFieldBlock>\n <div class="widget form-group">\n <label [attr.for]="id" class="horizontal control-label">\n {{ schema.title }}\n </label>\n <span *ngIf="schema.description" class="formHelp">{{schema.description}}</span>\n <input [name]="formProperty.name" [attr.readonly]="(id!==\'color\') && schema.readOnly?true:null"\n class="text-{{ id }} textline-widget form-control" [attr.type]="getInputType()"\n [attr.id]="id" [formControl]="formProperty" [attr.placeholder]="schema.placeholder"\n [attr.maxLength]="schema.maxLength || null"\n [attr.minLength]="schema.minLength || null"\n [attr.disabled]="(id==\'color\' && schema.readOnly)?true:null">\n <input *ngIf="(id===\'color\' && schema.readOnly)" [attr.name]="formProperty.name" type="hidden" [formControl]="formProperty">\n <span class="help-block" *ngFor="let message of errorMessages">{{ message }}</span>\n\n </div>\n </ng-template>\n '}]}],e}(gt),kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.decorators=[{type:a.Component,args:[{selector:"sf-form-fieldset",template:'\n <fieldset>\n <legend *ngIf="title">{{ title }}</legend>\n <div *ngIf="description">{{ description }}</div>\n <div *ngFor="let formProperty of formProperties">\n <sf-form-field [formProperty]="formProperty"> </sf-form-field>\n </div>\n </fieldset>\n '}]}],e}(vt),jt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.selectedTab=0,t}return w(t,e),t.decorators=[{type:a.Component,args:[{selector:"sf-form-tabs",template:'\n <div class="panel panel-default">\n <div class="panel-body" style="min-height: 420px;">\n <ul class="nav nav-tabs" style="margin-bottom: 10px">\n <li *ngFor="let tab of widget.tabs; let index=index"\n (click)="selectedTab = index"\n [class.active]="selectedTab === index"\n style="cursor: pointer">\n <a>{{ tab.title }}</a>\n </li>\n </ul>\n\n <div *ngFor="let tab of widget.tabs; let index=index" >\n <ng-container *ngIf="selectedTab === index">\n <div *ngFor="let field of tab.fields">\n <sf-form-field [formProperty]="formProperty.get(field)"> </sf-form-field>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n '}]}],t}(vt),St=function(e){function t(){var t=e.call(this)||this;return t.setDefaultWidget(kt,g.Fieldset),t.register("fieldset",kt,g.Fieldset),t.register("tabs",jt,g.Fieldset),t.setDefaultWidget(Pt,g.Button),t.register("button",Pt,g.Button),t.setDefaultWidget(xt),t.register("array",bt),t.register("object",wt),t.register("string",xt),t.register("search",xt),t.register("tel",xt),t.register("url",xt),t.register("email",xt),t.register("password",xt),t.register("color",xt),t.register("date",xt),t.register("date-time",xt),t.register("time",xt),t.register("integer",Rt),t.register("number",Rt),t.register("range",Vt),t.register("textarea",Ot),t.register("file",Ft),t.register("select",Et),t.register("radio",It),t.register("boolean",Ct),t.register("checkbox",Ct),t}return w(t,e),t}(v),Wt=function(){function t(){}return t.decorators=[{type:a.Component,args:[{selector:"sf-default-field",template:"<p>Unknow type</p>"}]}],t}(),Dt=[{provide:v,useClass:St},{provide:y,useClass:K}],At=function(){function t(){}return t.forRoot=function(){return{ngModule:t,providers:I(Dt)}},t.decorators=[{type:a.NgModule,args:[{imports:[e.CommonModule,r.FormsModule,r.ReactiveFormsModule],declarations:[U,Y,H,X,Q,Wt,bt,Pt,wt,Ct,Ft,Rt,Ot,It,Vt,Et,xt,kt,J,jt],entryComponents:[U,H,J,bt,Pt,wt,Ct,Ft,Rt,Ot,It,Vt,Et,xt,kt,jt],exports:[H,U,Y,J,X,bt,Pt,wt,Ct,Ft,Rt,Ot,It,Vt,Et,xt,kt,Q,jt]}]}],t}(),Bt=function(){function t(){this.changes=new a.EventEmitter}return t.prototype.changed=function(){this.changes.emit(!0)},t}(),Tt=function(){function t(){}return t.prototype.getTextContent=function(t){var e=Array.from(t.nativeElement.childNodes).filter(function(t){return t.nodeType===t.TEXT_NODE}).pop();return e&&e.nodeValue?e.nodeValue.trim():""},t}(),qt=function(r){function t(t){var e=r.call(this)||this;return e.elementRef=t,e.label="",e.options=new at,e.click=new a.EventEmitter,e.changes=new a.EventEmitter,e}return w(t,r),t.prototype.setLabelFromContent=function(){var t=this.getTextContent(this.elementRef);t&&!this.label&&(this.label=t)},t.prototype.ngOnChanges=function(t){(t.label||t.widget)&&this.changes.emit({label:this.label,widget:this.widget})},t.prototype.ngAfterContentInit=function(){this.setLabelFromContent()},t.decorators=[{type:a.Component,args:[{selector:"sf-button",template:"<ng-content></ng-content>\n"}]}],t.ctorParameters=function(){return[{type:a.ElementRef}]},t.propDecorators={id:[{type:a.Input}],label:[{type:a.Input}],options:[{type:a.Input}],widget:[{type:a.Input}],click:[{type:a.Output}]},t}(Tt),zt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="",t}return w(t,e),Object.defineProperty(t.prototype,"path",{get:function(){return this.name?"/"+this.name:""},enumerable:!0,configurable:!0}),t.prototype.getButtons=function(){var o=this;return this.childButtons.map(function(t,e){if(!t.id){var r=Math.random().toString(16).substr(2,8);t.id=o.name+r+"_"+(e+1)}o.actionRegistry.register(t.id,t.click.emit.bind(t.click)),o.templateRegistry.register(t.id,t,L);var n={id:t.id,label:t.label,options:t.options};return t.widget&&(n.widget=t.widget),n})},t.prototype.getFieldsValidators=function(t){return t.reduce(function(t,e){return t.concat(e.getValidators())},[])},t.prototype.getFieldsSchema=function(t){var n=this;return t.reduce(function(t,e){switch(n.type){case s:t.items=e.getSchema();break;default:t.properties||(t.properties={}),t.properties[e.name]=e.getSchema()}var r=e.getButtons();return 0<r.length&&(t.buttons=r),e.required&&(t.required||(t.required=[]),t.required.push(e.name)),t},{})},t}(Tt),_t=function(r){function t(t){var e=r.call(this)||this;return e.elementRef=t,e}return w(t,r),t.prototype.ngOnInit=function(){this.description=this.label},t.decorators=[{type:a.Component,args:[{selector:"sf-item",template:"<ng-content></ng-content>\n"}]}],t.ctorParameters=function(){return[{type:a.ElementRef}]},t.propDecorators={value:[{type:a.Input}],label:[{type:a.Input}]},t}(Tt),Lt=function(i){function t(t,e,r,n){var o=i.call(this)||this;return o.elementRef=t,o.templateSchemaService=e,o.templateRegistry=r,o.actionRegistry=n,o.schema={},o.changes=new a.EventEmitter,o}return w(t,i),t.prototype.getSchema=function(){var e=this,t=this.getFieldsSchema(this.childFields.filter(function(t){return t!==e})),r=t.properties,n=t.items,o=t.required,i=this.getOneOf(),s={type:!this.type&&r?p:this.type?this.type:c};this.title!==undefined&&(s.title=this.title),r!==undefined&&(s.properties=r),n!==undefined&&(s.items=n),o!==undefined&&(s.required=o),i!==undefined&&(s.oneOf=i),this.description!==undefined&&(s.description=this.description),this.placeholder!==undefined&&(s.placeholder=this.placeholder),this.format!==undefined&&(s.format=this.format),this.widget!==undefined&&(s.widget=this.widget),this.readOnly!==undefined&&(s.readOnly=this.readOnly);var a=this.getButtons();return 0<a.length&&(s.buttons=a),Object.assign(s,this.schema)},t.prototype.getValidators=function(){var n=this,t=this.getFieldsValidators(this.childFields.filter(function(t){return t!==n})).map(function(t){var e=t.path,r=t.validators;return{path:n.path+e,validators:r}});return this.validators&&t.push({path:this.path,validators:this.validators}),t},t.prototype.register=function(t){var e=this;void 0===t&&(t="");var r=t+this.path;this.templateRegistry.register(r,this),this.childFields.length&&this.childFields.forEach(function(t){t!==e&&t.register(r)})},t.prototype.ngOnChanges=function(t){if(t.type||t.name||t.format||t.validators)this.templateSchemaService.changed();else if(this.childFields){var e=this.getSchema();delete e.name,delete e.format,"string"==typeof e.widget?delete e.widget:e.widget&&e.width.id&&delete e.widget.id,this.changes.emit(e)}},t.prototype.getOneOf=function(){if(0!==this.childItems.length){var t=this.childItems.map(function(t){var e=t.value,r=t.description;return Array.isArray(e)?{"enum":e,description:r}:{"enum":[e],description:r}});if(0!==t.length)return t}},t.prototype.setTitleFromContent=function(){var t=this.getTextContent(this.elementRef);t&&!this.title&&(this.title=t)},t.prototype.ngAfterContentInit=function(){var t=this;this.setTitleFromContent(),u.merge(this.childFields.changes,this.childItems.changes,this.childButtons.changes).pipe(f.filter(function(t){return Boolean(t)})).subscribe(function(){t.templateSchemaService.changed()})},t.decorators=[{type:a.Component,args:[{selector:"sf-field",template:"<ng-content ></ng-content>\n"}]}],t.ctorParameters=function(){return[{type:a.ElementRef},{type:Bt},{type:M},{type:l}]},t.propDecorators={childFields:[{type:a.ContentChildren,args:[t]}],childItems:[{type:a.ContentChildren,args:[_t]}],childButtons:[{type:a.ContentChildren,args:[qt]}],name:[{type:a.Input}],type:[{type:a.Input}],format:[{type:a.Input}],required:[{type:a.Input}],readOnly:[{type:a.Input}],title:[{type:a.Input}],description:[{type:a.Input}],placeholder:[{type:a.Input}],widget:[{type:a.Input}],validators:[{type:a.Input}],schema:[{type:a.Input}]},t}(zt),Mt=function(s){function t(t,e,r,n,o){var i=s.call(this)||this;return i.formComponent=t,i.templateSchemaService=e,i.actionRegistry=r,i.validatorRegistry=n,i.templateRegistry=o,i}return w(t,s),t.prototype.setFormDocumentSchema=function(t){var n=this;this.actionRegistry.clear(),this.validatorRegistry.clear();var e=this.getFieldsSchema(t);this.templateRegistry.clear(),t.forEach(function(t){t.register()}),this.getFieldsValidators(t).forEach(function(t){var e=t.path,r=t.validators;n.validatorRegistry.register(e,r)});var r=this.formComponent.schema;this.formComponent.schema={type:p,properties:e.properties},this.fieldsets&&(this.formComponent.schema.fieldsets=this.fieldsets),e.required&&0<e.required.length&&(this.formComponent.schema.required=e.required);var o=this.getButtons();0<o.length&&(this.formComponent.schema.buttons=o),this.formComponent.ngOnChanges({schema:new a.SimpleChange(r,this.formComponent.schema,Boolean(r))})},t.prototype.ngAfterContentInit=function(){var t=this;0<this.childFields.length&&this.setFormDocumentSchema(this.childFields.toArray()),u.merge(this.childFields.changes,this.childButtons.changes,this.templateSchemaService.changes).pipe(f.filter(function(t){return Boolean(t)})).subscribe(function(){t.setFormDocumentSchema(t.childFields.toArray())})},t.decorators=[{type:a.Directive,args:[{selector:"sf-form[templateSchema]",providers:[Bt]}]}],t.ctorParameters=function(){return[{type:H},{type:Bt},{type:l},{type:i},{type:M}]},t.propDecorators={childFields:[{type:a.ContentChildren,args:[Lt]}],childButtons:[{type:a.ContentChildren,args:[qt]}],fieldsets:[{type:a.Input}]},t}(zt),Nt=function(){function t(){}return t.decorators=[{type:a.NgModule,args:[{imports:[e.CommonModule],declarations:[Mt,Lt,qt,_t],exports:[Mt,Lt,qt,_t],providers:[Bt]}]}],t}();t.FormComponent=H,t.FormElementComponent=U,t.FormButtonWidgetChooserDirective=Y,t.FormFieldComponent=J,t.FormFieldsetWidgetChooserDirective=Q,t.FormPropertyWidgetChooserDirective=X,t.WidgetRegistry=v,t.WidgetType=g,t.SchemaValidatorFactory=y,t.ZSchemaValidatorFactory=Z,t.AjvSchemaValidatorFactory=K,t.Widget=tt,t.PropertyWidget=nt,t.ArrayPropertyWidget=ot,t.ObjectPropertyWidget=it,t.FieldsetLayoutWidget=et,t.ArrayWidget=st,t.ButtonWidget=lt,t.ObjectWidget=ct,t.CheckboxWidget=pt,t.FileWidget=ut,t.IntegerWidget=ft,t.TextAreaWidget=ht,t.RadioWidget=dt,t.RangeWidget=mt,t.SelectWidget=yt,t.StringWidget=gt,t.FieldsetWidget=vt,t.ArrayComponent=bt,t.ButtonComponent=Pt,t.ObjectComponent=wt,t.CheckboxComponent=Ct,t.FileComponent=Ft,t.IntegerComponent=Rt,t.TextAreaComponent=Ot,t.RadioComponent=It,t.RangeComponent=Vt,t.SelectComponent=Et,t.StringComponent=xt,t.FieldsetComponent=kt,t.TabsComponent=jt,t.DefaultWidgetRegistry=St,t.SchemaFormModule=At,t.TemplateSchemaModule=Nt,t.ɵj=Wt,t.ɵb=$,t.ɵa=N,t.ɵd=l,t.ɵg=z,t.ɵe=i,t.ɵq=qt,t.ɵl=zt,t.ɵo=Lt,t.ɵp=_t,t.ɵm=Tt,t.ɵh=M,t.ɵk=Mt,t.ɵn=Bt,t.ɵi=G,t.ɵf=b,t.ɵc=rt,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-schema-forms.umd.min.js.map