New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mstform

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mstform - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

20

CHANGES.md

@@ -0,5 +1,21 @@

# 0.15
- Performance: Refactored the way accessors are handled. Instead of
recreating them each time you access a field (or sub-object, repeating
form), they are now persisted. They are created once and then reused. The
form state (raw values, errors, etc) is now maintained directly on the
accessors. This should have a positive effect on performance as mobx will
be able to keep many more computed values.
- SubForms weren't discovered when validating the whole form. Now
properly integrate SubForms.
- Breaking: remove the Group concept for now; it needs to be rethought
in the light of the performance oriented refactorings.
# 0.14
- Support for isReadOnly hook and field accessor `readOnly`. This is sent along
with `inputProps` only if isReadOnly returns `true` for that accessor.
- Support for isReadOnly hook and field accessor `readOnly`. This is sent
along with `inputProps` only if isReadOnly returns `true` for that
accessor.

@@ -6,0 +22,0 @@ # 0.13

10

dist/demo/component.d.ts
import { Component } from "react";
import { Field, Form } from "../src/index";
import { Field, Form, FieldAccessor } from "../src/index";
declare const form: Form<{

@@ -16,5 +16,11 @@ foo: string;

}>;
export declare class MyInput extends Component<{
type: string;
field: FieldAccessor<any, any, any>;
}> {
render(): JSX.Element;
}
declare type MyFormProps = {};
export declare class MyForm extends Component<MyFormProps> {
state: typeof form.FormStateType;
formState: typeof form.FormStateType;
constructor(props: MyFormProps);

@@ -21,0 +27,0 @@ handleSave: () => void;

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mobx"),require("mobx-state-tree")):"function"==typeof define&&define.amd?define(["mobx","mobx-state-tree"],e):"object"==typeof exports?exports.mstform=e(require("mobx"),require("mobx-state-tree")):t.mstform=e(t.mobx,t["mobx-state-tree"])}(window,function(t,e){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(e,r){e.exports=t},function(t,r){t.exports=e},function(t,e,r){"use strict";r.r(e);var n={value:function(t){return{value:t.raw,onChange:function(e){return t.setRaw(e.target.value)}}},checked:function(t){return{checked:t.raw,onChange:function(e){return t.setRaw(e.target.checked)}}},object:function(t){return{value:t.raw,onChange:function(e){return t.setRaw(e)}}}},o=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}u((n=n.apply(t,e||[])).next())})},i=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},s=function(){return function(t){this.value=t}}(),a=function(){function t(t){this.definition=t,this.emptyRaw=t.emptyRaw,this.defaultControlled=t.defaultControlled?t.defaultControlled:n.object}return t.prototype.convert=function(t){return o(this,void 0,void 0,function(){var e;return i(this,function(r){switch(r.label){case 0:return this.definition.rawValidate?[4,this.definition.rawValidate(t)]:[3,2];case 1:if(!r.sent())return[2,"ConversionError"];r.label=2;case 2:return e=this.definition.convert(t),this.definition.validate?[4,this.definition.validate(e)]:[3,4];case 3:if(!r.sent())return[2,"ConversionError"];r.label=4;case 4:return[2,new s(e)]}})})},t.prototype.render=function(t){return this.definition.render(t)},t}(),u=r(0),c=r(1),p=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},l=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},d=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}u((n=n.apply(t,e||[])).next())})},f=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},h=function(){return{}};function y(t){h=t}var g=function(){function t(t,e,r,n){this.state=t,this.definition=e,this.path=r,this.allowedKeys=n,this.keys=null!=n?n:Object.keys(this.definition)}return t.prototype.validate=function(){return d(this,void 0,void 0,function(){var t;return f(this,function(e){switch(e.label){case 0:return t=this.accessors.map(function(t){return t.validate()}),[4,Promise.all(t)];case 1:return[2,e.sent().every(function(t){return t})]}})})},Object.defineProperty(t.prototype,"isValid",{get:function(){return this.accessors.every(function(t){return t.isValid})},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"accessors",{get:function(){var t=this,e=[];return this.keys.forEach(function(r){var n=t.definition[r];n instanceof G?e.push(t.field(r)):n instanceof H&&e.push(t.repeatingForm(r))}),e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"flatAccessors",{get:function(){var t=[];return this.accessors.forEach(function(e){e instanceof v?t.push(e):e instanceof b&&(t.push.apply(t,e.flatAccessors),t.push(e))}),t},enumerable:!0,configurable:!0}),t.prototype.access=function(t){if(this.keys.includes(t))try{return this.field(t)}catch(e){try{return this.repeatingForm(t)}catch(t){return}}},t.prototype.accessBySteps=function(t){var e=t[0],r=t.slice(1),n=this.access(e);return 0===r.length?n:void 0===n?n:n.accessBySteps(r)},t.prototype.getDefinitionEntry=function(t){if(this.keys.includes(t))return this.definition[t]},t.prototype.restricted=function(e){var r=this;return e.forEach(function(t){if(!r.keys.includes(t))throw new Error("Cannot restrict FormAccessor to non-existent key: "+t)}),new t(this.state,this.definition,this.path,e)},t.prototype.field=function(t){var e=this.getDefinitionEntry(t);if(null==e)throw new Error("Field "+t+" is not in group");if(!(e instanceof G))throw new Error("Not accessing a Field instance");return new v(this.state,e,this.path,t)},t.prototype.repeatingForm=function(t){var e=this.getDefinitionEntry(t);if(null==e)throw new Error("RepeatingForm "+t+" is not in group");if(!(e instanceof H))throw new Error("Not accessing a RepeatingForm instance");return new b(this.state,e,this.path,t)},t.prototype.subForm=function(t){var e=this.getDefinitionEntry(t);if(null==e)throw new Error("SubForm "+t+" is not in group");if(!(e instanceof W))throw new Error("Not accessing a SubForm instance");return new w(this.state,e.definition,this.path,t)},t.prototype.repeatingField=function(t){},p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"isValid",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"flatAccessors",null),t}(),v=function(){function t(t,e,r,n){var o=this;this.state=t,this.field=e,this.handleChange=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return d(o,void 0,void 0,function(){var e,r;return f(this,function(n){switch(n.label){case 0:return r=(e=this.field).getRaw.apply(e,t),[4,this.setRaw(r)];case 1:return n.sent(),[2]}})})},this.handleFocus=function(t){null!=o.state.focusFunc&&o.state.focusFunc(t,o)},this.name=n,this.nodePath=r,this.path=r+"/"+n,this.createDerivedReaction()}var e,r,n;return t.prototype.createDerivedReaction=function(){var t=this,e=this.field.derivedFunc;if(null!=e&&!this.state.derivedDisposers.get(this.path)){var r=Object(u.reaction)(function(){return t.node?e(t.node):void 0},function(e){void 0!==e&&t.setRaw(t.field.render(e))});this.state.setDerivedDisposer(this.path,r)}},Object.defineProperty(t.prototype,"node",{get:function(){try{return this.state.getValue(this.nodePath)}catch(t){return}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"addMode",{get:function(){return this.state.addMode(this.path)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"raw",{get:function(){var t=this.state.raw.get(this.path);return void 0!==t?!Object(u.isObservable)(t)||t instanceof Array?Object(u.toJS)(t):t:this.addMode?this.field.converter.emptyRaw:this.field.render(this.value)},enumerable:!0,configurable:!0}),Object.defineProperty(t.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(t.prototype,"errorValue",{get:function(){return this.state.getError(this.path)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canShowValidationMessages",{get:function(){if("rightAfter"===this.state.saveStatus)return!0;var t="before"===this.state.saveStatus?this.state.validationBeforeSave:this.state.validationAfterSave;return"immediate"===t||"no"!==t&&("blur"!==t&&"pause"!==t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"error",{get:function(){return this.canShowValidationMessages?this.errorValue:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isValidating",{get:function(){return this.state.validating.get(this.path)||!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"disabled",{get:function(){return this.state.isDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hidden",{get:function(){return this.state.isHiddenFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"readOnly",{get:function(){return this.state.isReadOnlyFunc(this)},enumerable:!0,configurable:!0}),t.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(t){switch(t.label){case 0:return[4,this.setRaw(this.raw)];case 1:return t.sent(),[2,this.isValid]}})})},Object.defineProperty(t.prototype,"isValid",{get:function(){return void 0===this.errorValue},enumerable:!0,configurable:!0}),t.prototype.setRaw=function(t){return d(this,void 0,void 0,function(){var e,r,n,o;return f(this,function(i){switch(i.label){case 0:this.state.setRaw(this.path,t),this.state.setValidating(this.path,!0),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.field.process(t)];case 2:return e=i.sent(),[3,4];case 3:return i.sent(),this.state.setError(this.path,"Something went wrong"),this.state.setValidating(this.path,!1),[2];case 4:if(r=this.state.raw.get(this.path),!u.comparer.structural(r,t))return[2];if(this.state.setValidating(this.path,!1),e instanceof I)return this.state.setError(this.path,e.message),[2];if(this.state.deleteError(this.path),!(e instanceof U))throw new Error("Unknown process result");return"string"==typeof(n=this.state.extraValidationFunc(this,e.value))&&n&&this.state.setError(this.path,n),u.comparer.structural(this.value,e.value)?[2]:(this.state.setValueWithoutRawUpdate(this.path,e.value),null!=(o=this.field.changeFunc)&&o(this.node,e.value),[2])}})})},Object.defineProperty(t.prototype,"inputProps",{get:function(){var t=this.field.controlled(this);return t.disabled=this.disabled,this.readOnly&&(t.readOnly=this.readOnly),null!=this.state.focusFunc&&(t.onFocus=this.handleFocus),t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"validationProps",{get:function(){return h(this)},enumerable:!0,configurable:!0}),t.prototype.accessBySteps=function(t){throw new Error("Cannot step through field accessor")},p([u.computed,l("design:type",Object),l("design:paramtypes",[])],t.prototype,"node",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"addMode",null),p([u.computed,l("design:type","function"==typeof(e="undefined"!=typeof R&&R)&&e||Object),l("design:paramtypes",[])],t.prototype,"raw",null),p([u.computed,l("design:type","function"==typeof(r="undefined"!=typeof V&&V)&&r||Object),l("design:paramtypes",[])],t.prototype,"value",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],t.prototype,"errorValue",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"canShowValidationMessages",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],t.prototype,"error",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"isValidating",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"disabled",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"hidden",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"readOnly",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"isValid",null),p([u.action,l("design:type",Function),l("design:paramtypes",["function"==typeof(n="undefined"!=typeof R&&R)&&n||Object]),l("design:returntype",Promise)],t.prototype,"setRaw",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],t.prototype,"inputProps",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],t.prototype,"validationProps",null),t}(),b=function(){function t(t,e,r,n){this.state=t,this.repeatingForm=e,this.name=n,this.path=r+"/"+n}return t.prototype.validate=function(){return d(this,void 0,void 0,function(){var t,e,r,n;return f(this,function(o){switch(o.label){case 0:for(t=[],e=0,r=this.accessors;e<r.length;e++)n=r[e],t.push(n.validate());return[4,Promise.all(t)];case 1:return[2,o.sent().every(function(t){return t})]}})})},Object.defineProperty(t.prototype,"isValid",{get:function(){return this.accessors.every(function(t){return t.isValid})},enumerable:!0,configurable:!0}),t.prototype.index=function(t){return new m(this.state,this.repeatingForm.definition,this.path,t)},Object.defineProperty(t.prototype,"disabled",{get:function(){return this.state.isRepeatingFormDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"accessors",{get:function(){for(var t=[],e=0;e<this.length;e++)t.push(this.index(e));return t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"flatAccessors",{get:function(){var t=[];return this.accessors.forEach(function(e){t.push.apply(t,e.flatAccessors)}),t},enumerable:!0,configurable:!0}),t.prototype.accessBySteps=function(t){var e=t[0],r=t.slice(1),n=parseInt(e,10);if(isNaN(n))throw new Error("Expected index of repeating form");return this.index(n).accessBySteps(r)},Object.defineProperty(t.prototype,"error",{get:function(){return this.state.errors.get(this.path)},enumerable:!0,configurable:!0}),t.prototype.insert=function(t,e){var r=this.path+"/"+t;Object(c.applyPatch)(this.state.node,[{op:"add",path:r,value:e}])},t.prototype.push=function(t){var e=Object(c.resolvePath)(this.state.node,this.path),r=this.path+"/"+e.length;Object(c.applyPatch)(this.state.node,[{op:"add",path:r,value:t}])},t.prototype.remove=function(t){var e=Object(c.resolvePath)(this.state.node,this.path).indexOf(t);if(-1===e)throw new Error("Cannot find node to remove.");Object(c.applyPatch)(this.state.node,[{op:"remove",path:this.path+"/"+e}])},Object.defineProperty(t.prototype,"length",{get:function(){return Object(c.resolvePath)(this.state.node,this.path).length},enumerable:!0,configurable:!0}),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"disabled",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"flatAccessors",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],t.prototype,"error",null),t}(),m=function(){function t(t,e,r,n){this.state=t,this.definition=e,this.index=n,this.path=r+"/"+n,this.formAccessor=new g(t,e,r+"/"+n)}return t.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(t){return[2,this.formAccessor.validate()]})})},Object.defineProperty(t.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),t.prototype.access=function(t){return this.formAccessor.access(t)},t.prototype.accessBySteps=function(t){var e=t[0],r=t.slice(1),n=this.access(e);return 0===r.length?n:void 0!==n?n.accessBySteps(t):void 0},t.prototype.restricted=function(t){return this.formAccessor.restricted(t)},t.prototype.field=function(t){return this.formAccessor.field(t)},t.prototype.repeatingForm=function(t){return this.formAccessor.repeatingForm(t)},Object.defineProperty(t.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"isValid",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"flatAccessors",null),t}(),w=function(){function t(t,e,r,n){this.state=t,this.definition=e,this.name=n,this.path=r+"/"+n,this.formAccessor=new g(t,e,this.path)}return t.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(t){return[2,this.formAccessor.validate()]})})},Object.defineProperty(t.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),t.prototype.access=function(t){return this.formAccessor.access(t)},t.prototype.accessBySteps=function(t){var e=t[0],r=t.slice(1),n=this.access(e);return 0===r.length?n:void 0!==n?n.accessBySteps(t):void 0},t.prototype.restricted=function(t){return this.formAccessor.restricted(t)},t.prototype.field=function(t){return this.formAccessor.field(t)},t.prototype.repeatingForm=function(t){return this.formAccessor.repeatingForm(t)},Object.defineProperty(t.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],t.prototype,"isValid",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],t.prototype,"flatAccessors",null),t}();function P(t){return t}function O(t){return t.startsWith("/")&&(t=t.slice(1)),t.split("/")}function j(t){var e=t.join("/");return e.startsWith("/")?e:"/"+e}function F(t){return Number.isInteger(parseInt(t,10))}function S(t,e){return function t(e,r){var n=r[0],o=r.slice(1);if(0===o.length)return e[n];var i=e[n];if(void 0===i)return;return t(i,o)}(t,O(e))}function E(t,e){return function t(e,r){var n=r[0],o=r.slice(1);0===o.length&&delete e[n];var i=e[n];if(void 0===i)return;t(i,o)}(t,O(e))}function A(t,e,r){var n=O(e),o=n[n.length-1],i=parseInt(o,10),s=j(n.slice(0,n.length-1)),a=new Map;return t.forEach(function(t,e){if(e.startsWith(s)){var n=O(e.slice(s.length+1)),o=parseInt(n[0],10);if(isNaN(o))a.set(e,t);else if(o<i)a.set(e,t);else if(o!==i){var u=n.slice(1),c=s+j([(o-1).toString()].concat(u));a.delete(e),a.set(c,t)}else null!=r&&r(t)}else a.set(e,t)}),a}function x(t,e){var r=O(e),n=r[r.length-1],o=parseInt(n,10);if(isNaN(o))return t;var i=j(r.slice(0,r.length-1)),s=new Map;return t.forEach(function(t,e){if(e.startsWith(i)){var r=O(e.slice(i.length+1)),n=parseInt(r[0],10);if(isNaN(n))s.set(e,t);else if(n<o)s.set(e,t);else{var a=r.slice(1),u=i+j([(n+1).toString()].concat(a));s.set(u,t)}}else s.set(e,t)}),s}var D=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},C=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},M=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}u((n=n.apply(t,e||[])).next())})},k=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},B=function(){function t(t,e,r){var n=this;if(this.form=t,this.node=e,this.saveStatus="before",this.raw=u.observable.map(),this.errors=u.observable.map(),this.validating=u.observable.map(),this.addModePaths=u.observable.map(),this.derivedDisposers=u.observable.map(),this.additionalErrorTree={},this.noRawUpdate=!1,Object(c.onPatch)(e,function(t){"remove"===t.op?n.removePath(t.path):"add"===t.op?n.addPath(t.path):"replace"===t.op&&n.setRawFromValue(t.path)}),this.formAccessor=new g(this,this.form.definition,""),null==r)this.saveFunc=T,this.isDisabledFunc=function(){return!1},this.isHiddenFunc=function(){return!1},this.isReadOnlyFunc=function(){return!1},this.isRepeatingFormDisabledFunc=function(){return!1},this.extraValidationFunc=function(){return!1},this.validationBeforeSave="immediate",this.validationAfterSave="immediate",this.validationPauseDuration=0,this.addModePaths.set("/",!1),this.focusFunc=null;else{this.saveFunc=r.save?r.save:T,this.isDisabledFunc=r.isDisabled?r.isDisabled:function(){return!1},this.isHiddenFunc=r.isHidden?r.isHidden:function(){return!1},this.isReadOnlyFunc=r.isReadOnly?r.isReadOnly:function(){return!1},this.isRepeatingFormDisabledFunc=r.isRepeatingFormDisabled?r.isRepeatingFormDisabled:function(){return!1},this.extraValidationFunc=r.extraValidation?r.extraValidation:function(){return!1},this.addModePaths.set("/",r.addMode||!1);var o=r.validation||{};this.validationBeforeSave=o.beforeSave||"immediate",this.validationAfterSave=o.afterSave||"immediate",this.validationPauseDuration=o.pauseDuration||0,this.focusFunc=r.focus?r.focus:null}}return t.prototype.setError=function(t,e){this.errors.set(t,e)},t.prototype.deleteError=function(t){this.errors.delete(t)},t.prototype.setValidating=function(t,e){this.validating.set(t,e)},t.prototype.setSaveStatus=function(t){this.saveStatus=t},t.prototype.setRaw=function(t,e){"rightAfter"===this.saveStatus&&this.setSaveStatus("after"),this.raw.set(t,e)},t.prototype.setRawFromValue=function(t){if(!this.noRawUpdate){var e=this.accessByPath(t);if(void 0!==e&&e instanceof v){var r=this.getValue(t);this.setRaw(t,e.field.render(r)),e.validate()}}},t.prototype.setValueWithoutRawUpdate=function(t,e){this.noRawUpdate=!0,Object(c.applyPatch)(this.node,[{op:"replace",path:t,value:e}]),this.noRawUpdate=!1},t.prototype.setDerivedDisposer=function(t,e){this.derivedDisposers.set(t,e)},t.prototype.removePath=function(t){this.raw=A(this.raw,t),this.errors=A(this.errors,t),this.validating=A(this.validating,t),this.addModePaths=A(this.addModePaths,t),this.derivedDisposers=A(this.derivedDisposers,t,function(t){t()}),this.addModePaths.set(t,!0)},t.prototype.addPath=function(t){this.raw=x(this.raw,t),this.errors=x(this.errors,t),this.validating=x(this.validating,t),this.addModePaths=x(this.addModePaths,t),this.derivedDisposers=x(this.derivedDisposers,t),this.addModePaths.set(t,!0)},t.prototype.validate=function(){return M(this,void 0,void 0,function(){return k(this,function(t){return[2,this.formAccessor.validate()]})})},Object.defineProperty(t.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),t.prototype.save=function(){return M(this,void 0,void 0,function(){var t,e;return k(this,function(r){switch(r.label){case 0:return[4,this.validate()];case 1:return t=r.sent(),this.setSaveStatus("rightAfter"),t?[4,this.saveFunc(this.node)]:[2,!1];case 2:return null!=(e=r.sent())?(this.setErrors(e),[2,!1]):(this.clearErrors(),[2,!0])}})})},t.prototype.setErrors=function(t){var e=this,r=function(t){return JSON.parse(JSON.stringify(t))}(t);this.flatAccessors.map(function(n){var o=S(t,n.path);null!=o&&(e.errors.set(n.path,o),E(r,n.path))}),this.additionalErrorTree=r},t.prototype.clearErrors=function(){this.additionalErrorTree={},this.errors.clear()},t.prototype.isKnownAddModePath=function(t){var e,r="";return this.addModePaths.forEach(function(n,o){if(t.startsWith(o)){if(o.length<r.length)return;return r=o,void(e=n)}}),void 0!==e&&e},t.prototype.addMode=function(t){return this.isKnownAddModePath(t)&&void 0===this.raw.get(t)},t.prototype.getValue=function(t){return Object(c.resolvePath)(this.node,t)},t.prototype.getError=function(t){return this.errors.get(t)},t.prototype.getMstType=function(t){for(var e=O(t),r=this.form.model,n=0,o=e;n<o.length;n++){var i=o[n];F(i)?r=r.getChildType(i):r=r.getChildType(i)}return r},Object.defineProperty(t.prototype,"isValidating",{get:function(){return Array.from(this.validating.values()).filter(function(t){return t}).length>0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),t.prototype.accessByPath=function(t){var e=O(t);return this.accessBySteps(e)},t.prototype.accessBySteps=function(t){return this.formAccessor.accessBySteps(t)},t.prototype.access=function(t){return this.formAccessor.access(t)},t.prototype.restricted=function(t){return this.formAccessor.restricted(t)},t.prototype.field=function(t){return this.formAccessor.field(t)},t.prototype.repeatingForm=function(t){return this.formAccessor.repeatingForm(t)},t.prototype.subForm=function(t){return this.formAccessor.subForm(t)},t.prototype.repeatingField=function(t){},t.prototype.additionalError=function(t){var e=this.additionalErrorTree[t];if("string"==typeof e)return e},Object.defineProperty(t.prototype,"additionalErrors",{get:function(){var t=this,e=[];return Object.keys(this.additionalErrorTree).forEach(function(r){var n=t.additionalErrorTree[r];"string"==typeof n&&e.push(n)}),e.sort(),e},enumerable:!0,configurable:!0}),D([u.observable,C("design:type",Map)],t.prototype,"raw",void 0),D([u.observable,C("design:type",Map)],t.prototype,"errors",void 0),D([u.observable,C("design:type",Object)],t.prototype,"additionalErrorTree",void 0),D([u.observable,C("design:type",Map)],t.prototype,"validating",void 0),D([u.observable,C("design:type",Map)],t.prototype,"addModePaths",void 0),D([u.observable,C("design:type",Map)],t.prototype,"derivedDisposers",void 0),D([u.observable,C("design:type",String)],t.prototype,"saveStatus",void 0),D([u.action,C("design:type",Function),C("design:paramtypes",[String,String]),C("design:returntype",void 0)],t.prototype,"setError",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"deleteError",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String,Boolean]),C("design:returntype",void 0)],t.prototype,"setValidating",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"setSaveStatus",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String,Object]),C("design:returntype",void 0)],t.prototype,"setRaw",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"setRawFromValue",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String,Object]),C("design:returntype",void 0)],t.prototype,"setValueWithoutRawUpdate",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String,Function]),C("design:returntype",void 0)],t.prototype,"setDerivedDisposer",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"removePath",null),D([u.action,C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"addPath",null),D([u.computed,C("design:type",Boolean),C("design:paramtypes",[])],t.prototype,"isValid",null),D([u.action,C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"save",null),D([u.action,C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",void 0)],t.prototype,"setErrors",null),D([u.action,C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",void 0)],t.prototype,"clearErrors",null),D([u.computed,C("design:type",Boolean),C("design:paramtypes",[])],t.prototype,"isValidating",null),D([u.computed,C("design:type",Array),C("design:paramtypes",[])],t.prototype,"accessors",null),D([u.computed,C("design:type",Array),C("design:paramtypes",[])],t.prototype,"flatAccessors",null),D([u.computed,C("design:type",Array),C("design:paramtypes",[])],t.prototype,"additionalErrors",null),t}();function T(){return M(this,void 0,void 0,function(){return k(this,function(t){return console.warn("No mstform save function configured"),[2,null]})})}var N=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}u((n=n.apply(t,e||[])).next())})},q=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},_=function(){function t(t,e){this.model=t,this.definition=e}return Object.defineProperty(t.prototype,"FormStateType",{get:function(){throw new Error("For introspection")},enumerable:!0,configurable:!0}),t.prototype.state=function(t,e){return new B(this,t,e)},t}(),W=function(){return function(t){this.definition=t}}(),I=function(){return function(t){this.message=t}}(),U=function(){return function(t){this.value=t}}(),G=function(){function t(t,e){if(this.converter=t,this.options=e,e){if(this.rawValidators=e.rawValidators?e.rawValidators:[],this.validators=e.validators?e.validators:[],this.conversionError=e.conversionError||"Could not convert",this.requiredError=e.requiredError||"Required",this.required=e.required||!1,e.fromEvent){if(e.getRaw)throw new Error("Cannot have fromEvent and getRaw defined at same time");this.getRaw=function(t){return t.target.value}}else this.getRaw=e.getRaw||P;this.derivedFunc=e.derived,this.changeFunc=e.change,this.controlled=e.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 t.prototype.createDefaultControlled=function(){var t=this;return this.getRaw!==P?function(e){return{value:e.raw,onChange:function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return e.setRaw(t.getRaw.apply(t,r))}}}:this.converter.defaultControlled},Object.defineProperty(t.prototype,"RawType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ValueType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),t.prototype.process=function(t){return N(this,void 0,void 0,function(){var e,r,n,o,i,s;return q(this,function(a){switch(a.label){case 0:if(t===this.converter.emptyRaw&&this.required)return[2,new I(this.requiredError)];e=0,r=this.rawValidators,a.label=1;case 1:return e<r.length?[4,(0,r[e])(t)]:[3,4];case 2:if("string"==typeof(s=a.sent())&&s)return[2,new I(s)];a.label=3;case 3:return e++,[3,1];case 4:return[4,this.converter.convert(t)];case 5:if("ConversionError"===(n=a.sent()))return t===this.converter.emptyRaw?[2,new I(this.requiredError)]:[2,new I(this.conversionError)];o=0,i=this.validators,a.label=6;case 6:return o<i.length?[4,(0,i[o])(n.value)]:[3,9];case 7:if("string"==typeof(s=a.sent())&&s)return[2,new I(s)];a.label=8;case 8:return o++,[3,6];case 9:return[2,new U(n.value)]}})})},t.prototype.render=function(t){return this.converter.render(t)},t}(),H=function(){return function(t){this.definition=t}}(),K=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),J=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}u((n=n.apply(t,e||[])).next())})},$=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},z=new RegExp("^-?(0|[1-9]\\d*)(\\.\\d*)?$"),L=new RegExp("^-?(0|[1-9]\\d*)$"),Q=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.defaultControlled=n.value,e}return K(e,t),e}(a),X=new Q({emptyRaw:"",convert:function(t){return t},render:function(t){return t}}),Y=new Q({emptyRaw:"",rawValidate:function(t){return t.startsWith(".")&&(t="0"+t),z.test(t)},convert:function(t){return+t},render:function(t){return t.toString()}}),Z=new Q({emptyRaw:"",rawValidate:function(t){return L.test(t)},convert:function(t){return+t},render:function(t){return t.toString()}}),tt=new a({emptyRaw:!1,convert:function(t){return t},render:function(t){return t},defaultControlled:n.checked}),et=function(){function t(t,e){this.maxWholeDigits=t,this.decimalPlaces=e,this.defaultControlled=n.value,this.emptyRaw="";var r=new RegExp("^-?(0|[1-9]\\d{0,"+(t-1)+"})(\\.\\d{0,"+e+"})?$");this.converter=new Q({emptyRaw:"",rawValidate:function(t){return t.startsWith(".")&&(t="0"+t),r.test(t)},convert:function(t){return t},render:function(t){return t}})}return t.prototype.convert=function(t){return this.converter.convert(t)},t.prototype.render=function(t){return this.converter.render(t)},t.prototype.getRaw=function(t){return t},t}();var rt=new a({emptyRaw:[],convert:function(t){return u.observable.array(t)},render:function(t){return t.slice()}});var nt=function(){function t(t){this.converter=t,this.defaultControlled=n.value,this.emptyRaw=""}return t.prototype.convert=function(t){return J(this,void 0,void 0,function(){return $(this,function(e){return""===t.trim()?[2,new s(null)]:[2,this.converter.convert(t)]})})},t.prototype.render=function(t){return null===t?"":this.converter.render(t)},t}(),ot=function(){function t(t){this.emptyRaw=null,this.defaultControlled=n.object}return t.prototype.convert=function(t){return J(this,void 0,void 0,function(){return $(this,function(e){return null===t?[2,"ConversionError"]:[2,new s(t)]})})},t.prototype.render=function(t){return t},t}();var it={string:X,number:Y,integer:Z,decimal:function(t,e){return new et(t,e)},boolean:tt,stringArray:rt,maybe:function(t){return t instanceof Q?new nt(t):new a({emptyRaw:null,convert:P,render:P,defaultControlled:n.object})},model:function(t){return new ot(t)},object:new a({emptyRaw:null,convert:P,render:P})},st=function(){function t(t,e){this.model=t,this.allowedKeys=e}return t.prototype.access=function(t){return t.restricted(this.allowedKeys)},t}();var at={validationProps:function(t){var e=t.error,r=t.isValidating;return e?{validateStatus:r?"validating":"error",help:e}:{validateStatus:r?"validating":""}}};r.d(e,"Form",function(){return _}),r.d(e,"SubForm",function(){return W}),r.d(e,"ValidationMessage",function(){return I}),r.d(e,"ProcessValue",function(){return U}),r.d(e,"Field",function(){return G}),r.d(e,"RepeatingForm",function(){return H}),r.d(e,"ConversionValue",function(){return s}),r.d(e,"CONVERSION_ERROR",function(){return"ConversionError"}),r.d(e,"Converter",function(){return a}),r.d(e,"StringConverter",function(){return Q}),r.d(e,"converters",function(){return it}),r.d(e,"setupValidationProps",function(){return y}),r.d(e,"FormAccessor",function(){return g}),r.d(e,"FieldAccessor",function(){return v}),r.d(e,"RepeatingFormAccessor",function(){return b}),r.d(e,"RepeatingFormIndexedAccessor",function(){return m}),r.d(e,"SubFormAccessor",function(){return w}),r.d(e,"controlled",function(){return n}),r.d(e,"Group",function(){return st}),r.d(e,"antd",function(){return at}),r.d(e,"FormState",function(){return B})}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx"),require("mobx-state-tree")):"function"==typeof define&&define.amd?define(["mobx","mobx-state-tree"],t):"object"==typeof exports?exports.mstform=t(require("mobx"),require("mobx-state-tree")):e.mstform=t(e.mobx,e["mobx-state-tree"])}(window,function(e,t){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t,r){"use strict";r.r(t);var n={value:function(e){return{value:e.raw,onChange:function(t){return e.setRaw(t.target.value)}}},checked:function(e){return{checked:e.raw,onChange:function(t){return e.setRaw(t.target.checked)}}},object:function(e){return{value:e.raw,onChange:function(t){return e.setRaw(t)}}}},o=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},s=function(){return function(e){this.value=e}}(),a=function(){function e(e){this.definition=e,this.emptyRaw=e.emptyRaw,this.defaultControlled=e.defaultControlled?e.defaultControlled:n.object}return e.prototype.convert=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return this.definition.rawValidate?[4,this.definition.rawValidate(e)]:[3,2];case 1:if(!r.sent())return[2,"ConversionError"];r.label=2;case 2:return t=this.definition.convert(e),this.definition.validate?[4,this.definition.validate(t)]:[3,4];case 3:if(!r.sent())return[2,"ConversionError"];r.label=4;case 4:return[2,new s(t)]}})})},e.prototype.render=function(e){return this.definition.render(e)},e}(),u=r(0),c=r(1),p=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},l=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},d=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},f=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},h=function(){return{}};function y(e){h=e}var g=function(){function e(e,t,r,n,o){this.state=e,this.definition=t,this.parent=r,this.allowedKeys=o,this.fieldAccessors=u.observable.map(),this.repeatingFormAccessors=u.observable.map(),this.subFormAccessors=u.observable.map(),this.keys=null!=o?o:Object.keys(this.definition),this._addMode=n,this.initialize()}return e.prototype.validate=function(){return d(this,void 0,void 0,function(){var e;return f(this,function(t){switch(t.label){case 0:return e=this.accessors.map(function(e){return e.validate()}),[4,Promise.all(e)];case 1:return[2,t.sent().every(function(e){return e})]}})})},e.prototype.setError=function(e){},e.prototype.clearError=function(){},e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return null==this.parent?"":this.parent.path},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.accessors.every(function(e){return e.isValid})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){var e=this,t=[];return this.keys.forEach(function(r){var n=e.definition[r];n instanceof N?t.push(e.field(r)):n instanceof z?t.push(e.repeatingForm(r)):n instanceof D&&t.push(e.subForm(r))}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){var e=[];return this.accessors.forEach(function(t){t instanceof b?e.push(t):t instanceof v?(e.push.apply(e,t.flatAccessors),e.push(t)):t instanceof w&&(e.push.apply(e,t.flatAccessors),e.push(t))}),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return!!this._addMode||null!=this.parent&&this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){if(this.keys.includes(e))try{return this.field(e)}catch(t){try{return this.repeatingForm(e)}catch(t){try{return this.subForm(e)}catch(e){return}}}},e.prototype.accessBySteps=function(e){if(0===e.length)return this;var t=e[0],r=e.slice(1),n=this.access(t);return 0===r.length?n:void 0===n?n:n.accessBySteps(r)},e.prototype.initialize=function(){var e=this;this.keys.forEach(function(t){var r=e.definition[t];r instanceof N?e.createField(t,r):r instanceof z?e.createRepeatingForm(t,r):r instanceof D&&e.createSubForm(t,r)})},e.prototype.createField=function(e,t){var r=new b(this.state,t,this,e);this.fieldAccessors.set(e,r)},e.prototype.field=function(e){var t=this.fieldAccessors.get(e);if(null==t)throw new Error(e+" is not a Field");return t},e.prototype.createRepeatingForm=function(e,t){var r=new v(this.state,t,this,e);this.repeatingFormAccessors.set(e,r),r.initialize()},e.prototype.repeatingForm=function(e){var t=this.repeatingFormAccessors.get(e);if(null==t)throw new Error(e+" is not a RepeatingForm");return t},e.prototype.createSubForm=function(e,t){var r=new w(this.state,t.definition,this,e);this.subFormAccessors.set(e,r),r.initialize()},e.prototype.subForm=function(e){var t=this.subFormAccessors.get(e);if(null==t)throw new Error(e+" is not a SubForm");return t},e.prototype.repeatingField=function(e){},p([u.observable,l("design:type",Boolean)],e.prototype,"_addMode",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),e}(),b=function(){function e(e,t,r,n){var o=this;this.state=e,this.field=t,this.parent=r,this._isValidating=!1,this._addMode=!1,this.handleChange=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d(o,void 0,void 0,function(){var t,r;return f(this,function(n){switch(n.label){case 0:return r=(t=this.field).getRaw.apply(t,e),[4,this.setRaw(r)];case 1:return n.sent(),[2]}})})},this.handleFocus=function(e){null!=o.state.focusFunc&&o.state.focusFunc(e,o)},this.name=n,this.createDerivedReaction()}var t,r,n;return e.prototype.clear=function(){null!=this._disposer&&this._disposer()},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),e.prototype.setDisposer=function(e){this._disposer=e},e.prototype.createDerivedReaction=function(){var e=this,t=this.field.derivedFunc;if(null!=t&&null==this._disposer){var r=Object(u.reaction)(function(){return e.node?t(e.node):void 0},function(t){void 0!==t&&e.setRaw(e.field.render(t))});this._disposer=r}},Object.defineProperty(e.prototype,"node",{get:function(){try{return this.state.getValue(this.parent.path)}catch(e){return}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return void 0===this._raw&&(this._addMode||this.parent.addMode)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"raw",{get:function(){var e=this._raw;return void 0!==e?!Object(u.isObservable)(e)||e instanceof Array?Object(u.toJS)(e):e:this.addMode?this.field.converter.emptyRaw:this.field.render(this.value)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){if(this.addMode)throw new Error("Cannot access field in add mode until it has been set once");return this.state.getValue(this.path)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorValue",{get:function(){return this._error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canShowValidationMessages",{get:function(){if("rightAfter"===this.state.saveStatus)return!0;var e="before"===this.state.saveStatus?this.state.validationBeforeSave:this.state.validationAfterSave;return"immediate"===e||"no"!==e&&("blur"!==e&&"pause"!==e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this.canShowValidationMessages?this.errorValue:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValidating",{get:function(){return this._isValidating},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this.state.isDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hidden",{get:function(){return this.state.isHiddenFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readOnly",{get:function(){return this.state.isReadOnlyFunc(this)},enumerable:!0,configurable:!0}),e.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(e){switch(e.label){case 0:return[4,this.setRaw(this.raw)];case 1:return e.sent(),[2,this.isValid]}})})},Object.defineProperty(e.prototype,"isValid",{get:function(){return void 0===this.errorValue},enumerable:!0,configurable:!0}),e.prototype.setRaw=function(e){return d(this,void 0,void 0,function(){var t,r,n,o;return f(this,function(i){switch(i.label){case 0:"rightAfter"===this.state.saveStatus&&this.state.setSaveStatus("after"),this._raw=e,this._isValidating=!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._error="Something went wrong",this._isValidating=!1,[2];case 4:if(r=this._raw,!u.comparer.structural(r,e))return[2];if(this._isValidating=!1,t instanceof T)return this._error=t.message,[2];if(this._error=void 0,!(t instanceof q))throw new Error("Unknown process result");return"string"==typeof(n=this.state.extraValidationFunc(this,t.value))&&n&&(this._error=n),u.comparer.structural(this.value,t.value)?[2]:(this.state.setValueWithoutRawUpdate(this.path,t.value),null!=(o=this.field.changeFunc)&&o(this.node,t.value),[2])}})})},e.prototype.setRawFromValue=function(){var e=this.state.getValue(this.path);this._raw=this.field.render(e),this.validate()},e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},Object.defineProperty(e.prototype,"inputProps",{get:function(){var e=this.field.controlled(this);return e.disabled=this.disabled,this.readOnly&&(e.readOnly=this.readOnly),null!=this.state.focusFunc&&(e.onFocus=this.handleFocus),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validationProps",{get:function(){return h(this)},enumerable:!0,configurable:!0}),e.prototype.accessBySteps=function(e){throw new Error("Cannot step through field accessor")},p([u.observable,l("design:type",Object)],e.prototype,"_raw",void 0),p([u.observable,l("design:type",Object)],e.prototype,"_error",void 0),p([u.observable,l("design:type",Boolean)],e.prototype,"_isValidating",void 0),p([u.observable,l("design:type",Boolean)],e.prototype,"_addMode",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.action,l("design:type",Function),l("design:paramtypes",[Function]),l("design:returntype",void 0)],e.prototype,"setDisposer",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"node",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type","function"==typeof(t="undefined"!=typeof R&&R)&&t||Object),l("design:paramtypes",[])],e.prototype,"raw",null),p([u.computed,l("design:type","function"==typeof(r="undefined"!=typeof V&&V)&&r||Object),l("design:paramtypes",[])],e.prototype,"value",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"errorValue",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"canShowValidationMessages",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"error",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValidating",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"disabled",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"hidden",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"readOnly",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.action,l("design:type",Function),l("design:paramtypes",["function"==typeof(n="undefined"!=typeof R&&R)&&n||Object]),l("design:returntype",Promise)],e.prototype,"setRaw",null),p([u.action,l("design:type",Function),l("design:paramtypes",[String]),l("design:returntype",void 0)],e.prototype,"setError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"clearError",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"inputProps",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"validationProps",null),e}(),v=function(){function e(e,t,r,n){this.state=e,this.repeatingForm=t,this.parent=r,this.repeatingFormIndexedAccessors=u.observable.map(),this.name=n}return e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),e.prototype.setError=function(e){this._error=e},e.prototype.clearError=function(){this._error=void 0},e.prototype.validate=function(){return d(this,void 0,void 0,function(){var e,t,r,n;return f(this,function(o){switch(o.label){case 0:for(e=[],t=0,r=this.accessors;t<r.length;t++)n=r[t],e.push(n.validate());return[4,Promise.all(e)];case 1:return[2,o.sent().every(function(e){return e})]}})})},Object.defineProperty(e.prototype,"addMode",{get:function(){return this.parent.addMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.accessors.every(function(e){return e.isValid})},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){var e=this,t=0;this.state.getValue(this.path).forEach(function(){e.createFormIndexedAccessor(t),t++})},e.prototype.createFormIndexedAccessor=function(e){var t=new m(this.state,this.repeatingForm.definition,this,e);this.repeatingFormIndexedAccessors.set(e,t),t.initialize()},e.prototype.index=function(e){var t=this.repeatingFormIndexedAccessors.get(e);if(null==t)throw new Error(e+" is not a RepeatingFormIndexedAccessor");return t},Object.defineProperty(e.prototype,"disabled",{get:function(){return this.state.isRepeatingFormDisabledFunc(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){for(var e=[],t=0;t<this.length;t++)e.push(this.index(t));return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){var e=[];return this.accessors.forEach(function(t){e.push.apply(e,t.flatAccessors)}),e},enumerable:!0,configurable:!0}),e.prototype.accessBySteps=function(e){var t=e[0],r=e.slice(1),n=parseInt(t,10);if(isNaN(n))throw new Error("Expected index of repeating form");return this.index(n).accessBySteps(r)},Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0}),e.prototype.insert=function(e,t){var r=this.path+"/"+e;Object(c.applyPatch)(this.state.node,[{op:"add",path:r,value:t}])},e.prototype.push=function(e){var t=Object(c.resolvePath)(this.state.node,this.path),r=this.path+"/"+t.length;Object(c.applyPatch)(this.state.node,[{op:"add",path:r,value:e}])},e.prototype.remove=function(e){var t=Object(c.resolvePath)(this.state.node,this.path).indexOf(e);if(-1===t)throw new Error("Cannot find node to remove.");Object(c.applyPatch)(this.state.node,[{op:"remove",path:this.path+"/"+t}])},e.prototype.removeIndex=function(e){var t=this.repeatingFormIndexedAccessors;if(t.delete(e)){var r=[],n=[];t.forEach(function(t,o){o<=e||(t.setIndex(o-1),r.push(o),n.push(t))}),this.executeRenumber(r,n)}},e.prototype.addIndex=function(e){var t=[],r=[];this.repeatingFormIndexedAccessors.forEach(function(n,o){o<e||(n.setIndex(o+1),t.push(o),r.push(n))}),this.executeRenumber(t,r),this.createFormIndexedAccessor(e)},e.prototype.executeRenumber=function(e,t){var r=this.repeatingFormIndexedAccessors;e.forEach(function(e){r.delete(e)}),t.forEach(function(e){r.set(e.index,e)})},Object.defineProperty(e.prototype,"length",{get:function(){return Object(c.resolvePath)(this.state.node,this.path).length},enumerable:!0,configurable:!0}),p([u.observable,l("design:type",Object)],e.prototype,"_error",void 0),p([u.observable,l("design:type",Map)],e.prototype,"repeatingFormIndexedAccessors",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.action,l("design:type",Function),l("design:paramtypes",[String]),l("design:returntype",void 0)],e.prototype,"setError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"clearError",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"disabled",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"error",null),e}(),m=function(){function e(e,t,r,n){this.state=e,this.definition=t,this.parent=r,this._addMode=!1,this.index=n,this.formAccessor=new g(e,t,this,!1)}return e.prototype.initialize=function(){this.formAccessor.initialize()},e.prototype.clear=function(){return this.formAccessor.flatAccessors.forEach(function(e){e.clear()}),this.parent.removeIndex(this.index)},e.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.formAccessor.validate()]})})},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.index},enumerable:!0,configurable:!0}),e.prototype.setIndex=function(e){this.index=e},e.prototype.setError=function(e){this._error=e},e.prototype.setAddMode=function(){this._addMode=!0},e.prototype.clearError=function(){this._error=void 0},Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return this._addMode||this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.accessBySteps=function(e){return 0===e.length?this:this.formAccessor.accessBySteps(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),p([u.observable,l("design:type",Object)],e.prototype,"_error",void 0),p([u.observable,l("design:type",Number)],e.prototype,"index",void 0),p([u.observable,l("design:type",Boolean)],e.prototype,"_addMode",void 0),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.action,l("design:type",Function),l("design:paramtypes",[Number]),l("design:returntype",void 0)],e.prototype,"setIndex",null),p([u.action,l("design:type",Function),l("design:paramtypes",[String]),l("design:returntype",void 0)],e.prototype,"setError",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"setAddMode",null),p([u.action,l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],e.prototype,"clearError",null),p([u.computed,l("design:type",Object),l("design:paramtypes",[])],e.prototype,"error",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),e}(),w=function(){function e(e,t,r,n){this.state=e,this.definition=t,this.parent=r,this.name=n,this.name=n,this.formAccessor=new g(e,t,this,!1)}return e.prototype.initialize=function(){this.formAccessor.initialize()},e.prototype.validate=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.formAccessor.validate()]})})},e.prototype.setError=function(e){},e.prototype.clearError=function(){},e.prototype.clear=function(){},Object.defineProperty(e.prototype,"path",{get:function(){return this.parent.path+"/"+this.name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addMode",{get:function(){return this.parent.addMode},enumerable:!0,configurable:!0}),e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.accessBySteps=function(e){return 0===e.length?this:this.formAccessor.accessBySteps(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),p([u.computed,l("design:type",String),l("design:paramtypes",[])],e.prototype,"path",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"isValid",null),p([u.computed,l("design:type",Boolean),l("design:paramtypes",[])],e.prototype,"addMode",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"accessors",null),p([u.computed,l("design:type",Array),l("design:paramtypes",[])],e.prototype,"flatAccessors",null),e}();function F(e){return e}function O(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/")}function j(e){return Number.isInteger(parseInt(e,10))}function A(e,t){return function e(t,r){var n=r[0],o=r.slice(1);if(0===o.length)return t[n];var i=t[n];if(void 0===i)return;return e(i,o)}(e,O(t))}function P(e,t){return function e(t,r){var n=r[0],o=r.slice(1);0===o.length&&delete t[n];var i=t[n];if(void 0===i)return;e(i,o)}(e,O(t))}var x=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},E=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},S=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},_=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},B=function(){function e(e,t,r){var n=this;this.form=e,this.node=t,this.saveStatus="before",this.additionalErrorTree={},this.noRawUpdate=!1,Object(c.onPatch)(t,function(e){"remove"===e.op?n.removePath(e.path):"add"===e.op?n.addPath(e.path):"replace"===e.op&&n.replacePath(e.path)});var o=null!=r&&r.addMode||!1;if(this.formAccessor=new g(this,this.form.definition,null,o),this.formAccessor.initialize(),null==r)this.saveFunc=M,this.isDisabledFunc=function(){return!1},this.isHiddenFunc=function(){return!1},this.isReadOnlyFunc=function(){return!1},this.isRepeatingFormDisabledFunc=function(){return!1},this.extraValidationFunc=function(){return!1},this.validationBeforeSave="immediate",this.validationAfterSave="immediate",this.validationPauseDuration=0,this.focusFunc=null;else{this.saveFunc=r.save?r.save:M,this.isDisabledFunc=r.isDisabled?r.isDisabled:function(){return!1},this.isHiddenFunc=r.isHidden?r.isHidden:function(){return!1},this.isReadOnlyFunc=r.isReadOnly?r.isReadOnly:function(){return!1},this.isRepeatingFormDisabledFunc=r.isRepeatingFormDisabled?r.isRepeatingFormDisabled:function(){return!1},this.extraValidationFunc=r.extraValidation?r.extraValidation:function(){return!1};var i=r.validation||{};this.validationBeforeSave=i.beforeSave||"immediate",this.validationAfterSave=i.afterSave||"immediate",this.validationPauseDuration=i.pauseDuration||0,this.focusFunc=r.focus?r.focus:null}}return e.prototype.setSaveStatus=function(e){this.saveStatus=e},e.prototype.setValueWithoutRawUpdate=function(e,t){this.noRawUpdate=!0,Object(c.applyPatch)(this.node,[{op:"replace",path:e,value:t}]),this.noRawUpdate=!1},e.prototype.replacePath=function(e){if(!this.noRawUpdate){var t=this.accessByPath(e);void 0!==t&&t instanceof b&&t.setRawFromValue()}},e.prototype.removePath=function(e){var t;try{t=this.accessByPath(e)}catch(e){return}void 0!==t&&t instanceof m&&t.clear()},e.prototype.addPath=function(e){var t=O(e);if(0!==t.length){var r=parseInt(t[t.length-1],10);if(!isNaN(r)){var n=this.accessByPath(function(e){var t=e.join("/");return t.startsWith("/")?t:"/"+t}(t.slice(0,t.length-1)));if(void 0!==n&&n instanceof v){n.addIndex(r);var o=this.accessByPath(e);void 0!==o&&o instanceof m&&o.setAddMode()}}}},e.prototype.validate=function(){return S(this,void 0,void 0,function(){return _(this,function(e){return[2,this.formAccessor.validate()]})})},Object.defineProperty(e.prototype,"isValid",{get:function(){return this.formAccessor.isValid},enumerable:!0,configurable:!0}),e.prototype.save=function(){return S(this,void 0,void 0,function(){var e,t;return _(this,function(r){switch(r.label){case 0:return[4,this.validate()];case 1:return e=r.sent(),this.setSaveStatus("rightAfter"),e?[4,this.saveFunc(this.node)]:[2,!1];case 2:return null!=(t=r.sent())?(this.setErrors(t),[2,!1]):(this.clearErrors(),[2,!0])}})})},e.prototype.setErrors=function(e){var t=function(e){return JSON.parse(JSON.stringify(e))}(e);this.flatAccessors.map(function(r){var n=A(e,r.path);null!=n&&(r.setError(n),P(t,r.path))}),this.additionalErrorTree=t},e.prototype.clearErrors=function(){this.additionalErrorTree={},this.flatAccessors.map(function(e){e.clearError()})},e.prototype.getValue=function(e){return Object(c.resolvePath)(this.node,e)},e.prototype.getMstType=function(e){for(var t=O(e),r=this.form.model,n=0,o=t;n<o.length;n++){var i=o[n];j(i)?r=r.getChildType(i):r=r.getChildType(i)}return r},Object.defineProperty(e.prototype,"isValidating",{get:function(){return this.flatAccessors.some(function(e){return e instanceof b&&e.isValidating})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessors",{get:function(){return this.formAccessor.accessors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flatAccessors",{get:function(){return this.formAccessor.flatAccessors},enumerable:!0,configurable:!0}),e.prototype.accessByPath=function(e){var t=O(e);return this.accessBySteps(t)},e.prototype.accessBySteps=function(e){return this.formAccessor.accessBySteps(e)},e.prototype.access=function(e){return this.formAccessor.access(e)},e.prototype.field=function(e){return this.formAccessor.field(e)},e.prototype.repeatingForm=function(e){return this.formAccessor.repeatingForm(e)},e.prototype.subForm=function(e){return this.formAccessor.subForm(e)},e.prototype.repeatingField=function(e){},e.prototype.additionalError=function(e){var t=this.additionalErrorTree[e];if("string"==typeof t)return t},Object.defineProperty(e.prototype,"additionalErrors",{get:function(){var e=this,t=[];return Object.keys(this.additionalErrorTree).forEach(function(r){var n=e.additionalErrorTree[r];"string"==typeof n&&t.push(n)}),t.sort(),t},enumerable:!0,configurable:!0}),x([u.observable,E("design:type",Object)],e.prototype,"additionalErrorTree",void 0),x([u.observable,E("design:type",String)],e.prototype,"saveStatus",void 0),x([u.action,E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",void 0)],e.prototype,"setSaveStatus",null),x([u.action,E("design:type",Function),E("design:paramtypes",[String,Object]),E("design:returntype",void 0)],e.prototype,"setValueWithoutRawUpdate",null),x([u.action,E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",void 0)],e.prototype,"replacePath",null),x([u.action,E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",void 0)],e.prototype,"removePath",null),x([u.action,E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",void 0)],e.prototype,"addPath",null),x([u.computed,E("design:type",Boolean),E("design:paramtypes",[])],e.prototype,"isValid",null),x([u.action,E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],e.prototype,"save",null),x([u.action,E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",void 0)],e.prototype,"setErrors",null),x([u.action,E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",void 0)],e.prototype,"clearErrors",null),x([u.computed,E("design:type",Boolean),E("design:paramtypes",[])],e.prototype,"isValidating",null),x([u.computed,E("design:type",Array),E("design:paramtypes",[])],e.prototype,"accessors",null),x([u.computed,E("design:type",Array),E("design:paramtypes",[])],e.prototype,"flatAccessors",null),x([u.computed,E("design:type",Array),E("design:paramtypes",[])],e.prototype,"additionalErrors",null),e}();function M(){return S(this,void 0,void 0,function(){return _(this,function(e){return console.warn("No mstform save function configured"),[2,null]})})}var C=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},k=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},I=function(){function e(e,t){this.model=e,this.definition=t}return Object.defineProperty(e.prototype,"FormStateType",{get:function(){throw new Error("For introspection")},enumerable:!0,configurable:!0}),e.prototype.state=function(e,t){return new B(this,e,t)},e}(),D=function(){return function(e){this.definition=e}}(),T=function(){return function(e){this.message=e}}(),q=function(){return function(e){this.value=e}}(),N=function(){function e(e,t){if(this.converter=e,this.options=t,t){if(this.rawValidators=t.rawValidators?t.rawValidators:[],this.validators=t.validators?t.validators:[],this.conversionError=t.conversionError||"Could not convert",this.requiredError=t.requiredError||"Required",this.required=t.required||!1,t.fromEvent){if(t.getRaw)throw new Error("Cannot have fromEvent and getRaw defined at same time");this.getRaw=function(e){return e.target.value}}else this.getRaw=t.getRaw||F;this.derivedFunc=t.derived,this.changeFunc=t.change,this.controlled=t.controlled||this.createDefaultControlled()}else this.rawValidators=[],this.validators=[],this.conversionError="Could not convert",this.requiredError="Required",this.required=!1,this.getRaw=F,this.controlled=this.createDefaultControlled()}return e.prototype.createDefaultControlled=function(){var e=this;return this.getRaw!==F?function(t){return{value:t.raw,onChange:function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return t.setRaw(e.getRaw.apply(e,r))}}}:this.converter.defaultControlled},Object.defineProperty(e.prototype,"RawType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ValueType",{get:function(){throw new Error("This is a function to enable type introspection")},enumerable:!0,configurable:!0}),e.prototype.process=function(e){return C(this,void 0,void 0,function(){var t,r,n,o,i,s;return k(this,function(a){switch(a.label){case 0:if(e===this.converter.emptyRaw&&this.required)return[2,new T(this.requiredError)];t=0,r=this.rawValidators,a.label=1;case 1:return t<r.length?[4,(0,r[t])(e)]:[3,4];case 2:if("string"==typeof(s=a.sent())&&s)return[2,new T(s)];a.label=3;case 3:return t++,[3,1];case 4:return[4,this.converter.convert(e)];case 5:if("ConversionError"===(n=a.sent()))return e===this.converter.emptyRaw?[2,new T(this.requiredError)]:[2,new T(this.conversionError)];o=0,i=this.validators,a.label=6;case 6:return o<i.length?[4,(0,i[o])(n.value)]:[3,9];case 7:if("string"==typeof(s=a.sent())&&s)return[2,new T(s)];a.label=8;case 8:return o++,[3,6];case 9:return[2,new q(n.value)]}})})},e.prototype.render=function(e){return this.converter.render(e)},e}(),z=function(){return function(e){this.definition=e}}(),U=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),W=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})},G=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},H=new RegExp("^-?(0|[1-9]\\d*)(\\.\\d*)?$"),J=new RegExp("^-?(0|[1-9]\\d*)$"),$=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.defaultControlled=n.value,t}return U(t,e),t}(a),K=new $({emptyRaw:"",convert:function(e){return e},render:function(e){return e}}),L=new $({emptyRaw:"",rawValidate:function(e){return e.startsWith(".")&&(e="0"+e),H.test(e)},convert:function(e){return+e},render:function(e){return e.toString()}}),Q=new $({emptyRaw:"",rawValidate:function(e){return J.test(e)},convert:function(e){return+e},render:function(e){return e.toString()}}),X=new a({emptyRaw:!1,convert:function(e){return e},render:function(e){return e},defaultControlled:n.checked}),Y=function(){function e(e,t){this.maxWholeDigits=e,this.decimalPlaces=t,this.defaultControlled=n.value,this.emptyRaw="";var r=new RegExp("^-?(0|[1-9]\\d{0,"+(e-1)+"})(\\.\\d{0,"+t+"})?$");this.converter=new $({emptyRaw:"",rawValidate:function(e){return e.startsWith(".")&&(e="0"+e),r.test(e)},convert:function(e){return e},render:function(e){return e}})}return e.prototype.convert=function(e){return this.converter.convert(e)},e.prototype.render=function(e){return this.converter.render(e)},e.prototype.getRaw=function(e){return e},e}();var Z=new a({emptyRaw:[],convert:function(e){return u.observable.array(e)},render:function(e){return e.slice()}});var ee=function(){function e(e){this.converter=e,this.defaultControlled=n.value,this.emptyRaw=""}return e.prototype.convert=function(e){return W(this,void 0,void 0,function(){return G(this,function(t){return""===e.trim()?[2,new s(null)]:[2,this.converter.convert(e)]})})},e.prototype.render=function(e){return null===e?"":this.converter.render(e)},e}(),te=function(){function e(e){this.emptyRaw=null,this.defaultControlled=n.object}return e.prototype.convert=function(e){return W(this,void 0,void 0,function(){return G(this,function(t){return null===e?[2,"ConversionError"]:[2,new s(e)]})})},e.prototype.render=function(e){return e},e}();var re={string:K,number:L,integer:Q,decimal:function(e,t){return new Y(e,t)},boolean:X,stringArray:Z,maybe:function(e){return e instanceof $?new ee(e):new a({emptyRaw:null,convert:F,render:F,defaultControlled:n.object})},model:function(e){return new te(e)},object:new a({emptyRaw:null,convert:F,render:F})};var ne={validationProps:function(e){var t=e.error,r=e.isValidating;return t?{validateStatus:r?"validating":"error",help:t}:{validateStatus:r?"validating":""}}};r.d(t,"Form",function(){return I}),r.d(t,"SubForm",function(){return D}),r.d(t,"ValidationMessage",function(){return T}),r.d(t,"ProcessValue",function(){return q}),r.d(t,"Field",function(){return N}),r.d(t,"RepeatingForm",function(){return z}),r.d(t,"ConversionValue",function(){return s}),r.d(t,"CONVERSION_ERROR",function(){return"ConversionError"}),r.d(t,"Converter",function(){return a}),r.d(t,"StringConverter",function(){return $}),r.d(t,"converters",function(){return re}),r.d(t,"setupValidationProps",function(){return y}),r.d(t,"FormAccessor",function(){return g}),r.d(t,"FieldAccessor",function(){return b}),r.d(t,"RepeatingFormAccessor",function(){return v}),r.d(t,"RepeatingFormIndexedAccessor",function(){return m}),r.d(t,"SubFormAccessor",function(){return w}),r.d(t,"controlled",function(){return n}),r.d(t,"antd",function(){return ne}),r.d(t,"FormState",function(){return B})}])});
//# sourceMappingURL=mstform.js.map

@@ -1,2 +0,3 @@

import { ArrayEntryType, Field, FormDefinition, FormDefinitionType, RawType, RepeatingForm, ValidationResponse } from "./form";
import { IReactionDisposer } from "mobx";
import { SubForm, ArrayEntryType, Field, FormDefinition, RepeatingFormDefinitionType, SubFormDefinitionType, RawType, RepeatingForm, ValidationResponse } from "./form";
import { FormState } from "./state";

@@ -15,10 +16,9 @@ export interface FieldAccessorAllows {

}
export declare type Accessor = FieldAccessor<any, any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any>;
export declare type Accessor = FormAccessor<any, any> | FieldAccessor<any, any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | SubFormAccessor<any, any>;
export declare type FieldAccess<M, D extends FormDefinition<M>, K extends keyof M> = FieldAccessor<M, RawType<D[K]>, M[K]>;
export declare type RepeatingFormAccess<M, D extends FormDefinition<M>, K extends keyof M> = RepeatingFormAccessor<ArrayEntryType<M[K]>, FormDefinitionType<D[K]>>;
export declare type SubFormAccess<M, D extends FormDefinition<M>, K extends keyof M> = SubFormAccessor<M[K], FormDefinitionType<D[K]>>;
export declare type RepeatingFormAccess<M, D extends FormDefinition<M>, K extends keyof M> = RepeatingFormAccessor<ArrayEntryType<M[K]>, RepeatingFormDefinitionType<D[K]>>;
export declare type SubFormAccess<M, D extends FormDefinition<M>, K extends keyof M> = SubFormAccessor<M[K], SubFormDefinitionType<D[K]>>;
export interface IFormAccessor<M, D extends FormDefinition<M>> {
validate(): Promise<boolean>;
isValid: boolean;
restricted<K extends keyof M>(allowedKeys: K[]): IFormAccessor<M, D>;
field<K extends keyof M>(name: K): FieldAccess<M, D, K>;

@@ -34,16 +34,27 @@ repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>;

definition: any;
path: string;
parent: FormAccessor<any, any> | SubFormAccessor<any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | null;
allowedKeys?: string[] | undefined;
private keys;
constructor(state: FormState<M, D>, definition: any, path: string, allowedKeys?: string[] | undefined);
fieldAccessors: Map<keyof M, FieldAccessor<any, any, any>>;
repeatingFormAccessors: Map<keyof M, RepeatingFormAccessor<any, any>>;
subFormAccessors: Map<keyof M, SubFormAccessor<any, any>>;
_addMode: boolean;
constructor(state: FormState<M, D>, definition: any, parent: FormAccessor<any, any> | SubFormAccessor<any, any> | RepeatingFormAccessor<any, any> | RepeatingFormIndexedAccessor<any, any> | null, addMode: boolean, allowedKeys?: string[] | undefined);
validate(): Promise<boolean>;
setError(error: string): void;
clearError(): void;
clear(): void;
readonly path: string;
readonly isValid: boolean;
readonly accessors: Accessor[];
readonly flatAccessors: Accessor[];
readonly addMode: boolean;
access(name: string): Accessor | undefined;
accessBySteps(steps: string[]): Accessor | undefined;
private getDefinitionEntry;
restricted<K extends keyof M>(allowedKeys: K[]): IFormAccessor<M, D>;
initialize(): void;
createField<K extends keyof M>(name: K, field: Field<any, any>): void;
field<K extends keyof M>(name: K): FieldAccess<M, D, K>;
createRepeatingForm<K extends keyof M>(name: K, repeatingForm: RepeatingForm<any, any>): void;
repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>;
createSubForm<K extends keyof M>(name: K, subForm: SubForm<any, any>): void;
subForm<K extends keyof M>(name: K): SubFormAccess<M, D, K>;

@@ -55,6 +66,13 @@ repeatingField(name: string): any;

field: Field<R, V>;
path: string;
parent: FormAccessor<any, any>;
name: string;
nodePath: string;
constructor(state: FormState<any, any>, field: Field<R, V>, path: string, name: string);
_raw: R | undefined;
_error: string | undefined;
_isValidating: boolean;
_addMode: boolean;
_disposer: IReactionDisposer | undefined;
constructor(state: FormState<any, any>, field: Field<R, V>, parent: FormAccessor<any, any>, name: string);
clear(): void;
readonly path: string;
setDisposer(disposer: IReactionDisposer): void;
createDerivedReaction(): void;

@@ -75,2 +93,5 @@ readonly node: M | undefined;

setRaw(raw: R): Promise<void>;
setRawFromValue(): void;
setError(error: string): void;
clearError(): void;
handleChange: (...args: any[]) => Promise<void>;

@@ -85,7 +106,16 @@ handleFocus: (event: any) => void;

repeatingForm: RepeatingForm<M, D>;
parent: FormAccessor<any, any>;
name: string;
path: string;
constructor(state: FormState<any, any>, repeatingForm: RepeatingForm<M, D>, path: string, name: string);
_error: string | undefined;
repeatingFormIndexedAccessors: Map<number, RepeatingFormIndexedAccessor<any, any>>;
constructor(state: FormState<any, any>, repeatingForm: RepeatingForm<M, D>, parent: FormAccessor<any, any>, name: string);
clear(): void;
readonly path: string;
setError(error: string): void;
clearError(): void;
validate(): Promise<boolean>;
readonly addMode: boolean;
readonly isValid: boolean;
initialize(): void;
createFormIndexedAccessor(index: number): void;
index(index: number): RepeatingFormIndexedAccessor<M, D>;

@@ -100,2 +130,5 @@ readonly disabled: boolean;

remove(node: any): void;
removeIndex(index: number): void;
addIndex(index: number): void;
private executeRenumber;
readonly length: number;

@@ -106,11 +139,21 @@ }

definition: any;
parent: RepeatingFormAccessor<any, any>;
formAccessor: FormAccessor<M, D>;
_error: string | undefined;
index: number;
path: string;
formAccessor: FormAccessor<M, D>;
constructor(state: FormState<any, any>, definition: any, path: string, index: number);
_addMode: boolean;
constructor(state: FormState<any, any>, definition: any, parent: RepeatingFormAccessor<any, any>, index: number);
initialize(): void;
clear(): void;
validate(): Promise<boolean>;
readonly path: string;
setIndex(index: number): void;
setError(error: string): void;
setAddMode(): void;
clearError(): void;
readonly error: string | undefined;
readonly isValid: boolean;
readonly addMode: boolean;
access(name: string): Accessor | undefined;
accessBySteps(steps: string[]): Accessor | undefined;
restricted<K extends keyof M>(allowedKeys: K[]): IFormAccessor<M, D>;
field<K extends keyof M>(name: K): FieldAccess<M, D, K>;

@@ -124,11 +167,16 @@ repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>;

definition: any;
parent: FormAccessor<any, any>;
name: string;
formAccessor: FormAccessor<M, D>;
path: string;
constructor(state: FormState<any, any>, definition: any, path: string, name: string);
constructor(state: FormState<any, any>, definition: any, parent: FormAccessor<any, any>, name: string);
initialize(): void;
validate(): Promise<boolean>;
setError(error: string): void;
clearError(): void;
clear(): void;
readonly path: string;
readonly isValid: boolean;
readonly addMode: boolean;
access(name: string): Accessor | undefined;
accessBySteps(steps: string[]): Accessor | undefined;
restricted<K extends keyof M>(allowedKeys: K[]): IFormAccessor<M, D>;
field<K extends keyof M>(name: K): FieldAccess<M, D, K>;

@@ -135,0 +183,0 @@ repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>;

@@ -8,4 +8,5 @@ import { IObservableArray } from "mobx";

export declare type RawType<F> = F extends Field<infer R, any> ? R : never;
export declare type FormDefinitionType<T> = T extends RepeatingForm<any, infer D> ? D : never;
export declare type FormDefinitionEntry<M, K extends keyof M> = Field<any, M[K]> | RepeatingForm<ArrayEntryType<M[K]>, any> | SubForm<M[K], any>;
export declare type RepeatingFormDefinitionType<T> = T extends RepeatingForm<any, infer D> ? D : never;
export declare type SubFormDefinitionType<T> = T extends SubForm<any, infer D> ? D : never;
export declare type FormDefinitionEntry<M, K extends keyof M> = Field<any, M[K]> | RepeatingForm<ArrayEntryType<M[K]>, FormDefinition<ArrayEntryType<M[K]>>> | SubForm<M[K], FormDefinition<M[K]>>;
export declare type FormDefinition<M> = {

@@ -12,0 +13,0 @@ [K in keyof M]?: FormDefinitionEntry<M, K>;

@@ -6,4 +6,3 @@ export * from "./form";

export * from "./controlled";
export * from "./group";
export * from "./antd";
export * from "./state";

@@ -1,2 +0,1 @@

import { IReactionDisposer } from "mobx";
import { IType } from "mobx-state-tree";

@@ -31,8 +30,3 @@ import { Accessor, ExtraValidation, FieldAccess, FieldAccessor, FieldAccessorAllows, FormAccessor, IFormAccessor, RepeatingFormAccess, RepeatingFormAccessorAllows, SubFormAccess } from "./accessor";

node: M;
raw: Map<string, any>;
errors: Map<string, string>;
additionalErrorTree: any;
validating: Map<string, boolean>;
addModePaths: Map<string, boolean>;
derivedDisposers: Map<string, IReactionDisposer>;
saveStatus: SaveStatusOptions;

@@ -52,10 +46,5 @@ formAccessor: FormAccessor<M, D>;

constructor(form: Form<M, D>, node: M, options?: FormStateOptions<M>);
setError(path: string, value: string): void;
deleteError(path: string): void;
setValidating(path: string, value: boolean): void;
setSaveStatus(status: SaveStatusOptions): void;
setRaw(path: string, value: any): void;
setRawFromValue(path: string): void;
setValueWithoutRawUpdate(path: string, value: any): void;
setDerivedDisposer(path: string, disposer: IReactionDisposer): void;
replacePath(path: string): void;
removePath(path: string): void;

@@ -68,6 +57,3 @@ addPath(path: string): void;

clearErrors(): void;
isKnownAddModePath(path: string): boolean;
addMode(path: string): boolean;
getValue(path: string): any;
getError(path: string): string | undefined;
getMstType(path: string): IType<any, any>;

@@ -80,3 +66,2 @@ readonly isValidating: boolean;

access(name: string): Accessor | undefined;
restricted<K extends keyof M>(allowedKeys: K[]): IFormAccessor<M, D>;
field<K extends keyof M>(name: K): FieldAccess<M, D, K>;

@@ -83,0 +68,0 @@ repeatingForm<K extends keyof M>(name: K): RepeatingFormAccess<M, D, K>;

@@ -7,4 +7,2 @@ export declare function identity<T>(value: T): T;

export declare function deleteByPath(obj: any, path: string): void;
export declare function removePath(map: Map<string, any>, path: string, disposeFunc?: any): Map<string, any>;
export declare function addPath(map: Map<string, any>, path: string): Map<string, any>;
export declare function deepCopy(o: any): any;
{
"name": "mstform",
"version": "0.14.0",
"version": "0.15.0",
"description": "mobx-state-tree powered forms",

@@ -68,2 +68,3 @@ "main": "dist/mstform.js",

"@types/jest": "^22.2.0",
"@types/mobx-devtools-mst": "^0.9.0",
"@types/node": "^10.0.3",

@@ -80,2 +81,3 @@ "@types/react": "^16.2.0",

"mobx": "^4.2.0",
"mobx-devtools-mst": "^0.9.18",
"mobx-react": "^5.0.0",

@@ -82,0 +84,0 @@ "mobx-state-tree": "^2.0.5",

@@ -88,9 +88,17 @@ # mstform README

@observer
class Input extends Component {
render() {
const { type, field } = this.props;
return <input type={type} {...field.inputProps} />;
}
}
@observer
class InlineError extends Component {
render() {
const { children, error } = this.props;
const { children, field } = this.props;
return (
<div>
{children}
<span>{error}</span>
<span>{field.error}</span>
</div>

@@ -113,4 +121,4 @@ );

return (
<InlineError error={field.error}>
<input type="text" {...field.inputProps} />
<InlineError field={field}>
<Input type="text" field={field} />
</InlineError>

@@ -144,6 +152,11 @@ );

We define a simple `InlineError` component that can display error text. Your UI
component library probably has a nicer component that helps to display errors
-- Ant Design for instance has `Form.Item`.
We define a simple `InlineError` component that can display error text. It
takes a `field` and displays its error (which may be empty). Your UI component
library probably has a nicer component that helps to display errors -- Ant
Design for instance has `Form.Item`.
We also define a simple `Input` component that is our input; it takes a `field`
prop too and uses this to set the required input props (`value` and
`onChange`).
We then define a `MyForm` component that actually displays the form. To display

@@ -166,3 +179,3 @@ a form we need to initialize its _form state_. We create the form state with

everything we need: `error` to show the current error, and `inputProps` for the
input component.
input component, so we pass the field to `InlineError` and `Input`.

@@ -216,7 +229,7 @@ I've enabled `ts-check` on top. If you're using vscode you can see

<div>
<InlineError error={name.error}>
<input type="text" {...name.inputProps} />
<InlineError field={name}>
<Input type="text" field={name} />
</InlineError>
<InlineError error={size.error}>
<input type="text" {...name.inputProps} />
<InlineError field={size}>
<Input type="text" field={size} />
</InlineError>

@@ -620,41 +633,2 @@ </div>

## Groups
If you have a form with a lot of fields in the UI you want to split it up into
multiple tabs or menu entries. Each tab is a coherent set of related fields.
But if the underlying model instance is saved as a whole, you need to be able
to show validation issues in other tabs. You can do this using groups.
You can express such groups using `Group`:
```js
const M = types.model("M", {
foo: types.number,
bar: types.number,
baz: types.number,
qux: types.number
});
const groupA = new Group(M, ["foo", "bar"]);
const groupB = new Group(M, ["baz", "qux"]);
const o = M.create({ foo: 1, bar: 2, baz: 3, qux: 4 });
const state = form.state(o);
const accessGroupA = groupA.access(state);
const accessGroupB = groupB.access(state);
```
On `accessGroupA` and `accessGroupB` you can now use `.field()`,
`.repeatingForm()`, as usual. You're not allowed to access any fields you
didn't list in the group.
You can request whether a group state is valid using `isValid`:
```js
const tabAValid = groupA.isValid;
const tabBValid = groupB.isValid;
```
## Disabled, hidden and readOnly fields

@@ -686,4 +660,4 @@

React input widgets support a `readOnly` prop (HTML input does). There is no
such behavior for `hidden`; use `accessor.hidden` in your form rendering code
to determine whether a field wants to be hidden.
such behavior for `hidden`; use `accessor.hidden` in your rendering code to
determine whether a field wants to be hidden.

@@ -853,8 +827,6 @@ ## Extra validation

```js
<InlineError {...field.validationProps}>
<input type="text" {...field.inputProps} />
</InlineError>
<InlineError {...field.validationProps}>...</InlineError>
```
This way if the behavior of InlineError changes to take more props drived from
This way if the behavior of InlineError changes to take more props derived from
a field accessor you can easily change the way `validationProps` is generated.

@@ -864,3 +836,3 @@

- Don't name your form state `this.state` as this has a special meaning
to React and can lead to odd bugs.
- Don't name your form state `this.state` on a React component as this has a
special meaning to React and can lead to odd bugs.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc