Comparing version 0.16.0 to 0.16.1
@@ -0,1 +1,5 @@ | ||
# 0.16.1 | ||
- Actual release with what I intended. | ||
# 0.16.0 | ||
@@ -5,2 +9,4 @@ | ||
- `isRequired` hook to drive required validation dynamically. | ||
- Remove antd support. We're maintaining this in a separate code base now | ||
@@ -7,0 +13,0 @@ (hopefully soon to be open source). |
@@ -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 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})}])}); | ||
!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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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}(),u=n(0),c=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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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(u.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(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}),Object.defineProperty(e.prototype,"required",{get:function(){return this.field.required||this.state.isRequiredFunc(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,this.required)];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,!u.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),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")},g([u.observable,v("design:type",Object)],e.prototype,"_raw",void 0),g([u.observable,v("design:type",Object)],e.prototype,"_error",void 0),g([u.observable,v("design:type",Boolean)],e.prototype,"_isValidating",void 0),g([u.observable,v("design:type",Boolean)],e.prototype,"_addMode",void 0),g([u.computed,v("design:type",String),v("design:paramtypes",[])],e.prototype,"path",null),g([u.action,v("design:type",Function),v("design:paramtypes",[Function]),v("design:returntype",void 0)],e.prototype,"setDisposer",null),g([u.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"node",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"addMode",null),g([u.computed,v("design:type","function"==typeof(t="undefined"!=typeof R&&R)&&t||Object),v("design:paramtypes",[])],e.prototype,"raw",null),g([u.computed,v("design:type","function"==typeof(n="undefined"!=typeof V&&V)&&n||Object),v("design:paramtypes",[])],e.prototype,"value",null),g([u.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"errorValue",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"canShowValidationMessages",null),g([u.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"error",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"isValidating",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"disabled",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"hidden",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"readOnly",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"required",null),g([u.computed,v("design:type",Boolean),v("design:paramtypes",[])],e.prototype,"isValid",null),g([u.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([u.action,v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",void 0)],e.prototype,"setError",null),g([u.action,v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",void 0)],e.prototype,"clearError",null),g([u.action,v("design:type",Function),v("design:paramtypes",[Boolean]),v("design:returntype",void 0)],e.prototype,"setValidating",null),g([u.computed,v("design:type",Object),v("design:paramtypes",[])],e.prototype,"inputProps",null),g([u.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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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([u.action,P("design:type",Function),P("design:paramtypes",[String]),P("design:returntype",void 0)],e.prototype,"setError",null),j([u.action,P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",void 0)],e.prototype,"clearError",null),j([u.computed,P("design:type",Object),P("design:paramtypes",[])],e.prototype,"error",null),j([u.computed,P("design:type",Boolean),P("design:paramtypes",[])],e.prototype,"isValid",null),j([u.computed,P("design:type",Array),P("design:paramtypes",[])],e.prototype,"accessors",null),j([u.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([u.computed,_("design:type",String),_("design:paramtypes",[])],t.prototype,"path",null),A([u.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([u.observable,C("design:type",Number)],t.prototype,"index",void 0),B([u.observable,C("design:type",Boolean)],t.prototype,"_addMode",void 0),B([u.computed,C("design:type",String),C("design:paramtypes",[])],t.prototype,"path",null),B([u.action,C("design:type",Function),C("design:paramtypes",[Number]),C("design:returntype",void 0)],t.prototype,"setIndex",null),B([u.action,C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",void 0)],t.prototype,"setAddMode",null),B([u.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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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=u.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(c.applyPatch)(this.state.node,[{op:"add",path:n,value:t}])},e.prototype.push=function(e){var t=Object(c.resolvePath)(this.state.node,this.path),n=this.path+"/"+t.length;Object(c.applyPatch)(this.state.node,[{op:"add",path:n,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 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(c.resolvePath)(this.state.node,this.path).length},enumerable:!0,configurable:!0}),I([u.observable,T("design:type",Object)],e.prototype,"_error",void 0),I([u.observable,T("design:type",Map)],e.prototype,"repeatingFormIndexedAccessors",void 0),I([u.computed,T("design:type",String),T("design:paramtypes",[])],e.prototype,"path",null),I([u.action,T("design:type",Function),T("design:paramtypes",[String]),T("design:returntype",void 0)],e.prototype,"setError",null),I([u.action,T("design:type",Function),T("design:paramtypes",[]),T("design:returntype",void 0)],e.prototype,"clearError",null),I([u.computed,T("design:type",Boolean),T("design:paramtypes",[])],e.prototype,"addMode",null),I([u.computed,T("design:type",Boolean),T("design:paramtypes",[])],e.prototype,"isValid",null),I([u.computed,T("design:type",Boolean),T("design:paramtypes",[])],e.prototype,"disabled",null),I([u.computed,T("design:type",Array),T("design:paramtypes",[])],e.prototype,"accessors",null),I([u.computed,T("design:type",Array),T("design:paramtypes",[])],e.prototype,"flatAccessors",null),I([u.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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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=u.observable.map(),this.repeatingFormAccessors=u.observable.map(),this.subFormAccessors=u.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([u.observable,G("design:type",Object)],e.prototype,"_error",void 0),U([u.observable,G("design:type",Boolean)],e.prototype,"_addMode",void 0),U([u.action,G("design:type",Function),G("design:paramtypes",[String]),G("design:returntype",void 0)],e.prototype,"setError",null),U([u.action,G("design:type",Function),G("design:paramtypes",[]),G("design:returntype",void 0)],e.prototype,"clearError",null),U([u.computed,G("design:type",String),G("design:paramtypes",[])],e.prototype,"path",null),U([u.computed,G("design:type",Object),G("design:paramtypes",[])],e.prototype,"error",null),U([u.computed,G("design:type",Boolean),G("design:paramtypes",[])],e.prototype,"isValid",null),U([u.computed,G("design:type",Array),G("design:paramtypes",[])],e.prototype,"accessors",null),U([u.computed,G("design:type",Array),G("design:paramtypes",[])],e.prototype,"flatAccessors",null),U([u.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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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(c.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.isRequiredFunc=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.isRequiredFunc=r.isRequired?r.isRequired: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(c.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(c.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([u.observable,L("design:type",Object)],t.prototype,"additionalErrorTree",void 0),K([u.observable,L("design:type",String)],t.prototype,"saveStatus",void 0),K([u.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"setSaveStatus",null),K([u.action,L("design:type",Function),L("design:paramtypes",[String,Object]),L("design:returntype",void 0)],t.prototype,"setValueWithoutRawUpdate",null),K([u.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"replacePath",null),K([u.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"removePath",null),K([u.action,L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],t.prototype,"addPath",null),K([u.action,L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Promise)],t.prototype,"save",null),K([u.action,L("design:type",Function),L("design:paramtypes",[Object]),L("design:returntype",void 0)],t.prototype,"setErrors",null),K([u.action,L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",void 0)],t.prototype,"clearErrors",null),K([u.computed,L("design:type",Boolean),L("design:paramtypes",[])],t.prototype,"isValidating",null),K([u.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{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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,t){return ee(this,void 0,void 0,function(){var n,r,o,i,a,s;return te(this,function(u){switch(u.label){case 0:if(e===this.converter.emptyRaw&&t)return[2,new oe(this.requiredError)];n=0,r=this.rawValidators,u.label=1;case 1:return n<r.length?[4,(0,r[n])(e)]:[3,4];case 2:if("string"==typeof(s=u.sent())&&s)return[2,new oe(s)];u.label=3;case 3:return n++,[3,1];case 4:return[4,this.converter.convert(e)];case 5:if("ConversionError"===(o=u.sent()))return e===this.converter.emptyRaw?[2,new oe(this.requiredError)]:[2,new oe(this.conversionError)];i=0,a=this.validators,u.label=6;case 6:return i<a.length?[4,(0,a[i])(o.value)]:[3,9];case 7:if("string"==typeof(s=u.sent())&&s)return[2,new oe(s)];u.label=8;case 8:return i++,[3,6];case 9:return[2,new ie(o.value)]}})})},e.prototype.render=function(e){return this.converter.render(e)},e}(),se=function(){return function(e){this.definition=e}}(),ue=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)}}(),ce=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((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 ue(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 u.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 ce(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 ce(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 |
@@ -32,2 +32,3 @@ import { IReactionDisposer } from "mobx"; | ||
readonly readOnly: boolean; | ||
readonly required: boolean; | ||
validate(): Promise<boolean>; | ||
@@ -34,0 +35,0 @@ readonly isValid: boolean; |
@@ -75,3 +75,3 @@ import { IObservableArray } from "mobx"; | ||
readonly ValueType: V; | ||
process(raw: R): Promise<ProcessResponse<V>>; | ||
process(raw: R, required: boolean): Promise<ProcessResponse<V>>; | ||
render(value: V): R; | ||
@@ -78,0 +78,0 @@ } |
@@ -36,2 +36,3 @@ import { IType } from "mobx-state-tree"; | ||
isRepeatingFormDisabled?: RepeatingFormAccessorAllows; | ||
isRequired?: FieldAccessorAllows; | ||
extraValidation?: ExtraValidation; | ||
@@ -54,2 +55,3 @@ focus?: FocusFunc<M, any, any>; | ||
isReadOnlyFunc: FieldAccessorAllows; | ||
isRequiredFunc: FieldAccessorAllows; | ||
isRepeatingFormDisabledFunc: RepeatingFormAccessorAllows; | ||
@@ -56,0 +58,0 @@ extraValidationFunc: ExtraValidation; |
{ | ||
"name": "mstform", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"description": "mobx-state-tree powered forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/mstform.js", |
@@ -628,12 +628,37 @@ # mstform README | ||
## Disabled, hidden and readOnly fields | ||
## required fields | ||
mstform has hooks that let you calculate `hidden`, `disabled` and `readOnly` | ||
state based on the field accessor. Here is a small example that makes the `foo` | ||
field disabled. This uses the JSON Path functionality of mstform to determine | ||
whether a field is disabled, but any operation can be implemented here. You | ||
could for instance retrieve information about which fields are disabled | ||
dynamically from the backend before you display the form. | ||
You can control which fields are required by setting the `required` flag in the | ||
field definition: | ||
```js | ||
const form = new Form(M, { | ||
nr: new Field(converters.number, { required: true }) | ||
}); | ||
``` | ||
This causes the field accessor's `required` property to be `true`, which you | ||
can use during form rendering. It also causes it to be a validation error | ||
if the field isn't filled in. You can control the required error message | ||
by setting `requiredError`: | ||
```js | ||
const form = new Form(M, { | ||
nr: new Field(converters.number, { | ||
required: true, | ||
requiredError: "This is required!" | ||
}) | ||
}); | ||
``` | ||
## Dynamic disabled, hidden, required and readOnly fields | ||
mstform has hooks that let you calculate `hidden`, `disabled`, `required` and | ||
`readOnly` state based on the field accessor. Here is a small example that | ||
makes the `foo` field disabled. This uses the JSON Path functionality of | ||
mstform to determine whether a field is disabled, but any operation can be | ||
implemented here. You could for instance retrieve information about which | ||
fields are disabled dynamically from the backend before you display the form. | ||
```js | ||
const state = form.state(o, { | ||
@@ -651,2 +676,8 @@ isDisabled: accessor => accessor.path === "/foo" | ||
To implement required behavior, pass in an `isRequired` function. This does not | ||
only affect the `required` property on fieldAccessor, but also makes the field | ||
require the field just as if you used the `required` flag in the field | ||
definition. The `required` flag in the field definition always makes something | ||
required, no wonder what `isRequired` says. | ||
`isDisabled` returning `true` makes the `disabled` prop `true` in | ||
@@ -656,4 +687,5 @@ `accessor.inputProps`. If `isReadOnly` is true, the `readOnly` flag is added to | ||
React input widgets support a `readOnly` prop (HTML input does). There is no | ||
such behavior for `hidden`; use `accessor.hidden` in your rendering code to | ||
determine whether a field wants to be hidden. | ||
such behavior for `hidden` or `required`; use `accessor.hidden` and | ||
``accessor.required` in your rendering code to determine whether a field wants | ||
to be hidden or required. | ||
@@ -660,0 +692,0 @@ ## Extra validation |
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
187457
656
811
0
90