Comparing version 0.15.1 to 0.16.0
@@ -0,1 +1,8 @@ | ||
# 0.16.0 | ||
- Internal reorganization that allows us to reuse a bit more code. | ||
- Remove antd support. We're maintaining this in a separate code base now | ||
(hopefully soon to be open source). | ||
# 0.15.1 | ||
@@ -2,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx"),require("mobx-state-tree")):"function"==typeof define&&define.amd?define(["mobx","mobx-state-tree"],t):"object"==typeof exports?exports.mstform=t(require("mobx"),require("mobx-state-tree")):e.mstform=t(e.mobx,e["mobx-state-tree"])}(window,function(e,t){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t,r){"use strict";r.r(t);var n={value:function(e){return{value:e.raw,onChange:function(t){return e.setRaw(t.target.value)}}},checked:function(e){return{checked:e.raw,onChange:function(t){return e.setRaw(t.target.checked)}}},object:function(e){return{value:e.raw,onChange:function(t){return e.setRaw(t)}}}},o=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},s=function(){return function(e){this.value=e}}(),a=function(){function e(e){this.definition=e,this.emptyRaw=e.emptyRaw,this.defaultControlled=e.defaultControlled?e.defaultControlled:n.object}return e.prototype.convert=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return this.definition.rawValidate?[4,this.definition.rawValidate(e)]:[3,2];case 1:if(!r.sent())return[2,"ConversionError"];r.label=2;case 2:return t=this.definition.convert(e),this.definition.validate?[4,this.definition.validate(t)]:[3,4];case 3:if(!r.sent())return[2,"ConversionError"];r.label=4;case 4:return[2,new s(t)]}})})},e.prototype.render=function(e){return this.definition.render(e)},e}(),u=r(0),c=r(1),p=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},l=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},d=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},f=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},h=function(){return{}};function y(e){h=e}var g=function(){function e(e,t,r,n,o){this.state=e,this.definition=t,this.parent=r,this.allowedKeys=o,this.fieldAccessors=u.observable.map(),this.repeatingFormAccessors=u.observable.map(),this.subFormAccessors=u.observable.map(),this.keys=null!=o?o:Object.keys(this.definition),this._addMode=n,this.initialize()}return e.prototype.validate=function(){return d(this,void 0,void 0,function(){var e;return f(this,function(t){switch(t.label){case 0:return e=this.accessors.map(function(e){return e.validate()}),[4,Promise.all(e)];case 1:return[2,t.sent().every(function(e){return e})]}})})},e.prototype.setError=function(e){},e.prototype.clearError=function(){},e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return null==this.parent?"":this.parent.path},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.accessors.every(function(e){return e.isValid})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){var e=this,t=[];return this.keys.forEach(function(r){var n=e.definition[r];n instanceof N?t.push(e.field(r)):n instanceof z?t.push(e.repeatingForm(r)):n instanceof D&&t.push(e.subForm(r))}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){var e=[];return this.accessors.forEach(function(t){t instanceof b?e.push(t):t instanceof v?(e.push.apply(e,t.flatAccessors),e.push(t)):t instanceof w&&(e.push.apply(e,t.flatAccessors),e.push(t))}),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return!!this._addMode||null!=this.parent&&this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){if(this.keys.includes(e))try{return this.field(e)}catch(t){try{return this.repeatingForm(e)}catch(t){try{return this.subForm(e)}catch(e){return}}}},e.prototype.accessBySteps=function(e){if(0===e.length)return this;var t=e[0],r=e.slice(1),n=this.access(t);return 0===r.length?n:void 0===n?n:n.accessBySteps(r)},e.prototype.initialize=function(){var e=this;this.keys.forEach(function(t){var r=e.definition[t];r instanceof N?e.createField(t,r):r instanceof z?e.createRepeatingForm(t,r):r instanceof D&&e.createSubForm(t,r)})},e.prototype.createField=function(e,t){var r=new b(this.state,t,this,e);this.fieldAccessors.set(e,r)},e.prototype.field=function(e){var t=this.fieldAccessors.get(e);if(null==t)throw new Error(e+" is not a Field");return t},e.prototype.createRepeatingForm=function(e,t){var r=new v(this.state,t,this,e);this.repeatingFormAccessors.set(e,r),r.initialize()},e.prototype.repeatingForm=function(e){var t=this.repeatingFormAccessors.get(e);if(null==t)throw new Error(e+" is not a RepeatingForm");return t},e.prototype.createSubForm=function(e,t){var r=new w(this.state,t.definition,this,e);this.subFormAccessors.set(e,r),r.initialize()},e.prototype.subForm=function(e){var t=this.subFormAccessors.get(e);if(null==t)throw new Error(e+" is not a SubForm");return t},e.prototype.repeatingField=function(e){},p([u.observable,l("design:type",Boolean)],e.prototype,"_addMode",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),e}(),b=function(){function e(e,t,r,n){var o=this;this.state=e,this.field=t,this.parent=r,this._isValidating=!1,this._addMode=!1,this.handleChange=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d(o,void 0,void 0,function(){var t,r;return f(this,function(n){switch(n.label){case 0:return r=(t=this.field).getRaw.apply(t,e),[4,this.setRaw(r)];case 1:return n.sent(),[2]}})})},this.handleFocus=function(e){null!=o.state.focusFunc&&o.state.focusFunc(e,o)},this.name=n,this.createDerivedReaction()}var t,r,n;return e.prototype.clear=function(){null!=this._disposer&&this._disposer()},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),e.prototype.setDisposer=function(e){this._disposer=e},e.prototype.createDerivedReaction=function(){var e=this,t=this.field.derivedFunc;if(null!=t&&null==this._disposer){var r=Object(u.reaction)(function(){return e.node?t(e.node):void 0},function(t){void 0!==t&&e.setRaw(e.field.render(t))});this._disposer=r}},Object.defineProperty(e.prototype,"node",{get:function(){try{return this.state.getValue(this.parent.path)}catch(e){return}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return void 0===this._raw&&(this._addMode||this.parent.addMode)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"raw",{get:function(){var e=this._raw;return void 0!==e?!Object(u.isObservable)(e)||e instanceof Array?Object(u.toJS)(e):e:this.addMode?this.field.converter.emptyRaw:this.field.render(this.value)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){if(this.addMode)throw new Error("Cannot access field in add mode until it has been set once");return this.state.getValue(this.path)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorValue",{get:function(){return this._error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canShowValidationMessages",{get:function(){if("rightAfter"===this.state.saveStatus)return!0;var e="before"===this.state.saveStatus?this.state.validationBeforeSave:this.state.validationAfterSave;return"immediate"===e||"no"!==e&&("blur"!==e&&"pause"!==e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this.canShowValidationMessages?this.errorValue:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValidating",{get:function(){return this._isValidating},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this.state.isDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hidden",{get:function(){return this.state.isHiddenFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readOnly",{get:function(){return this.state.isReadOnlyFunc(this)},enumerable:!0,configurable:!0}),e.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(e){switch(e.label){case 0:return[4,this.setRaw(this.raw)];case 1:return e.sent(),[2,this.isValid]}})})},Object.defineProperty(e.prototype,"isValid",{get:function(){return void 0===this.errorValue},enumerable:!0,configurable:!0}),e.prototype.setRaw=function(e){return d(this,void 0,void 0,function(){var t,r,n,o;return f(this,function(i){switch(i.label){case 0:"rightAfter"===this.state.saveStatus&&this.state.setSaveStatus("after"),this._raw=e,this.setValidating(!0),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.field.process(e)];case 2:return t=i.sent(),[3,4];case 3:return i.sent(),this.setError("Something went wrong"),this.setValidating(!1),[2];case 4:if(r=this._raw,!u.comparer.structural(r,e))return[2];if(this.setValidating(!1),t instanceof T)return this.setError(t.message),[2];if(this.clearError(),!(t instanceof q))throw new Error("Unknown process result");return"string"==typeof(n=this.state.extraValidationFunc(this,t.value))&&n&&this.setError(n),u.comparer.structural(this.value,t.value)?[2]:(this.state.setValueWithoutRawUpdate(this.path,t.value),null!=(o=this.field.changeFunc)&&o(this.node,t.value),[2])}})})},e.prototype.setRawFromValue=function(){var e=this.state.getValue(this.path);this._raw=this.field.render(e),this.validate()},e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},e.prototype.setValidating=function(e){this._isValidating=e},Object.defineProperty(e.prototype,"inputProps",{get:function(){var e=this.field.controlled(this);return e.disabled=this.disabled,this.readOnly&&(e.readOnly=this.readOnly),null!=this.state.focusFunc&&(e.onFocus=this.handleFocus),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validationProps",{get:function(){return h(this)},enumerable:!0,configurable:!0}),e.prototype.accessBySteps=function(e){throw new Error("Cannot step through field accessor")},p([u.observable,l("design:type",Object)],e.prototype,"_raw",void 0),p([u.observable,l("design:type",Object)],e.prototype,"_error",void 0),p([u.observable,l("design:type",Boolean)],e.prototype,"_isValidating",void 0),p([u.observable,l("design:type",Boolean)],e.prototype,"_addMode",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.action,l("design:type",Function),l("design:paramtypes",[Function]),l("design:returntype",void 0)],e.prototype,"setDisposer",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"node",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type","function"==typeof(t="undefined"!=typeof R&&R)&&t||Object),l("design:paramtypes",[])],e.prototype,"raw",null),p([u.computed,l("design:type","function"==typeof(r="undefined"!=typeof V&&V)&&r||Object),l("design:paramtypes",[])],e.prototype,"value",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"errorValue",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"canShowValidationMessages",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"error",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValidating",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"disabled",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"hidden",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"readOnly",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.action,l("design:type",Function),l("design:paramtypes",["function"==typeof(n="undefined"!=typeof R&&R)&&n||Object]),l("design:returntype",Promise)],e.prototype,"setRaw",null),p([u.action,l("design:type",Function),l("design:paramtypes",[String]),l("design:returntype",void 0)],e.prototype,"setError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"clearError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[Boolean]),l("design:returntype",void 0)],e.prototype,"setValidating",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"inputProps",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"validationProps",null),e}(),v=function(){function e(e,t,r,n){this.state=e,this.repeatingForm=t,this.parent=r,this.repeatingFormIndexedAccessors=u.observable.map(),this.name=n}return e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},e.prototype.validate=function(){return d(this,void 0,void 0,function(){var e,t,r,n;return f(this,function(o){switch(o.label){case 0:for(e=[],t=0,r=this.accessors;t<r.length;t++)n=r[t],e.push(n.validate());return[4,Promise.all(e)];case 1:return[2,o.sent().every(function(e){return e})]}})})},Object.defineProperty(e.prototype,"addMode",{get:function(){return this.parent.addMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.accessors.every(function(e){return e.isValid})},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){var e=this,t=0;this.state.getValue(this.path).forEach(function(){e.createFormIndexedAccessor(t),t++})},e.prototype.createFormIndexedAccessor=function(e){var t=new m(this.state,this.repeatingForm.definition,this,e);this.repeatingFormIndexedAccessors.set(e,t),t.initialize()},e.prototype.index=function(e){var t=this.repeatingFormIndexedAccessors.get(e);if(null==t)throw new Error(e+" is not a RepeatingFormIndexedAccessor");return t},Object.defineProperty(e.prototype,"disabled",{get:function(){return this.state.isRepeatingFormDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){for(var e=[],t=0;t<this.length;t++)e.push(this.index(t));return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){var e=[];return this.accessors.forEach(function(t){e.push.apply(e,t.flatAccessors)}),e},enumerable:!0,configurable:!0}),e.prototype.accessBySteps=function(e){var t=e[0],r=e.slice(1),n=parseInt(t,10);if(isNaN(n))throw new Error("Expected index of repeating form");return this.index(n).accessBySteps(r)},Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0}),e.prototype.insert=function(e,t){var r=this.path+"/"+e;Object(c.applyPatch)(this.state.node,[{op:"add",path:r,value:t}])},e.prototype.push=function(e){var t=Object(c.resolvePath)(this.state.node,this.path),r=this.path+"/"+t.length;Object(c.applyPatch)(this.state.node,[{op:"add",path:r,value:e}])},e.prototype.remove=function(e){var t=Object(c.resolvePath)(this.state.node,this.path).indexOf(e);if(-1===t)throw new Error("Cannot find node to remove.");Object(c.applyPatch)(this.state.node,[{op:"remove",path:this.path+"/"+t}])},e.prototype.removeIndex=function(e){var t=this.repeatingFormIndexedAccessors;if(t.delete(e)){var r=[],n=[];t.forEach(function(t,o){o<=e||(t.setIndex(o-1),r.push(o),n.push(t))}),this.executeRenumber(r,n)}},e.prototype.addIndex=function(e){var t=[],r=[];this.repeatingFormIndexedAccessors.forEach(function(n,o){o<e||(n.setIndex(o+1),t.push(o),r.push(n))}),this.executeRenumber(t,r),this.createFormIndexedAccessor(e)},e.prototype.executeRenumber=function(e,t){var r=this.repeatingFormIndexedAccessors;e.forEach(function(e){r.delete(e)}),t.forEach(function(e){r.set(e.index,e)})},Object.defineProperty(e.prototype,"length",{get:function(){return Object(c.resolvePath)(this.state.node,this.path).length},enumerable:!0,configurable:!0}),p([u.observable,l("design:type",Object)],e.prototype,"_error",void 0),p([u.observable,l("design:type",Map)],e.prototype,"repeatingFormIndexedAccessors",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.action,l("design:type",Function),l("design:paramtypes",[String]),l("design:returntype",void 0)],e.prototype,"setError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"clearError",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"disabled",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"error",null),e}(),m=function(){function e(e,t,r,n){this.state=e,this.definition=t,this.parent=r,this._addMode=!1,this.index=n,this.formAccessor=new g(e,t,this,!1)}return e.prototype.initialize=function(){this.formAccessor.initialize()},e.prototype.clear=function(){return this.formAccessor.flatAccessors.forEach(function(e){e.clear()}),this.parent.removeIndex(this.index)},e.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.formAccessor.validate()]})})},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.index},enumerable:!0,configurable:!0}),e.prototype.setIndex=function(e){this.index=e},e.prototype.setError=function(e){this._error=e},e.prototype.setAddMode=function(){this._addMode=!0},e.prototype.clearError=function(){this._error=void 0},Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return this._addMode||this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.accessBySteps=function(e){return 0===e.length?this:this.formAccessor.accessBySteps(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),p([u.observable,l("design:type",Object)],e.prototype,"_error",void 0),p([u.observable,l("design:type",Number)],e.prototype,"index",void 0),p([u.observable,l("design:type",Boolean)],e.prototype,"_addMode",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.action,l("design:type",Function),l("design:paramtypes",[Number]),l("design:returntype",void 0)],e.prototype,"setIndex",null),p([u.action,l("design:type",Function),l("design:paramtypes",[String]),l("design:returntype",void 0)],e.prototype,"setError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"setAddMode",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"clearError",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"error",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),e}(),w=function(){function e(e,t,r,n){this.state=e,this.definition=t,this.parent=r,this.name=n,this.name=n,this.formAccessor=new g(e,t,this,!1)}return e.prototype.initialize=function(){this.formAccessor.initialize()},e.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.formAccessor.validate()]})})},e.prototype.setError=function(e){},e.prototype.clearError=function(){},e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.accessBySteps=function(e){return 0===e.length?this:this.formAccessor.accessBySteps(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),e}();function F(e){return e}function O(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/")}function j(e){return Number.isInteger(parseInt(e,10))}function A(e,t){return function e(t,r){var n=r[0],o=r.slice(1);if(0===o.length)return t[n];var i=t[n];if(void 0===i)return;return e(i,o)}(e,O(t))}function P(e,t){return function e(t,r){var n=r[0],o=r.slice(1);0===o.length&&delete t[n];var i=t[n];if(void 0===i)return;e(i,o)}(e,O(t))}var E=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},x=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},S=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},_=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},B=function(){function e(e,t,r){var n=this;this.form=e,this.node=t,this.saveStatus="before",this.additionalErrorTree={},this.noRawUpdate=!1,Object(c.onPatch)(t,function(e){"remove"===e.op?n.removePath(e.path):"add"===e.op?n.addPath(e.path):"replace"===e.op&&n.replacePath(e.path)});var o=null!=r&&r.addMode||!1;if(this.formAccessor=new g(this,this.form.definition,null,o),this.formAccessor.initialize(),null==r)this.saveFunc=M,this.isDisabledFunc=function(){return!1},this.isHiddenFunc=function(){return!1},this.isReadOnlyFunc=function(){return!1},this.isRepeatingFormDisabledFunc=function(){return!1},this.extraValidationFunc=function(){return!1},this.validationBeforeSave="immediate",this.validationAfterSave="immediate",this.validationPauseDuration=0,this.focusFunc=null;else{this.saveFunc=r.save?r.save:M,this.isDisabledFunc=r.isDisabled?r.isDisabled:function(){return!1},this.isHiddenFunc=r.isHidden?r.isHidden:function(){return!1},this.isReadOnlyFunc=r.isReadOnly?r.isReadOnly:function(){return!1},this.isRepeatingFormDisabledFunc=r.isRepeatingFormDisabled?r.isRepeatingFormDisabled:function(){return!1},this.extraValidationFunc=r.extraValidation?r.extraValidation:function(){return!1};var i=r.validation||{};this.validationBeforeSave=i.beforeSave||"immediate",this.validationAfterSave=i.afterSave||"immediate",this.validationPauseDuration=i.pauseDuration||0,this.focusFunc=r.focus?r.focus:null}}return e.prototype.setSaveStatus=function(e){this.saveStatus=e},e.prototype.setValueWithoutRawUpdate=function(e,t){this.noRawUpdate=!0,Object(c.applyPatch)(this.node,[{op:"replace",path:e,value:t}]),this.noRawUpdate=!1},e.prototype.replacePath=function(e){if(!this.noRawUpdate){var t=this.accessByPath(e);void 0!==t&&t instanceof b&&t.setRawFromValue()}},e.prototype.removePath=function(e){var t;try{t=this.accessByPath(e)}catch(e){return}void 0!==t&&t instanceof m&&t.clear()},e.prototype.addPath=function(e){var t=O(e);if(0!==t.length){var r=parseInt(t[t.length-1],10);if(!isNaN(r)){var n=this.accessByPath(function(e){var t=e.join("/");return t.startsWith("/")?t:"/"+t}(t.slice(0,t.length-1)));if(void 0!==n&&n instanceof v){n.addIndex(r);var o=this.accessByPath(e);void 0!==o&&o instanceof m&&o.setAddMode()}}}},e.prototype.validate=function(){return S(this,void 0,void 0,function(){return _(this,function(e){return[2,this.formAccessor.validate()]})})},Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),e.prototype.save=function(){return S(this,void 0,void 0,function(){var e,t;return _(this,function(r){switch(r.label){case 0:return[4,this.validate()];case 1:return e=r.sent(),this.setSaveStatus("rightAfter"),e?[4,this.saveFunc(this.node)]:[2,!1];case 2:return null!=(t=r.sent())?(this.setErrors(t),[2,!1]):(this.clearErrors(),[2,!0])}})})},e.prototype.setErrors=function(e){var t=function(e){return JSON.parse(JSON.stringify(e))}(e);this.flatAccessors.map(function(r){var n=A(e,r.path);null!=n&&(r.setError(n),P(t,r.path))}),this.additionalErrorTree=t},e.prototype.clearErrors=function(){this.additionalErrorTree={},this.flatAccessors.map(function(e){e.clearError()})},e.prototype.getValue=function(e){return Object(c.resolvePath)(this.node,e)},e.prototype.getMstType=function(e){for(var t=O(e),r=this.form.model,n=0,o=t;n<o.length;n++){var i=o[n];j(i)?r=r.getChildType(i):r=r.getChildType(i)}return r},Object.defineProperty(e.prototype,"isValidating",{get:function(){return this.flatAccessors.some(function(e){return e instanceof b&&e.isValidating})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),e.prototype.accessByPath=function(e){var t=O(e);return this.accessBySteps(t)},e.prototype.accessBySteps=function(e){return this.formAccessor.accessBySteps(e)},e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},e.prototype.subForm=function(e){return this.formAccessor.subForm(e)},e.prototype.repeatingField=function(e){},e.prototype.additionalError=function(e){var t=this.additionalErrorTree[e];if("string"==typeof t)return t},Object.defineProperty(e.prototype,"additionalErrors",{get:function(){var e=this,t=[];return Object.keys(this.additionalErrorTree).forEach(function(r){var n=e.additionalErrorTree[r];"string"==typeof n&&t.push(n)}),t.sort(),t},enumerable:!0,configurable:!0}),E([u.observable,x("design:type",Object)],e.prototype,"additionalErrorTree",void 0),E([u.observable,x("design:type",String)],e.prototype,"saveStatus",void 0),E([u.action,x("design:type",Function),x("design:paramtypes",[String]),x("design:returntype",void 0)],e.prototype,"setSaveStatus",null),E([u.action,x("design:type",Function),x("design:paramtypes",[String,Object]),x("design:returntype",void 0)],e.prototype,"setValueWithoutRawUpdate",null),E([u.action,x("design:type",Function),x("design:paramtypes",[String]),x("design:returntype",void 0)],e.prototype,"replacePath",null),E([u.action,x("design:type",Function),x("design:paramtypes",[String]),x("design:returntype",void 0)],e.prototype,"removePath",null),E([u.action,x("design:type",Function),x("design:paramtypes",[String]),x("design:returntype",void 0)],e.prototype,"addPath",null),E([u.computed,x("design:type",Boolean),x("design:paramtypes",[])],e.prototype,"isValid",null),E([u.action,x("design:type",Function),x("design:paramtypes",[]),x("design:returntype",Promise)],e.prototype,"save",null),E([u.action,x("design:type",Function),x("design:paramtypes",[Object]),x("design:returntype",void 0)],e.prototype,"setErrors",null),E([u.action,x("design:type",Function),x("design:paramtypes",[]),x("design:returntype",void 0)],e.prototype,"clearErrors",null),E([u.computed,x("design:type",Boolean),x("design:paramtypes",[])],e.prototype,"isValidating",null),E([u.computed,x("design:type",Array),x("design:paramtypes",[])],e.prototype,"accessors",null),E([u.computed,x("design:type",Array),x("design:paramtypes",[])],e.prototype,"flatAccessors",null),E([u.computed,x("design:type",Array),x("design:paramtypes",[])],e.prototype,"additionalErrors",null),e}();function M(){return S(this,void 0,void 0,function(){return _(this,function(e){return console.warn("No mstform save function configured"),[2,null]})})}var C=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},k=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},I=function(){function e(e,t){this.model=e,this.definition=t}return Object.defineProperty(e.prototype,"FormStateType",{get:function(){throw new Error("For introspection")},enumerable:!0,configurable:!0}),e.prototype.state=function(e,t){return new B(this,e,t)},e}(),D=function(){return function(e){this.definition=e}}(),T=function(){return function(e){this.message=e}}(),q=function(){return function(e){this.value=e}}(),N=function(){function e(e,t){if(this.converter=e,this.options=t,t){if(this.rawValidators=t.rawValidators?t.rawValidators:[],this.validators=t.validators?t.validators:[],this.conversionError=t.conversionError||"Could not convert",this.requiredError=t.requiredError||"Required",this.required=t.required||!1,t.fromEvent){if(t.getRaw)throw new Error("Cannot have fromEvent and getRaw defined at same time");this.getRaw=function(e){return e.target.value}}else this.getRaw=t.getRaw||F;this.derivedFunc=t.derived,this.changeFunc=t.change,this.controlled=t.controlled||this.createDefaultControlled()}else this.rawValidators=[],this.validators=[],this.conversionError="Could not convert",this.requiredError="Required",this.required=!1,this.getRaw=F,this.controlled=this.createDefaultControlled()}return e.prototype.createDefaultControlled=function(){var e=this;return this.getRaw!==F?function(t){return{value:t.raw,onChange:function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return t.setRaw(e.getRaw.apply(e,r))}}}:this.converter.defaultControlled},Object.defineProperty(e.prototype,"RawType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ValueType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),e.prototype.process=function(e){return C(this,void 0,void 0,function(){var t,r,n,o,i,s;return k(this,function(a){switch(a.label){case 0:if(e===this.converter.emptyRaw&&this.required)return[2,new T(this.requiredError)];t=0,r=this.rawValidators,a.label=1;case 1:return t<r.length?[4,(0,r[t])(e)]:[3,4];case 2:if("string"==typeof(s=a.sent())&&s)return[2,new T(s)];a.label=3;case 3:return t++,[3,1];case 4:return[4,this.converter.convert(e)];case 5:if("ConversionError"===(n=a.sent()))return e===this.converter.emptyRaw?[2,new T(this.requiredError)]:[2,new T(this.conversionError)];o=0,i=this.validators,a.label=6;case 6:return o<i.length?[4,(0,i[o])(n.value)]:[3,9];case 7:if("string"==typeof(s=a.sent())&&s)return[2,new T(s)];a.label=8;case 8:return o++,[3,6];case 9:return[2,new q(n.value)]}})})},e.prototype.render=function(e){return this.converter.render(e)},e}(),z=function(){return function(e){this.definition=e}}(),U=function(){var e=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])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),W=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},G=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},H=new RegExp("^-?(0|[1-9]\\d*)(\\.\\d*)?$"),J=new RegExp("^-?(0|[1-9]\\d*)$"),$=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.defaultControlled=n.value,t}return U(t,e),t}(a),K=new $({emptyRaw:"",convert:function(e){return e},render:function(e){return e}}),L=new $({emptyRaw:"",rawValidate:function(e){return e.startsWith(".")&&(e="0"+e),H.test(e)},convert:function(e){return+e},render:function(e){return e.toString()}}),Q=new $({emptyRaw:"",rawValidate:function(e){return J.test(e)},convert:function(e){return+e},render:function(e){return e.toString()}}),X=new a({emptyRaw:!1,convert:function(e){return e},render:function(e){return e},defaultControlled:n.checked}),Y=function(){function e(e,t){this.maxWholeDigits=e,this.decimalPlaces=t,this.defaultControlled=n.value,this.emptyRaw="";var r=new RegExp("^-?(0|[1-9]\\d{0,"+(e-1)+"})(\\.\\d{0,"+t+"})?$");this.converter=new $({emptyRaw:"",rawValidate:function(e){return e.startsWith(".")&&(e="0"+e),r.test(e)},convert:function(e){return e},render:function(e){return e}})}return e.prototype.convert=function(e){return this.converter.convert(e)},e.prototype.render=function(e){return this.converter.render(e)},e.prototype.getRaw=function(e){return e},e}();var Z=new a({emptyRaw:[],convert:function(e){return u.observable.array(e)},render:function(e){return e.slice()}});var ee=function(){function e(e){this.converter=e,this.defaultControlled=n.value,this.emptyRaw=""}return e.prototype.convert=function(e){return W(this,void 0,void 0,function(){return G(this,function(t){return""===e.trim()?[2,new s(null)]:[2,this.converter.convert(e)]})})},e.prototype.render=function(e){return null===e?"":this.converter.render(e)},e}(),te=function(){function e(e){this.emptyRaw=null,this.defaultControlled=n.object}return e.prototype.convert=function(e){return W(this,void 0,void 0,function(){return G(this,function(t){return null===e?[2,"ConversionError"]:[2,new s(e)]})})},e.prototype.render=function(e){return e},e}();var re={string:K,number:L,integer:Q,decimal:function(e,t){return new Y(e,t)},boolean:X,stringArray:Z,maybe:function(e){return e instanceof $?new ee(e):new a({emptyRaw:null,convert:F,render:F,defaultControlled:n.object})},model:function(e){return new te(e)},object:new a({emptyRaw:null,convert:F,render:F})};var ne={validationProps:function(e){var t=e.error,r=e.isValidating;return t?{validateStatus:r?"validating":"error",help:t}:{validateStatus:r?"validating":""}}};r.d(t,"Form",function(){return I}),r.d(t,"SubForm",function(){return D}),r.d(t,"ValidationMessage",function(){return T}),r.d(t,"ProcessValue",function(){return q}),r.d(t,"Field",function(){return N}),r.d(t,"RepeatingForm",function(){return z}),r.d(t,"ConversionValue",function(){return s}),r.d(t,"CONVERSION_ERROR",function(){return"ConversionError"}),r.d(t,"Converter",function(){return a}),r.d(t,"StringConverter",function(){return $}),r.d(t,"converters",function(){return re}),r.d(t,"setupValidationProps",function(){return y}),r.d(t,"FormAccessor",function(){return g}),r.d(t,"FieldAccessor",function(){return b}),r.d(t,"RepeatingFormAccessor",function(){return v}),r.d(t,"RepeatingFormIndexedAccessor",function(){return m}),r.d(t,"SubFormAccessor",function(){return w}),r.d(t,"controlled",function(){return n}),r.d(t,"antd",function(){return ne}),r.d(t,"FormState",function(){return B})}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx"),require("mobx-state-tree")):"function"==typeof define&&define.amd?define(["mobx","mobx-state-tree"],t):"object"==typeof exports?exports.mstform=t(require("mobx"),require("mobx-state-tree")):e.mstform=t(e.mobx,e["mobx-state-tree"])}(window,function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";n.r(t);var r={value:function(e){return{value:e.raw,onChange:function(t){return e.setRaw(t.target.value)}}},checked:function(e){return{checked:e.raw,onChange:function(t){return e.setRaw(t.target.checked)}}},object:function(e){return{value:e.raw,onChange:function(t){return e.setRaw(t)}}}},o=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},a=function(){return function(e){this.value=e}}(),s=function(){function e(e){this.definition=e,this.emptyRaw=e.emptyRaw,this.defaultControlled=e.defaultControlled?e.defaultControlled:r.object}return e.prototype.convert=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return this.definition.rawValidate?[4,this.definition.rawValidate(e)]:[3,2];case 1:if(!n.sent())return[2,"ConversionError"];n.label=2;case 2:return t=this.definition.convert(e),this.definition.validate?[4,this.definition.validate(t)]:[3,4];case 3:if(!n.sent())return[2,"ConversionError"];n.label=4;case 4:return[2,new a(t)]}})})},e.prototype.render=function(e){return this.definition.render(e)},e}(),c=n(0),u=n(1);function p(e){return e}function l(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/")}function f(e){return Number.isInteger(parseInt(e,10))}function d(e,t){return function e(t,n){var r=n[0],o=n.slice(1);if(0===o.length)return t[r];var i=t[r];if(void 0===i)return;return e(i,o)}(e,l(t))}function y(e,t){return function e(t,n){var r=n[0],o=n.slice(1);0===o.length&&delete t[r];var i=t[r];if(void 0===i)return;e(i,o)}(e,l(t))}var h=function(){return{}};function b(e){h=e}var g=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},v=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},m=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},w=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},O=function(){function e(e,t,n,r){var o=this;this.state=e,this.field=t,this.parent=n,this._isValidating=!1,this._addMode=!1,this.handleChange=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return m(o,void 0,void 0,function(){var t,n;return w(this,function(r){switch(r.label){case 0:return n=(t=this.field).getRaw.apply(t,e),[4,this.setRaw(n)];case 1:return r.sent(),[2]}})})},this.handleFocus=function(e){null!=o.state.focusFunc&&o.state.focusFunc(e,o)},this.name=r,this.createDerivedReaction()}var t,n,r;return e.prototype.clear=function(){null!=this._disposer&&this._disposer()},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),e.prototype.setDisposer=function(e){this._disposer=e},e.prototype.createDerivedReaction=function(){var e=this,t=this.field.derivedFunc;if(null!=t&&null==this._disposer){var n=Object(c.reaction)(function(){return e.node?t(e.node):void 0},function(t){void 0!==t&&e.setRaw(e.field.render(t))});this._disposer=n}},Object.defineProperty(e.prototype,"node",{get:function(){try{return this.state.getValue(this.parent.path)}catch(e){return}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return void 0===this._raw&&(this._addMode||this.parent.addMode)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"raw",{get:function(){var e=this._raw;return void 0!==e?!Object(c.isObservable)(e)||e instanceof Array?Object(c.toJS)(e):e:this.addMode?this.field.converter.emptyRaw:this.field.render(this.value)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){if(this.addMode)throw new Error("Cannot access field in add mode until it has been set once");return this.state.getValue(this.path)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorValue",{get:function(){return this._error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canShowValidationMessages",{get:function(){if("rightAfter"===this.state.saveStatus)return!0;var e="before"===this.state.saveStatus?this.state.validationBeforeSave:this.state.validationAfterSave;return"immediate"===e||"no"!==e&&("blur"!==e&&"pause"!==e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this.canShowValidationMessages?this.errorValue:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValidating",{get:function(){return this._isValidating},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this.state.isDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hidden",{get:function(){return this.state.isHiddenFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readOnly",{get:function(){return this.state.isReadOnlyFunc(this)},enumerable:!0,configurable:!0}),e.prototype.validate=function(){return m(this,void 0,void 0,function(){return w(this,function(e){switch(e.label){case 0:return[4,this.setRaw(this.raw)];case 1:return e.sent(),[2,this.isValid]}})})},Object.defineProperty(e.prototype,"isValid",{get:function(){return void 0===this.errorValue},enumerable:!0,configurable:!0}),e.prototype.setRaw=function(e){return m(this,void 0,void 0,function(){var t,n,r,o;return w(this,function(i){switch(i.label){case 0:"rightAfter"===this.state.saveStatus&&this.state.setSaveStatus("after"),this._raw=e,this.setValidating(!0),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.field.process(e)];case 2:return t=i.sent(),[3,4];case 3:return i.sent(),this.setError("Something went wrong"),this.setValidating(!1),[2];case 4:if(n=this._raw,!c.comparer.structural(n,e))return[2];if(this.setValidating(!1),t instanceof oe)return this.setError(t.message),[2];if(this.clearError(),!(t instanceof ie))throw new Error("Unknown process result");return"string"==typeof(r=this.state.extraValidationFunc(this,t.value))&&r&&this.setError(r),c.comparer.structural(this.value,t.value)?[2]:(this.state.setValueWithoutRawUpdate(this.path,t.value),null!=(o=this.field.changeFunc)&&o(this.node,t.value),[2])}})})},e.prototype.setRawFromValue=function(){var e=this.state.getValue(this.path);this._raw=this.field.render(e),this.validate()},e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},e.prototype.setValidating=function(e){this._isValidating=e},Object.defineProperty(e.prototype,"inputProps",{get:function(){var e=this.field.controlled(this);return e.disabled=this.disabled,this.readOnly&&(e.readOnly=this.readOnly),null!=this.state.focusFunc&&(e.onFocus=this.handleFocus),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validationProps",{get:function(){return h(this)},enumerable:!0,configurable:!0}),e.prototype.accessBySteps=function(e){throw new Error("Cannot step through field accessor")},g([c.observable,v("design:type",Object)],e.prototype,"_raw",void 0),g([c.observable,v("design:type",Object)],e.prototype,"_error",void 0),g([c.observable,v("design:type",Boolean)],e.prototype,"_isValidating",void 0),g([c.observable,v("design:type",Boolean)],e.prototype,"_addMode",void 0),g([c.computed,v("design:type",String),v("design:paramtypes",[])],e.prototype,"path",null),g([c.action,v("design:type",Function),v("design:paramtypes",[Function]),v("design:returntype",void 0)],e.prototype,"setDisposer",null),g([c.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"node",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"addMode",null),g([c.computed,v("design:type","function"==typeof(t="undefined"!=typeof R&&R)&&t||Object),v("design:paramtypes",[])],e.prototype,"raw",null),g([c.computed,v("design:type","function"==typeof(n="undefined"!=typeof V&&V)&&n||Object),v("design:paramtypes",[])],e.prototype,"value",null),g([c.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"errorValue",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"canShowValidationMessages",null),g([c.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"error",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"isValidating",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"disabled",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"hidden",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"readOnly",null),g([c.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"isValid",null),g([c.action,v("design:type",Function),v("design:paramtypes",["function"==typeof(r="undefined"!=typeof R&&R)&&r||Object]),v("design:returntype",Promise)],e.prototype,"setRaw",null),g([c.action,v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",void 0)],e.prototype,"setError",null),g([c.action,v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",void 0)],e.prototype,"clearError",null),g([c.action,v("design:type",Function),v("design:paramtypes",[Boolean]),v("design:returntype",void 0)],e.prototype,"setValidating",null),g([c.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"inputProps",null),g([c.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"validationProps",null),e}(),j=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},P=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},F=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},x=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},E=function(){function e(){}return e.prototype.initialize=function(){this.formAccessor.initialize()},e.prototype.validate=function(){return F(this,void 0,void 0,function(){return x(this,function(e){return[2,this.formAccessor.validate()]})})},e.prototype.setError=function(e){this.formAccessor.setError(e)},e.prototype.clearError=function(){this.formAccessor.clearError()},Object.defineProperty(e.prototype,"error",{get:function(){return this.formAccessor.error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.accessBySteps=function(e){if(0===e.length){if(null==this.formAccessor.parent)throw new Error("Unknown parent");return this.formAccessor.parent}return this.formAccessor.accessBySteps(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},e.prototype.subForm=function(e){return this.formAccessor.subForm(e)},Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),j([c.action,P("design:type",Function),P("design:paramtypes",[String]),P("design:returntype",void 0)],e.prototype,"setError",null),j([c.action,P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",void 0)],e.prototype,"clearError",null),j([c.computed,P("design:type",Object),P("design:paramtypes",[])],e.prototype,"error",null),j([c.computed,P("design:type",Boolean),P("design:paramtypes",[])],e.prototype,"isValid",null),j([c.computed,P("design:type",Array),P("design:paramtypes",[])],e.prototype,"accessors",null),j([c.computed,P("design:type",Array),P("design:paramtypes",[])],e.prototype,"flatAccessors",null),e}(),S=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),A=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},_=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},k=function(e){function t(t,n,r,o){var i=e.call(this)||this;return i.state=t,i.definition=n,i.parent=r,i.name=o,i.name=o,i.formAccessor=new J(t,n,i,!1),i}return S(t,e),t.prototype.clear=function(){},Object.defineProperty(t.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"addMode",{get:function(){return this.parent.addMode},enumerable:!0,configurable:!0}),A([c.computed,_("design:type",String),_("design:paramtypes",[])],t.prototype,"path",null),A([c.computed,_("design:type",Boolean),_("design:paramtypes",[])],t.prototype,"addMode",null),t}(E),M=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),B=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},C=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},D=function(e){function t(t,n,r,o){var i=e.call(this)||this;return i.state=t,i.definition=n,i.parent=r,i._addMode=!1,i.index=o,i.formAccessor=new J(t,n,i,!1),i}return M(t,e),t.prototype.clear=function(){return this.formAccessor.flatAccessors.forEach(function(e){e.clear()}),this.parent.removeIndex(this.index)},Object.defineProperty(t.prototype,"path",{get:function(){return this.parent.path+"/"+this.index},enumerable:!0,configurable:!0}),t.prototype.setIndex=function(e){this.index=e},t.prototype.setAddMode=function(){this._addMode=!0},Object.defineProperty(t.prototype,"addMode",{get:function(){return this._addMode||this.parent.addMode},enumerable:!0,configurable:!0}),B([c.observable,C("design:type",Number)],t.prototype,"index",void 0),B([c.observable,C("design:type",Boolean)],t.prototype,"_addMode",void 0),B([c.computed,C("design:type",String),C("design:paramtypes",[])],t.prototype,"path",null),B([c.action,C("design:type",Function),C("design:paramtypes",[Number]),C("design:returntype",void 0)],t.prototype,"setIndex",null),B([c.action,C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",void 0)],t.prototype,"setAddMode",null),B([c.computed,C("design:type",Boolean),C("design:paramtypes",[])],t.prototype,"addMode",null),t}(E),I=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},T=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},q=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},N=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},z=function(){function e(e,t,n,r){this.state=e,this.repeatingForm=t,this.parent=n,this.repeatingFormIndexedAccessors=c.observable.map(),this.name=r}return e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},e.prototype.validate=function(){return q(this,void 0,void 0,function(){var e,t,n,r;return N(this,function(o){switch(o.label){case 0:for(e=[],t=0,n=this.accessors;t<n.length;t++)r=n[t],e.push(r.validate());return[4,Promise.all(e)];case 1:return[2,o.sent().every(function(e){return e})]}})})},Object.defineProperty(e.prototype,"addMode",{get:function(){return this.parent.addMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.accessors.every(function(e){return e.isValid})},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){var e=this,t=0;this.state.getValue(this.path).forEach(function(){e.createFormIndexedAccessor(t),t++})},e.prototype.createFormIndexedAccessor=function(e){var t=new D(this.state,this.repeatingForm.definition,this,e);this.repeatingFormIndexedAccessors.set(e,t),t.initialize()},e.prototype.index=function(e){var t=this.repeatingFormIndexedAccessors.get(e);if(null==t)throw new Error(e+" is not a RepeatingFormIndexedAccessor");return t},Object.defineProperty(e.prototype,"disabled",{get:function(){return this.state.isRepeatingFormDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){for(var e=[],t=0;t<this.length;t++)e.push(this.index(t));return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){var e=[];return this.accessors.forEach(function(t){e.push.apply(e,t.flatAccessors)}),e},enumerable:!0,configurable:!0}),e.prototype.accessBySteps=function(e){var t=e[0],n=e.slice(1),r=parseInt(t,10);if(isNaN(r))throw new Error("Expected index of repeating form");return this.index(r).accessBySteps(n)},Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0}),e.prototype.insert=function(e,t){var n=this.path+"/"+e;Object(u.applyPatch)(this.state.node,[{op:"add",path:n,value:t}])},e.prototype.push=function(e){var t=Object(u.resolvePath)(this.state.node,this.path),n=this.path+"/"+t.length;Object(u.applyPatch)(this.state.node,[{op:"add",path:n,value:e}])},e.prototype.remove=function(e){var t=Object(u.resolvePath)(this.state.node,this.path).indexOf(e);if(-1===t)throw new Error("Cannot find node to remove.");Object(u.applyPatch)(this.state.node,[{op:"remove",path:this.path+"/"+t}])},e.prototype.removeIndex=function(e){var t=this.repeatingFormIndexedAccessors;if(t.delete(e)){var n=[],r=[];t.forEach(function(t,o){o<=e||(t.setIndex(o-1),n.push(o),r.push(t))}),this.executeRenumber(n,r)}},e.prototype.addIndex=function(e){var t=[],n=[];this.repeatingFormIndexedAccessors.forEach(function(r,o){o<e||(r.setIndex(o+1),t.push(o),n.push(r))}),this.executeRenumber(t,n),this.createFormIndexedAccessor(e)},e.prototype.executeRenumber=function(e,t){var n=this.repeatingFormIndexedAccessors;e.forEach(function(e){n.delete(e)}),t.forEach(function(e){n.set(e.index,e)})},Object.defineProperty(e.prototype,"length",{get:function(){return Object(u.resolvePath)(this.state.node,this.path).length},enumerable:!0,configurable:!0}),I([c.observable,T("design:type",Object)],e.prototype,"_error",void 0),I([c.observable,T("design:type",Map)],e.prototype,"repeatingFormIndexedAccessors",void 0),I([c.computed,T("design:type",String),T("design:paramtypes",[])],e.prototype,"path",null),I([c.action,T("design:type",Function),T("design:paramtypes",[String]),T("design:returntype",void 0)],e.prototype,"setError",null),I([c.action,T("design:type",Function),T("design:paramtypes",[]),T("design:returntype",void 0)],e.prototype,"clearError",null),I([c.computed,T("design:type",Boolean),T("design:paramtypes",[])],e.prototype,"addMode",null),I([c.computed,T("design:type",Boolean),T("design:paramtypes",[])],e.prototype,"isValid",null),I([c.computed,T("design:type",Boolean),T("design:paramtypes",[])],e.prototype,"disabled",null),I([c.computed,T("design:type",Array),T("design:paramtypes",[])],e.prototype,"accessors",null),I([c.computed,T("design:type",Array),T("design:paramtypes",[])],e.prototype,"flatAccessors",null),I([c.computed,T("design:type",Object),T("design:paramtypes",[])],e.prototype,"error",null),e}(),U=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},G=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},W=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},H=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},J=function(){function e(e,t,n,r,o){this.state=e,this.definition=t,this.parent=n,this.allowedKeys=o,this.fieldAccessors=c.observable.map(),this.repeatingFormAccessors=c.observable.map(),this.subFormAccessors=c.observable.map(),this.keys=null!=o?o:Object.keys(this.definition),this._addMode=r,this.initialize()}return e.prototype.validate=function(){return W(this,void 0,void 0,function(){var e;return H(this,function(t){switch(t.label){case 0:return e=this.accessors.map(function(e){return e.validate()}),[4,Promise.all(e)];case 1:return[2,t.sent().every(function(e){return e})]}})})},e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return null==this.parent?"":this.parent.path},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this.error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.accessors.every(function(e){return e.isValid})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){var e=this,t=[];return this.keys.forEach(function(n){var r=e.definition[n];r instanceof ae?t.push(e.field(n)):r instanceof se?t.push(e.repeatingForm(n)):r instanceof re&&t.push(e.subForm(n))}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){var e=[];return this.accessors.forEach(function(t){t instanceof O?e.push(t):t instanceof z?(e.push.apply(e,t.flatAccessors),e.push(t)):t instanceof k&&(e.push.apply(e,t.flatAccessors),e.push(t))}),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return!!this._addMode||null!=this.parent&&this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){if(this.keys.includes(e))try{return this.field(e)}catch(t){try{return this.repeatingForm(e)}catch(t){try{return this.subForm(e)}catch(e){return}}}},e.prototype.accessBySteps=function(e){if(0===e.length)return this;var t=e[0],n=e.slice(1),r=this.access(t);return 0===n.length?r:void 0===r?r:r.accessBySteps(n)},e.prototype.initialize=function(){var e=this;this.keys.forEach(function(t){var n=e.definition[t];n instanceof ae?e.createField(t,n):n instanceof se?e.createRepeatingForm(t,n):n instanceof re&&e.createSubForm(t,n)})},e.prototype.createField=function(e,t){var n=new O(this.state,t,this,e);this.fieldAccessors.set(e,n)},e.prototype.field=function(e){var t=this.fieldAccessors.get(e);if(null==t)throw new Error(e+" is not a Field");return t},e.prototype.createRepeatingForm=function(e,t){var n=new z(this.state,t,this,e);this.repeatingFormAccessors.set(e,n),n.initialize()},e.prototype.repeatingForm=function(e){var t=this.repeatingFormAccessors.get(e);if(null==t)throw new Error(e+" is not a RepeatingForm");return t},e.prototype.createSubForm=function(e,t){var n=new k(this.state,t.definition,this,e);this.subFormAccessors.set(e,n),n.initialize()},e.prototype.subForm=function(e){var t=this.subFormAccessors.get(e);if(null==t)throw new Error(e+" is not a SubForm");return t},e.prototype.repeatingField=function(e){},U([c.observable,G("design:type",Object)],e.prototype,"_error",void 0),U([c.observable,G("design:type",Boolean)],e.prototype,"_addMode",void 0),U([c.action,G("design:type",Function),G("design:paramtypes",[String]),G("design:returntype",void 0)],e.prototype,"setError",null),U([c.action,G("design:type",Function),G("design:paramtypes",[]),G("design:returntype",void 0)],e.prototype,"clearError",null),U([c.computed,G("design:type",String),G("design:paramtypes",[])],e.prototype,"path",null),U([c.computed,G("design:type",Object),G("design:paramtypes",[])],e.prototype,"error",null),U([c.computed,G("design:type",Boolean),G("design:paramtypes",[])],e.prototype,"isValid",null),U([c.computed,G("design:type",Array),G("design:paramtypes",[])],e.prototype,"accessors",null),U([c.computed,G("design:type",Array),G("design:paramtypes",[])],e.prototype,"flatAccessors",null),U([c.computed,G("design:type",Boolean),G("design:paramtypes",[])],e.prototype,"addMode",null),e}(),$=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),K=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},L=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Q=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},X=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Y=function(e){function t(t,n,r){var o=e.call(this)||this;o.form=t,o.node=n,o.saveStatus="before",o.additionalErrorTree={},o.noRawUpdate=!1,Object(u.onPatch)(n,function(e){"remove"===e.op?o.removePath(e.path):"add"===e.op?o.addPath(e.path):"replace"===e.op&&o.replacePath(e.path)});var i=null!=r&&r.addMode||!1;if(o.formAccessor=new J(o,o.form.definition,null,i),o.formAccessor.initialize(),null==r)o.saveFunc=Z,o.isDisabledFunc=function(){return!1},o.isHiddenFunc=function(){return!1},o.isReadOnlyFunc=function(){return!1},o.isRepeatingFormDisabledFunc=function(){return!1},o.extraValidationFunc=function(){return!1},o.validationBeforeSave="immediate",o.validationAfterSave="immediate",o.validationPauseDuration=0,o.focusFunc=null;else{o.saveFunc=r.save?r.save:Z,o.isDisabledFunc=r.isDisabled?r.isDisabled:function(){return!1},o.isHiddenFunc=r.isHidden?r.isHidden:function(){return!1},o.isReadOnlyFunc=r.isReadOnly?r.isReadOnly:function(){return!1},o.isRepeatingFormDisabledFunc=r.isRepeatingFormDisabled?r.isRepeatingFormDisabled:function(){return!1},o.extraValidationFunc=r.extraValidation?r.extraValidation:function(){return!1};var a=r.validation||{};o.validationBeforeSave=a.beforeSave||"immediate",o.validationAfterSave=a.afterSave||"immediate",o.validationPauseDuration=a.pauseDuration||0,o.focusFunc=r.focus?r.focus:null}return o}return $(t,e),t.prototype.setSaveStatus=function(e){this.saveStatus=e},t.prototype.setValueWithoutRawUpdate=function(e,t){this.noRawUpdate=!0,Object(u.applyPatch)(this.node,[{op:"replace",path:e,value:t}]),this.noRawUpdate=!1},t.prototype.replacePath=function(e){if(!this.noRawUpdate){var t=this.accessByPath(e);void 0!==t&&t instanceof O&&t.setRawFromValue()}},t.prototype.removePath=function(e){var t;try{t=this.accessByPath(e)}catch(e){return}void 0!==t&&t instanceof D&&t.clear()},t.prototype.addPath=function(e){var t=l(e);if(0!==t.length){var n=parseInt(t[t.length-1],10);if(!isNaN(n)){var r=this.accessByPath(function(e){var t=e.join("/");return t.startsWith("/")?t:"/"+t}(t.slice(0,t.length-1)));if(void 0!==r&&r instanceof z){r.addIndex(n);var o=this.accessByPath(e);void 0!==o&&o instanceof D&&o.setAddMode()}}}},t.prototype.save=function(){return Q(this,void 0,void 0,function(){var e,t;return X(this,function(n){switch(n.label){case 0:return[4,this.validate()];case 1:return e=n.sent(),this.setSaveStatus("rightAfter"),e?[4,this.saveFunc(this.node)]:[2,!1];case 2:return null!=(t=n.sent())?(this.setErrors(t),[2,!1]):(this.clearErrors(),[2,!0])}})})},t.prototype.setErrors=function(e){var t=function(e){return JSON.parse(JSON.stringify(e))}(e);this.flatAccessors.map(function(n){var r=d(e,n.path);null!=r&&(n.setError(r),y(t,n.path))}),this.additionalErrorTree=t},t.prototype.clearErrors=function(){this.additionalErrorTree={},this.flatAccessors.map(function(e){e.clearError()})},t.prototype.getValue=function(e){return Object(u.resolvePath)(this.node,e)},t.prototype.getMstType=function(e){for(var t=l(e),n=this.form.model,r=0,o=t;r<o.length;r++){var i=o[r];f(i)?n=n.getChildType(i):n=n.getChildType(i)}return n},Object.defineProperty(t.prototype,"isValidating",{get:function(){return this.flatAccessors.some(function(e){return e instanceof O&&e.isValidating})},enumerable:!0,configurable:!0}),t.prototype.accessByPath=function(e){var t=l(e);return this.accessBySteps(t)},t.prototype.accessBySteps=function(e){return this.formAccessor.accessBySteps(e)},t.prototype.additionalError=function(e){var t=this.additionalErrorTree[e];if("string"==typeof t)return t},Object.defineProperty(t.prototype,"additionalErrors",{get:function(){var e=this,t=[];return Object.keys(this.additionalErrorTree).forEach(function(n){var r=e.additionalErrorTree[n];"string"==typeof r&&t.push(r)}),t.sort(),t},enumerable:!0,configurable:!0}),K([c.observable,L("design:type",Object)],t.prototype,"additionalErrorTree",void 0),K([c.observable,L("design:type",String)],t.prototype,"saveStatus",void 0),K([c.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"setSaveStatus",null),K([c.action,L("design:type",Function),L("design:paramtypes",[String,Object]),L("design:returntype",void 0)],t.prototype,"setValueWithoutRawUpdate",null),K([c.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"replacePath",null),K([c.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"removePath",null),K([c.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"addPath",null),K([c.action,L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Promise)],t.prototype,"save",null),K([c.action,L("design:type",Function),L("design:paramtypes",[Object]),L("design:returntype",void 0)],t.prototype,"setErrors",null),K([c.action,L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",void 0)],t.prototype,"clearErrors",null),K([c.computed,L("design:type",Boolean),L("design:paramtypes",[])],t.prototype,"isValidating",null),K([c.computed,L("design:type",Array),L("design:paramtypes",[])],t.prototype,"additionalErrors",null),t}(E);function Z(){return Q(this,void 0,void 0,function(){return X(this,function(e){return console.warn("No mstform save function configured"),[2,null]})})}var ee=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},te=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},ne=function(){function e(e,t){this.model=e,this.definition=t}return Object.defineProperty(e.prototype,"FormStateType",{get:function(){throw new Error("For introspection")},enumerable:!0,configurable:!0}),e.prototype.state=function(e,t){return new Y(this,e,t)},e}(),re=function(){return function(e){this.definition=e}}(),oe=function(){return function(e){this.message=e}}(),ie=function(){return function(e){this.value=e}}(),ae=function(){function e(e,t){if(this.converter=e,this.options=t,t){if(this.rawValidators=t.rawValidators?t.rawValidators:[],this.validators=t.validators?t.validators:[],this.conversionError=t.conversionError||"Could not convert",this.requiredError=t.requiredError||"Required",this.required=t.required||!1,t.fromEvent){if(t.getRaw)throw new Error("Cannot have fromEvent and getRaw defined at same time");this.getRaw=function(e){return e.target.value}}else this.getRaw=t.getRaw||p;this.derivedFunc=t.derived,this.changeFunc=t.change,this.controlled=t.controlled||this.createDefaultControlled()}else this.rawValidators=[],this.validators=[],this.conversionError="Could not convert",this.requiredError="Required",this.required=!1,this.getRaw=p,this.controlled=this.createDefaultControlled()}return e.prototype.createDefaultControlled=function(){var e=this;return this.getRaw!==p?function(t){return{value:t.raw,onChange:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.setRaw(e.getRaw.apply(e,n))}}}:this.converter.defaultControlled},Object.defineProperty(e.prototype,"RawType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ValueType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),e.prototype.process=function(e){return ee(this,void 0,void 0,function(){var t,n,r,o,i,a;return te(this,function(s){switch(s.label){case 0:if(e===this.converter.emptyRaw&&this.required)return[2,new oe(this.requiredError)];t=0,n=this.rawValidators,s.label=1;case 1:return t<n.length?[4,(0,n[t])(e)]:[3,4];case 2:if("string"==typeof(a=s.sent())&&a)return[2,new oe(a)];s.label=3;case 3:return t++,[3,1];case 4:return[4,this.converter.convert(e)];case 5:if("ConversionError"===(r=s.sent()))return e===this.converter.emptyRaw?[2,new oe(this.requiredError)]:[2,new oe(this.conversionError)];o=0,i=this.validators,s.label=6;case 6:return o<i.length?[4,(0,i[o])(r.value)]:[3,9];case 7:if("string"==typeof(a=s.sent())&&a)return[2,new oe(a)];s.label=8;case 8:return o++,[3,6];case 9:return[2,new ie(r.value)]}})})},e.prototype.render=function(e){return this.converter.render(e)},e}(),se=function(){return function(e){this.definition=e}}(),ce=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ue=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},pe=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},le=new RegExp("^-?(0|[1-9]\\d*)(\\.\\d*)?$"),fe=new RegExp("^-?(0|[1-9]\\d*)$"),de=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.defaultControlled=r.value,t}return ce(t,e),t}(s),ye=new de({emptyRaw:"",convert:function(e){return e},render:function(e){return e}}),he=new de({emptyRaw:"",rawValidate:function(e){return e.startsWith(".")&&(e="0"+e),le.test(e)},convert:function(e){return+e},render:function(e){return e.toString()}}),be=new de({emptyRaw:"",rawValidate:function(e){return fe.test(e)},convert:function(e){return+e},render:function(e){return e.toString()}}),ge=new s({emptyRaw:!1,convert:function(e){return e},render:function(e){return e},defaultControlled:r.checked}),ve=function(){function e(e,t){this.maxWholeDigits=e,this.decimalPlaces=t,this.defaultControlled=r.value,this.emptyRaw="";var n=new RegExp("^-?(0|[1-9]\\d{0,"+(e-1)+"})(\\.\\d{0,"+t+"})?$");this.converter=new de({emptyRaw:"",rawValidate:function(e){return e.startsWith(".")&&(e="0"+e),n.test(e)},convert:function(e){return e},render:function(e){return e}})}return e.prototype.convert=function(e){return this.converter.convert(e)},e.prototype.render=function(e){return this.converter.render(e)},e.prototype.getRaw=function(e){return e},e}();var me=new s({emptyRaw:[],convert:function(e){return c.observable.array(e)},render:function(e){return e.slice()}});var we=function(){function e(e){this.converter=e,this.defaultControlled=r.value,this.emptyRaw=""}return e.prototype.convert=function(e){return ue(this,void 0,void 0,function(){return pe(this,function(t){return""===e.trim()?[2,new a(null)]:[2,this.converter.convert(e)]})})},e.prototype.render=function(e){return null===e?"":this.converter.render(e)},e}(),Oe=function(){function e(e){this.emptyRaw=null,this.defaultControlled=r.object}return e.prototype.convert=function(e){return ue(this,void 0,void 0,function(){return pe(this,function(t){return null===e?[2,"ConversionError"]:[2,new a(e)]})})},e.prototype.render=function(e){return e},e}();var je={string:ye,number:he,integer:be,decimal:function(e,t){return new ve(e,t)},boolean:ge,stringArray:me,maybe:function(e){return e instanceof de?new we(e):new s({emptyRaw:null,convert:p,render:p,defaultControlled:r.object})},model:function(e){return new Oe(e)},object:new s({emptyRaw:null,convert:p,render:p})};n.d(t,"Form",function(){return ne}),n.d(t,"SubForm",function(){return re}),n.d(t,"ValidationMessage",function(){return oe}),n.d(t,"ProcessValue",function(){return ie}),n.d(t,"Field",function(){return ae}),n.d(t,"RepeatingForm",function(){return se}),n.d(t,"ConversionValue",function(){return a}),n.d(t,"CONVERSION_ERROR",function(){return"ConversionError"}),n.d(t,"Converter",function(){return s}),n.d(t,"StringConverter",function(){return de}),n.d(t,"converters",function(){return je}),n.d(t,"FieldAccessor",function(){return O}),n.d(t,"FormAccessor",function(){return J}),n.d(t,"RepeatingFormAccessor",function(){return z}),n.d(t,"RepeatingFormIndexedAccessor",function(){return D}),n.d(t,"SubFormAccessor",function(){return k}),n.d(t,"currentValidationProps",function(){return h}),n.d(t,"setupValidationProps",function(){return b}),n.d(t,"controlled",function(){return r}),n.d(t,"FormState",function(){return Y})}])}); | ||
//# sourceMappingURL=mstform.js.map |
@@ -1,16 +0,7 @@ | ||
import { IReactionDisposer } from "mobx"; | ||
import { SubForm, ArrayEntryType, Field, FormDefinition, RepeatingFormDefinitionType, SubFormDefinitionType, RawType, RepeatingForm, ValidationResponse } from "./form"; | ||
import { FormState } from "./state"; | ||
export interface FieldAccessorAllows { | ||
(fieldAccessor: FieldAccessor<any, any, any>): boolean; | ||
} | ||
export interface ExtraValidation { | ||
(fieldAccessor: FieldAccessor<any, any, any>, value: any): ValidationResponse; | ||
} | ||
export interface RepeatingFormAccessorAllows { | ||
(repeatingFormAccessor: RepeatingFormAccessor<any, any>): boolean; | ||
} | ||
export interface ValidationProps { | ||
(accessor: FieldAccessor<any, any, any>): object; | ||
} | ||
import { ArrayEntryType, FormDefinition, RepeatingFormDefinitionType, SubFormDefinitionType, RawType } from "./form"; | ||
import { FieldAccessor } from "./field-accessor"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { RepeatingFormAccessor } from "./repeating-form-accessor"; | ||
import { RepeatingFormIndexedAccessor } from "./repeating-form-indexed-accessor"; | ||
import { SubFormAccessor } from "./sub-form-accessor"; | ||
export declare type Accessor = FormAccessor<any, any> | FieldAccessor<any, any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | SubFormAccessor<any, any>; | ||
@@ -20,161 +11,1 @@ export declare type FieldAccess<M, D extends FormDefinition<M>, K extends keyof M> = FieldAccessor<M, RawType<D[K]>, M[K]>; | ||
export declare type SubFormAccess<M, D extends FormDefinition<M>, K extends keyof M> = SubFormAccessor<M[K], SubFormDefinitionType<D[K]>>; | ||
export interface IFormAccessor<M, D extends FormDefinition<M>> { | ||
validate(): Promise<boolean>; | ||
isValid: boolean; | ||
field<K extends keyof M>(name: K): FieldAccess<M, D, K>; | ||
repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>; | ||
access(name: string): Accessor | undefined; | ||
accessors: Accessor[]; | ||
flatAccessors: Accessor[]; | ||
} | ||
export declare function setupValidationProps(validationProps: ValidationProps): void; | ||
export declare class FormAccessor<M, D extends FormDefinition<M>> implements IFormAccessor<M, D> { | ||
state: FormState<M, D>; | ||
definition: any; | ||
parent: FormAccessor<any, any> | SubFormAccessor<any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | null; | ||
allowedKeys?: string[] | undefined; | ||
private keys; | ||
fieldAccessors: Map<keyof M, FieldAccessor<any, any, any>>; | ||
repeatingFormAccessors: Map<keyof M, RepeatingFormAccessor<any, any>>; | ||
subFormAccessors: Map<keyof M, SubFormAccessor<any, any>>; | ||
_addMode: boolean; | ||
constructor(state: FormState<M, D>, definition: any, parent: FormAccessor<any, any> | SubFormAccessor<any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | null, addMode: boolean, allowedKeys?: string[] | undefined); | ||
validate(): Promise<boolean>; | ||
setError(error: string): void; | ||
clearError(): void; | ||
clear(): void; | ||
readonly path: string; | ||
readonly isValid: boolean; | ||
readonly accessors: Accessor[]; | ||
readonly flatAccessors: Accessor[]; | ||
readonly addMode: boolean; | ||
access(name: string): Accessor | undefined; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
initialize(): void; | ||
createField<K extends keyof M>(name: K, field: Field<any, any>): void; | ||
field<K extends keyof M>(name: K): FieldAccess<M, D, K>; | ||
createRepeatingForm<K extends keyof M>(name: K, repeatingForm: RepeatingForm<any, any>): void; | ||
repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>; | ||
createSubForm<K extends keyof M>(name: K, subForm: SubForm<any, any>): void; | ||
subForm<K extends keyof M>(name: K): SubFormAccess<M, D, K>; | ||
repeatingField(name: string): any; | ||
} | ||
export declare class FieldAccessor<M, R, V> { | ||
state: FormState<any, any>; | ||
field: Field<R, V>; | ||
parent: FormAccessor<any, any>; | ||
name: string; | ||
_raw: R | undefined; | ||
_error: string | undefined; | ||
_isValidating: boolean; | ||
_addMode: boolean; | ||
_disposer: IReactionDisposer | undefined; | ||
constructor(state: FormState<any, any>, field: Field<R, V>, parent: FormAccessor<any, any>, name: string); | ||
clear(): void; | ||
readonly path: string; | ||
setDisposer(disposer: IReactionDisposer): void; | ||
createDerivedReaction(): void; | ||
readonly node: M | undefined; | ||
readonly addMode: boolean; | ||
readonly raw: R; | ||
readonly value: V; | ||
readonly errorValue: string | undefined; | ||
readonly canShowValidationMessages: boolean; | ||
readonly error: string | undefined; | ||
readonly isValidating: boolean; | ||
readonly disabled: boolean; | ||
readonly hidden: boolean; | ||
readonly readOnly: boolean; | ||
validate(): Promise<boolean>; | ||
readonly isValid: boolean; | ||
setRaw(raw: R): Promise<void>; | ||
setRawFromValue(): void; | ||
setError(error: string): void; | ||
clearError(): void; | ||
setValidating(flag: boolean): void; | ||
handleChange: (...args: any[]) => Promise<void>; | ||
handleFocus: (event: any) => void; | ||
readonly inputProps: any; | ||
readonly validationProps: object; | ||
accessBySteps(steps: string[]): Accessor; | ||
} | ||
export declare class RepeatingFormAccessor<M, D extends FormDefinition<M>> { | ||
state: FormState<any, any>; | ||
repeatingForm: RepeatingForm<M, D>; | ||
parent: FormAccessor<any, any>; | ||
name: string; | ||
_error: string | undefined; | ||
repeatingFormIndexedAccessors: Map<number, RepeatingFormIndexedAccessor<any, any>>; | ||
constructor(state: FormState<any, any>, repeatingForm: RepeatingForm<M, D>, parent: FormAccessor<any, any>, name: string); | ||
clear(): void; | ||
readonly path: string; | ||
setError(error: string): void; | ||
clearError(): void; | ||
validate(): Promise<boolean>; | ||
readonly addMode: boolean; | ||
readonly isValid: boolean; | ||
initialize(): void; | ||
createFormIndexedAccessor(index: number): void; | ||
index(index: number): RepeatingFormIndexedAccessor<M, D>; | ||
readonly disabled: boolean; | ||
readonly accessors: RepeatingFormIndexedAccessor<M, D>[]; | ||
readonly flatAccessors: Accessor[]; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
readonly error: string | undefined; | ||
insert(index: number, node: any): void; | ||
push(node: any): void; | ||
remove(node: any): void; | ||
removeIndex(index: number): void; | ||
addIndex(index: number): void; | ||
private executeRenumber; | ||
readonly length: number; | ||
} | ||
export declare class RepeatingFormIndexedAccessor<M, D extends FormDefinition<M>> implements IFormAccessor<M, D> { | ||
state: FormState<any, any>; | ||
definition: any; | ||
parent: RepeatingFormAccessor<any, any>; | ||
formAccessor: FormAccessor<M, D>; | ||
_error: string | undefined; | ||
index: number; | ||
_addMode: boolean; | ||
constructor(state: FormState<any, any>, definition: any, parent: RepeatingFormAccessor<any, any>, index: number); | ||
initialize(): void; | ||
clear(): void; | ||
validate(): Promise<boolean>; | ||
readonly path: string; | ||
setIndex(index: number): void; | ||
setError(error: string): void; | ||
setAddMode(): void; | ||
clearError(): void; | ||
readonly error: string | undefined; | ||
readonly isValid: boolean; | ||
readonly addMode: boolean; | ||
access(name: string): Accessor | undefined; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
field<K extends keyof M>(name: K): FieldAccess<M, D, K>; | ||
repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>; | ||
readonly accessors: Accessor[]; | ||
readonly flatAccessors: Accessor[]; | ||
} | ||
export declare class SubFormAccessor<M, D extends FormDefinition<M>> implements IFormAccessor<M, D> { | ||
state: FormState<any, any>; | ||
definition: any; | ||
parent: FormAccessor<any, any>; | ||
name: string; | ||
formAccessor: FormAccessor<M, D>; | ||
constructor(state: FormState<any, any>, definition: any, parent: FormAccessor<any, any>, name: string); | ||
initialize(): void; | ||
validate(): Promise<boolean>; | ||
setError(error: string): void; | ||
clearError(): void; | ||
clear(): void; | ||
readonly path: string; | ||
readonly isValid: boolean; | ||
readonly addMode: boolean; | ||
access(name: string): Accessor | undefined; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
field<K extends keyof M>(name: K): FieldAccess<M, D, K>; | ||
repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>; | ||
readonly accessors: Accessor[]; | ||
readonly flatAccessors: Accessor[]; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { FieldAccessor } from "./accessor"; | ||
import { FieldAccessor } from "./field-accessor"; | ||
export interface Controlled { | ||
@@ -3,0 +3,0 @@ (accessor: FieldAccessor<any, any, any>): any; |
@@ -5,4 +5,9 @@ export * from "./form"; | ||
export * from "./accessor"; | ||
export * from "./field-accessor"; | ||
export * from "./form-accessor"; | ||
export * from "./repeating-form-accessor"; | ||
export * from "./repeating-form-indexed-accessor"; | ||
export * from "./sub-form-accessor"; | ||
export * from "./validation-props"; | ||
export * from "./controlled"; | ||
export * from "./antd"; | ||
export * from "./state"; |
import { IType } from "mobx-state-tree"; | ||
import { Accessor, ExtraValidation, FieldAccess, FieldAccessor, FieldAccessorAllows, FormAccessor, IFormAccessor, RepeatingFormAccess, RepeatingFormAccessorAllows, SubFormAccess } from "./accessor"; | ||
import { Form, FormDefinition } from "./form"; | ||
import { Accessor } from "./accessor"; | ||
import { Form, FormDefinition, ValidationResponse } from "./form"; | ||
import { FieldAccessor } from "./field-accessor"; | ||
import { FormAccessor } from "./form-accessor"; | ||
import { RepeatingFormAccessor } from "./repeating-form-accessor"; | ||
import { FormAccessorBase } from "./form-accessor-base"; | ||
export interface FieldAccessorAllows { | ||
(fieldAccessor: FieldAccessor<any, any, any>): boolean; | ||
} | ||
export interface ExtraValidation { | ||
(fieldAccessor: FieldAccessor<any, any, any>, value: any): ValidationResponse; | ||
} | ||
export interface RepeatingFormAccessorAllows { | ||
(repeatingFormAccessor: RepeatingFormAccessor<any, any>): boolean; | ||
} | ||
export interface SaveFunc<M> { | ||
@@ -27,3 +40,3 @@ (node: M): any; | ||
export declare type SaveStatusOptions = "before" | "rightAfter" | "after"; | ||
export declare class FormState<M, D extends FormDefinition<M>> implements IFormAccessor<M, D> { | ||
export declare class FormState<M, D extends FormDefinition<M>> extends FormAccessorBase<M, D> { | ||
form: Form<M, D>; | ||
@@ -51,4 +64,2 @@ node: M; | ||
addPath(path: string): void; | ||
validate(): Promise<boolean>; | ||
readonly isValid: boolean; | ||
save(): Promise<boolean>; | ||
@@ -60,13 +71,6 @@ setErrors(errors: any): void; | ||
readonly isValidating: boolean; | ||
readonly accessors: Accessor[]; | ||
readonly flatAccessors: Accessor[]; | ||
accessByPath(path: string): Accessor | undefined; | ||
accessBySteps(steps: string[]): Accessor | undefined; | ||
access(name: string): Accessor | undefined; | ||
field<K extends keyof M>(name: K): FieldAccess<M, D, K>; | ||
repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>; | ||
subForm<K extends keyof M>(name: K): SubFormAccess<M, D, K>; | ||
repeatingField(name: string): any; | ||
additionalError(name: string): string | undefined; | ||
readonly additionalErrors: string[]; | ||
} |
{ | ||
"name": "mstform", | ||
"version": "0.15.1", | ||
"version": "0.16.0", | ||
"description": "mobx-state-tree powered forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/mstform.js", |
@@ -775,53 +775,2 @@ # mstform README | ||
## validationProps | ||
`FieldAccessor` defines a property `validationProps` that can be used to drive | ||
the UI in a more advanced way than we did above with `InlineError`. Let's look | ||
at the [antd UI component library](https://ant.design/docs/react/introduce) as | ||
an example: | ||
```js | ||
<Form.Item label="My Field" {...myField.validationProps}> | ||
<Input {...myField.inputProps} /> | ||
</Form.Item> | ||
``` | ||
Besides `inputProps`, which drives an actual input component, we also use | ||
`validationProps`, which drive the `Form.Item` object. This takes information | ||
such as error status. While `inputProps` is fairly universal across form UI | ||
libraries, `validationProps` is different for each of them. | ||
Out of the box, mstform ships with antd support. This is how you | ||
enable it globally: | ||
```js | ||
import { antd } from "mstform"; | ||
setupValidationProps(antd.validationProps); | ||
``` | ||
You need to do this once when the application starts. | ||
You can also define a custom validationProps that's suitable for your library. | ||
Here's one for `InlineError` as we defined it above, for instance: | ||
```js | ||
function myValidationProps(accessor) { | ||
return { | ||
error: accessor.error | ||
}; | ||
} | ||
setupValidationProps(myValidationProps); | ||
``` | ||
Once's that set up you can use `validationProps` with `InlineError`: | ||
```js | ||
<InlineError {...field.validationProps}>...</InlineError> | ||
``` | ||
This way if the behavior of InlineError changes to take more props derived from | ||
a field accessor you can easily change the way `validationProps` is generated. | ||
## Tips | ||
@@ -828,0 +777,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
185044
32
652
779
1