react-jsonschema-form-manager
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.JSONSchemaForm=e(require("react")):t.JSONSchemaForm=e(t.React)}(this,function(t){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=2)}([function(t,e,r){"use strict";function n(t){return null===t||void 0===t}function o(t){return!(!t||"object"!==(void 0===t?"undefined":i(t))||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}function a(t,e,r){var a,l;if(n(t)||n(e))return!1;if(t.prototype!==e.prototype)return!1;if(c(t))return!!c(e)&&(t=u.call(t),e=u.call(e),s(t,e,r));if(o(t)){if(!o(e))return!1;if(t.length!==e.length)return!1;for(a=0;a<t.length;a++)if(t[a]!==e[a])return!1;return!0}try{var p=f(t),d=f(e)}catch(t){return!1}if(p.length!=d.length)return!1;for(p.sort(),d.sort(),a=p.length-1;a>=0;a--)if(p[a]!=d[a])return!1;for(a=p.length-1;a>=0;a--)if(l=p[a],!s(t[l],e[l],r))return!1;return(void 0===t?"undefined":i(t))===(void 0===e?"undefined":i(e))}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=Array.prototype.slice,f=r(5),c=r(6),s=t.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=(void 0===t?"undefined":i(t))&&"object"!=(void 0===e?"undefined":i(e))?r.strict?t===e:t==e:a(t,e,r))}},function(t,e,r){"use strict";function n(){return{onChange:function(){},stop:function(){}}}function o(t){return{onChange:function(){return t.updateIfChanged()},stop:function(){}}}function a(t){return function(e){var r=setInterval(function(){return e.updateIfChanged()},t);return{onChange:function(){},stop:function(){return clearInterval(r)}}}}Object.defineProperty(e,"__esModule",{value:!0}),e.ignoreUpdateStrategy=n,e.instantUpdateStrategy=o,e.intervalUpdateStrategy=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3);Object.keys(n).forEach(function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(1);Object.keys(o).forEach(function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})});var a=r(8),i=function(t){return t&&t.__esModule?t:{default:t}}(a);e.default=i.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.RESTFormManager=e.LocalStorageFormManager=void 0;var u=r(4),f=n(u),c=r(0),s=n(c),l=r(7),p=function t(){i(this,t)},d="form",h=(e.LocalStorageFormManager=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;i(this,e);var r=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.doUpdate=function(){return localStorage.setItem(r.key,JSON.stringify(r.formData)),Promise.resolve(r.formData)},r.submit=function(t){return r.formData=t||r.formData,r.doUpdate()},r.onChange=function(t){var e=t.formData;r.formData=e},r.sameData=function(){if(null!==localStorage.getItem(r.key)){return localStorage.getItem(r.key)===JSON.stringify(r.formData)}return!1},r.updateIfChanged=function(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||!r.sameData())return r.doUpdate()},r.key=t,r.formData={},r}return a(e,t),e}(p),function t(e,r,n){var o=this;i(this,t),this.post=function(t){var e=new Request(o.url,{method:"POST",body:JSON.stringify(t)});return(0,l.fetchWithCredentials)(e,o.credentials).then(function(t){return t.json()})},this.put=function(t){var e=o.url+"/"+t[o.idAttribute],r=new Request(e,{method:"PUT",body:JSON.stringify(t)});return(0,l.fetchWithCredentials)(r,o.credentials).then(function(t){return t.json()})},this.patch=function(t,e){var r=o.url+"/"+e[o.idAttribute],n=new Request(r,{method:"PATCH",body:f.default.createPatch(t,e)});return(0,l.fetchWithCredentials)(n,o.credentials).then(function(t){return t.json()})},this.delete=function(){var t=new Request(o.url,{method:"DELETE"});return(0,l.fetchWithCredentials)(t)},this.url=e,this.idAttribute=r,this.credentials=n});e.RESTFormManager=function(t){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id",n=arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,e);var u=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return u.onChange=function(t){var e=t.formData;u.formData=e,u.id&&!e[u.idAttribute]&&(u.formData[u.idAttribute]=u.id)},u.submit=function(t){return u.api.post(t).then(function(t){return u.id=t[u.idAttribute],t})},u.isNew=function(){return void 0===u.formData[u.idAttribute]},u.updateIfChanged=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]||!(0,s.default)(u.formData,u.savedFormData)?u.isNew()?u.submit(u.formData):u.patch?(u.savedFormData=u.formData,u.api.patch(u.savedFormData,u.formData)):(u.savedFormData=u.formData,u.api.put(u.formData)):Promise.resolve(u.formData)},u.idAttribute=r,u.api=new h(t,r,n),u.patch=a,u.formData={},u.savedFormData={},(0,l.checkCredentials)(n),u}return a(e,t),e}(p)},function(t,e,r){"use strict";var n,o,a,i,i,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(r){if("object"===u(e)&&void 0!==t)t.exports=r();else{o=[],n=r,void 0!==(a="function"==typeof n?n.apply(e,o):n)&&(t.exports=a)}}(function(){return function t(e,r,n){function o(u,f){if(!r[u]){if(!e[u]){var c="function"==typeof i&&i;if(!f&&c)return i(u,!0);if(a)return a(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var l=r[u]={exports:{}};e[u][0].call(l.exports,function(t){var r=e[u][1][t];return o(r||t)},l,l.exports,t,e,r,n)}return r[u].exports}for(var a="function"==typeof i&&i,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(t,e,r){function n(t){var e=t.op;return"remove"===e||"replace"===e||"copy"===e||"move"===e}function o(t,e){var r={};for(var n in t)r[n]=1;for(var o in e)delete r[o];return Object.keys(r)}function a(t){var e={};t.forEach(function(t){for(var r in t)e[r]=(e[r]||0)+1});var r=t.length;for(var n in e)e[n]<r&&delete e[n];return Object.keys(e)}function i(t){return void 0===t?"undefined":null===t?"null":Array.isArray(t)?"array":void 0===t?"undefined":u(t)}function f(t){return"add"===t.op}function c(t){return"remove"===t.op}function s(t,e,r){function n(r,a){var i=o[r+","+a];if(void 0===i){if(y(t[r-1],e[a-1]))i=n(r-1,a-1);else{var u=[];if(r>0){var f=n(r-1,a);u.push({operations:f.operations.concat({op:"remove",index:r-1}),cost:f.cost+1})}if(a>0){var c=n(r,a-1);u.push({operations:c.operations.concat({op:"add",index:r-1,value:e[a-1]}),cost:c.cost+1})}if(r>0&&a>0){var s=n(r-1,a-1);u.push({operations:s.operations.concat({op:"replace",index:r-1,original:t[r-1],value:e[a-1]}),cost:s.cost+1})}i=u.sort(function(t,e){return t.cost-e.cost})[0]}o[r+","+a]=i}return i}var o={"0,0":{operations:[],cost:0}},a=isNaN(t.length)||t.length<=0?0:t.length,i=isNaN(e.length)||e.length<=0?0:e.length,u=n(a,i).operations,s=u.reduce(function(t,e){var n=h(t,2),o=n[0],i=n[1];if(f(e)){var u=e.index+1+i,s=u<a+i?String(u):"-",l={op:e.op,path:r.add(s).toString(),value:e.value};return[o.concat(l),i+1]}if(c(e)){var l={op:e.op,path:r.add(String(e.index+i)).toString()};return[o.concat(l),i-1]}var p=r.add(String(e.index+i)),y=d(e.original,e.value,p);return[o.concat.apply(o,v(y)),i]},[[],0]),l=h(s,2),p=l[0];l[1];return p}function l(t,e,r){var n=[];return o(t,e).forEach(function(t){n.push({op:"remove",path:r.add(t).toString()})}),o(e,t).forEach(function(t){n.push({op:"add",path:r.add(t).toString(),value:e[t]})}),a([t,e]).forEach(function(o){n.push.apply(n,v(d(t[o],e[o],r.add(o))))}),n}function p(t,e,r){return y(t,e)?[]:[{op:"replace",path:r.toString(),value:e}]}function d(t,e,r){var n=i(t),o=i(e);return"array"==n&&"array"==o?s(t,e,r):"object"==n&&"object"==o?l(t,e,r):p(t,e,r)}var h=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t)){for(var r,n=[],o=t[Symbol.iterator]();!(r=o.next()).done&&(n.push(r.value),!e||n.length!==e););return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")},v=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)};r.isDestructive=n,r.subtract=o,r.intersection=a,r.objectType=i,r.diffArrays=s,r.diffObjects=l,r.diffValues=p,r.diffAny=d,Object.defineProperty(r,"__esModule",{value:!0});var y=t("./equal").compare},{"./equal":2}],2:[function(t,e,r){function n(t,e){for(var r=[],n=0,o=t.length;n<o;n++)r.push([t[n],e[n]]);return r}function o(t,e){return t.length===e.length&&n(t,e).every(function(t){return i(t[0],t[1])})}function a(t,e){var r=Object.keys(t);return!!o(r,Object.keys(e))&&r.every(function(r){return i(t[r],e[r])})}function i(t,e){return t===e||(Array.isArray(t)&&Array.isArray(e)?o(t,e):Object(t)===t&&Object(e)===e&&a(t,e))}r.compare=i,Object.defineProperty(r,"__esModule",{value:!0})},{}],3:[function(t,e,r){var n=function t(e,r,n){var o=Object.getOwnPropertyDescriptor(e,r);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,r,n)}if("value"in o&&o.writable)return o.value;var i=o.get;if(void 0!==i)return i.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":u(e)));t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(r,"__esModule",{value:!0});r.MissingError=function(t){function e(t){a(this,e),n(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,"Value required at path: "+t),this.path=t,this.name=this.constructor.name}return o(e,t),e}(Error),r.InvalidOperationError=function(t){function e(t){a(this,e),n(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,"Invalid operation: "+t),this.op=t,this.name=this.constructor.name}return o(e,t),e}(Error),r.TestError=function(t){function e(t,r){a(this,e),n(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,"Test failed: "+t+" != "+r),this.actual=t,this.expected=r,this.name=this.constructor.name,this.actual=t,this.expected=r}return o(e,t),e}(Error)},{}],4:[function(t,e,r){function n(t,e){return e.map(function(e){var r=c[e.op];return void 0===r?new u(e.op):r(t,e)})}function o(t,e){var r=new f;return l(t,e,r)}function a(t,e){var r=f.fromJSON(e).evaluate(t);if(void 0!==r)return{op:"test",path:e,value:r.value}}function i(t,e){var r=new Array;return e.filter(p).forEach(function(e){var n=a(t,e.path);if(n&&r.push(n),"from"in e){var o=a(t,e.from);o&&r.push(o)}}),r}r.applyPatch=n,r.createPatch=o,r.createTests=i,Object.defineProperty(r,"__esModule",{value:!0});var u=t("./errors").InvalidOperationError,f=t("./pointer").Pointer,c=function(t){return t&&t.__esModule?t:{default:t}}(t("./patch")),s=t("./diff"),l=s.diffAny,p=s.isDestructive},{"./diff":1,"./errors":3,"./patch":5,"./pointer":6}],5:[function(t,e,r){function n(t,e,r){Array.isArray(t)?"-"==e?t.push(r):t.splice(e,0,r):t[e]=r}function o(t,e){Array.isArray(t)?t.splice(e,1):delete t[e]}function a(t,e){var r=l.fromJSON(e.path).evaluate(t);return void 0===r.parent?new h(e.path):(n(r.parent,r.key,e.value),null)}function i(t,e){var r=l.fromJSON(e.path).evaluate(t);return void 0===r.value?new h(e.path):(o(r.parent,r.key),null)}function u(t,e){var r=l.fromJSON(e.path).evaluate(t);return void 0===r.value?new h(e.path):(r.parent[r.key]=e.value,null)}function f(t,e){var r=l.fromJSON(e.from).evaluate(t);if(void 0===r.value)return new h(e.from);var a=l.fromJSON(e.path).evaluate(t);return void 0===a.parent?new h(e.path):(o(r.parent,r.key),n(a.parent,a.key,r.value),null)}function c(t,e){var r=l.fromJSON(e.from).evaluate(t);if(void 0===r.value)return new h(e.from);var a=l.fromJSON(e.path).evaluate(t);return void 0===a.parent?new h(e.path):(o(r.parent,r.key),n(a.parent,a.key,r.value),null)}function s(t,e){var r=l.fromJSON(e.path).evaluate(t);return p(r.value,e.value)?null:new v(r.value,e.value)}r.add=a,r.remove=i,r.replace=u,r.move=f,r.copy=c,r.test=s,Object.defineProperty(r,"__esModule",{value:!0});var l=t("./pointer").Pointer,p=t("./equal").compare,d=t("./errors"),h=d.MissingError,v=d.TestError},{"./equal":2,"./errors":3,"./pointer":6}],6:[function(t,e,r){function n(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function o(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}var a=function(){function t(t,e){for(var r in e){var n=e[r];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(r,"__esModule",{value:!0});r.Pointer=function(){function t(){var e=void 0===arguments[0]?[""]:arguments[0];i(this,t),this.tokens=e}return a(t,{toString:{value:function(){return this.tokens.map(o).join("/")}},evaluate:{value:function(t){for(var e=null,r=null,n=1,o=this.tokens.length;n<o;n++)e=t,r=this.tokens[n],t=(e||{})[r];return{parent:e,key:r,value:t}}},push:{value:function(t){this.tokens.push(t)}},add:{value:function(e){return new t(this.tokens.concat(String(e)))}}},{fromJSON:{value:function(e){var r=e.split("/").map(n);if(""!==r[0])throw new Error("Invalid JSON Pointer: "+e);return new t(r)}}}),t}()},{}]},{},[4])(4)})},function(t,e,r){"use strict";function n(t){var e=[];for(var r in t)e.push(r);return e}e=t.exports="function"==typeof Object.keys?Object.keys:n,e.shim=n},function(t,e,r){"use strict";function n(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==(void 0===t?"undefined":a(t))&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();e=t.exports=i?n:o,e.supported=n,e.unsupported=o},function(t,e,r){"use strict";function n(t){if(void 0!==t&&null!==t&&"object"!==(void 0===t?"undefined":a(t))&&"function"!=typeof t)throw new Error("Credentials can be object or function(req)")}function o(t,e){if(void 0===e||null===e)return fetch(t);if("object"===(void 0===e?"undefined":a(e)))return fetch(t,e);var r=e(t);return Promise.resolve(r).then(function(t){return fetch(t)})}Object.defineProperty(e,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.checkCredentials=n,e.fetchWithCredentials=o},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(){return d.default.createElement("div",{className:"container"},d.default.createElement("h1",null,"Loading"))}function f(t){var e=t.error.message;return d.default.createElement("div",{className:"container"},d.default.createElement("h4",null,"Error"),d.default.createElement("h2",null,e))}function c(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.ignoreUpdateStrategy;r=r(e),v.default.checkPropTypes(g,{configPromise:t,manager:e,updateStrategy:r},"props","react-jsonschema-form-manager");var n=e.updateIfChanged;return e.updateIfChanged=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=n(t);return r&&r.then(function(t){return e.onUpdate(t)}),r},function(n,c,h){return function(p){function v(n){o(this,v);var i=a(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,n));return i.updateExternal=function(t,e){i.formData=t.formData,i.setState({formData:t.formData}),e&&e(t)},i.handleChange=function(t){e.onChange(t),r.onChange(t),i.updateExternal(t,i.props.onChange)},i.handleSubmit=function(t){e.submit(t.formData).then(function(){i.updateExternal(t,i.props.onSubmit)})},i.handleUpdate=function(t){i.setState({formData:t}),i.props.onUpdate&&i.props.onUpdate(t)},i.state={isLoading:!0,isError:!1,configPromise:t},e.onUpdate=i.handleUpdate,i}return i(v,p),l(v,[{key:"componentWillUnmount",value:function(){e.stop()}},{key:"shouldComponentUpdate",value:function(t,e){var r=(0,m.default)(e.formData,this.formData),n=e.isLoading===this.state.isLoading&&e.isError===this.state.isError;return!(0,m.default)(this.props,t)||!r||!n}},{key:"componentWillMount",value:function(){var t=this;this.state.configPromise.then(function(e){t.setState({isLoading:!1,isEqual:!1,config:e,formData:e.formData})}).catch(function(e){t.setState({isLoading:!1,isError:!0,error:e})})}},{key:"render",value:function(){var t=this.state,e=t.isLoading,r=t.isError,o=t.error,a=t.config,i=t.formData;if(e)return c?d.default.createElement(c,null):d.default.createElement(u,null);if(r)return h?d.default.createElement(h,{error:o}):d.default.createElement(f,{error:o});var l=Object.assign({},this.props,a,{formData:i});return d.default.createElement(n,s({},l,{onSubmit:this.handleSubmit,onChange:this.handleChange}))}}]),v}(p.Component)}}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},l=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.default=c;var p=r(9),d=n(p),h=r(10),v=n(h),y=r(0),m=n(y),b=r(1),g={configPromise:v.default.shape({then:v.default.func.isRequired}).isRequired,manager:v.default.shape({onChange:v.default.func.isRequired,submit:v.default.func.isRequired,updateIfChanged:v.default.func.isRequired}).isRequired,updateStrategy:v.default.shape({onChange:v.default.func.isRequired,stop:v.default.func.isRequired}).isRequired}},function(e,r){e.exports=t},function(t,e,r){"use strict";"function"==typeof Symbol&&Symbol.iterator;t.exports=r(11)()},function(t,e,r){"use strict";var n=r(12),o=r(13),a=r(14);t.exports=function(){function t(t,e,r,n,i,u){u!==a&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function e(){return t}t.isRequired=t;var r={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e};return r.checkPropTypes=n,r.PropTypes=r,r}},function(t,e,r){"use strict";function n(t){return function(){return t}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(t){return t},t.exports=o},function(t,e,r){"use strict";function n(t,e,r,n,a,i,u,f){if(o(e),!t){var c;if(void 0===e)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[r,n,a,i,u,f],l=0;c=new Error(e.replace(/%s/g,function(){return s[l++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var o=function(t){};t.exports=n},function(t,e,r){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.JSONSchemaForm=e(require("react")):t.JSONSchemaForm=e(t.React)}(this,function(t){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=2)}([function(t,e,r){"use strict";function n(t){return null===t||void 0===t}function o(t){return!(!t||"object"!==(void 0===t?"undefined":i(t))||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}function a(t,e,r){var a,l;if(n(t)||n(e))return!1;if(t.prototype!==e.prototype)return!1;if(c(t))return!!c(e)&&(t=u.call(t),e=u.call(e),s(t,e,r));if(o(t)){if(!o(e))return!1;if(t.length!==e.length)return!1;for(a=0;a<t.length;a++)if(t[a]!==e[a])return!1;return!0}try{var p=f(t),d=f(e)}catch(t){return!1}if(p.length!=d.length)return!1;for(p.sort(),d.sort(),a=p.length-1;a>=0;a--)if(p[a]!=d[a])return!1;for(a=p.length-1;a>=0;a--)if(l=p[a],!s(t[l],e[l],r))return!1;return(void 0===t?"undefined":i(t))===(void 0===e?"undefined":i(e))}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=Array.prototype.slice,f=r(5),c=r(6),s=t.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=(void 0===t?"undefined":i(t))&&"object"!=(void 0===e?"undefined":i(e))?r.strict?t===e:t==e:a(t,e,r))}},function(t,e,r){"use strict";function n(){return{onChange:function(){},stop:function(){}}}function o(t){return{onChange:function(){return t.updateIfChanged()},stop:function(){}}}function a(t){return function(e){var r=setInterval(function(){return e.updateIfChanged()},t);return{onChange:function(){},stop:function(){return clearInterval(r)}}}}Object.defineProperty(e,"__esModule",{value:!0}),e.ignoreUpdateStrategy=n,e.instantUpdateStrategy=o,e.intervalUpdateStrategy=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3);Object.keys(n).forEach(function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(1);Object.keys(o).forEach(function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})});var a=r(8),i=function(t){return t&&t.__esModule?t:{default:t}}(a);e.default=i.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.RESTFormManager=e.LocalStorageFormManager=void 0;var u=r(4),f=n(u),c=r(0),s=n(c),l=r(7),p=function t(){i(this,t)},d="form",h=(e.LocalStorageFormManager=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;i(this,e);var r=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.doUpdate=function(){return localStorage.setItem(r.key,JSON.stringify(r.formData)),Promise.resolve(r.formData)},r.submit=function(t){return r.formData=t||r.formData,r.doUpdate()},r.onChange=function(t){var e=t.formData;r.formData=e},r.sameData=function(){if(null!==localStorage.getItem(r.key)){return localStorage.getItem(r.key)===JSON.stringify(r.formData)}return!1},r.updateIfChanged=function(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||!r.sameData())return r.doUpdate()},r.key=t,r.formData={},r}return a(e,t),e}(p),function t(e,r){var n=this;i(this,t),this.post=function(t){var e=new Request(n.url,{method:"POST",body:JSON.stringify(t)});return(0,l.fetchWithCredentials)(e,n.credentials).then(function(t){return t.json()})},this.put=function(t,e){var r=n.url+"/"+t,o=new Request(r,{method:"PUT",body:JSON.stringify(e)});return(0,l.fetchWithCredentials)(o,n.credentials).then(function(t){return t.json()})},this.patch=function(t,e,r){var o=n.url+"/"+t,a=new Request(o,{method:"PATCH",body:f.default.createPatch(e,r)});return(0,l.fetchWithCredentials)(a,n.credentials).then(function(t){return t.json()})},this.url=e,this.credentials=r});e.RESTFormManager=function(t){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id",n=arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,e);var u=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return u.onChange=function(t){var e=t.formData;u.formData=e,u.id||(u.id=u.toID(e))},u.submit=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.api.post(t).then(function(t){return u.id=u.toID(t),t})},u.isNew=function(){return void 0===u.id},u.updateIfChanged=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]||!(0,s.default)(u.formData,u.savedFormData)?u.isNew()?u.submit(u.formData):u.patch?(u.savedFormData=u.formData,u.api.patch(u.id,u.savedFormData,u.formData)):(u.savedFormData=u.formData,u.api.put(u.id,u.formData)):Promise.resolve(u.formData)},u.toID="function"==typeof r?r:function(t){return t[r]},u.api=new h(t,r,n),u.patch=a,u.formData={},u.savedFormData={},(0,l.checkCredentials)(n),u}return a(e,t),e}(p)},function(t,e,r){"use strict";var n,o,a,i,i,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(r){if("object"===u(e)&&void 0!==t)t.exports=r();else{o=[],n=r,void 0!==(a="function"==typeof n?n.apply(e,o):n)&&(t.exports=a)}}(function(){return function t(e,r,n){function o(u,f){if(!r[u]){if(!e[u]){var c="function"==typeof i&&i;if(!f&&c)return i(u,!0);if(a)return a(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var l=r[u]={exports:{}};e[u][0].call(l.exports,function(t){var r=e[u][1][t];return o(r||t)},l,l.exports,t,e,r,n)}return r[u].exports}for(var a="function"==typeof i&&i,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(t,e,r){function n(t){var e=t.op;return"remove"===e||"replace"===e||"copy"===e||"move"===e}function o(t,e){var r={};for(var n in t)r[n]=1;for(var o in e)delete r[o];return Object.keys(r)}function a(t){var e={};t.forEach(function(t){for(var r in t)e[r]=(e[r]||0)+1});var r=t.length;for(var n in e)e[n]<r&&delete e[n];return Object.keys(e)}function i(t){return void 0===t?"undefined":null===t?"null":Array.isArray(t)?"array":void 0===t?"undefined":u(t)}function f(t){return"add"===t.op}function c(t){return"remove"===t.op}function s(t,e,r){function n(r,a){var i=o[r+","+a];if(void 0===i){if(y(t[r-1],e[a-1]))i=n(r-1,a-1);else{var u=[];if(r>0){var f=n(r-1,a);u.push({operations:f.operations.concat({op:"remove",index:r-1}),cost:f.cost+1})}if(a>0){var c=n(r,a-1);u.push({operations:c.operations.concat({op:"add",index:r-1,value:e[a-1]}),cost:c.cost+1})}if(r>0&&a>0){var s=n(r-1,a-1);u.push({operations:s.operations.concat({op:"replace",index:r-1,original:t[r-1],value:e[a-1]}),cost:s.cost+1})}i=u.sort(function(t,e){return t.cost-e.cost})[0]}o[r+","+a]=i}return i}var o={"0,0":{operations:[],cost:0}},a=isNaN(t.length)||t.length<=0?0:t.length,i=isNaN(e.length)||e.length<=0?0:e.length,u=n(a,i).operations,s=u.reduce(function(t,e){var n=h(t,2),o=n[0],i=n[1];if(f(e)){var u=e.index+1+i,s=u<a+i?String(u):"-",l={op:e.op,path:r.add(s).toString(),value:e.value};return[o.concat(l),i+1]}if(c(e)){var l={op:e.op,path:r.add(String(e.index+i)).toString()};return[o.concat(l),i-1]}var p=r.add(String(e.index+i)),y=d(e.original,e.value,p);return[o.concat.apply(o,v(y)),i]},[[],0]),l=h(s,2),p=l[0];l[1];return p}function l(t,e,r){var n=[];return o(t,e).forEach(function(t){n.push({op:"remove",path:r.add(t).toString()})}),o(e,t).forEach(function(t){n.push({op:"add",path:r.add(t).toString(),value:e[t]})}),a([t,e]).forEach(function(o){n.push.apply(n,v(d(t[o],e[o],r.add(o))))}),n}function p(t,e,r){return y(t,e)?[]:[{op:"replace",path:r.toString(),value:e}]}function d(t,e,r){var n=i(t),o=i(e);return"array"==n&&"array"==o?s(t,e,r):"object"==n&&"object"==o?l(t,e,r):p(t,e,r)}var h=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t)){for(var r,n=[],o=t[Symbol.iterator]();!(r=o.next()).done&&(n.push(r.value),!e||n.length!==e););return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")},v=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)};r.isDestructive=n,r.subtract=o,r.intersection=a,r.objectType=i,r.diffArrays=s,r.diffObjects=l,r.diffValues=p,r.diffAny=d,Object.defineProperty(r,"__esModule",{value:!0});var y=t("./equal").compare},{"./equal":2}],2:[function(t,e,r){function n(t,e){for(var r=[],n=0,o=t.length;n<o;n++)r.push([t[n],e[n]]);return r}function o(t,e){return t.length===e.length&&n(t,e).every(function(t){return i(t[0],t[1])})}function a(t,e){var r=Object.keys(t);return!!o(r,Object.keys(e))&&r.every(function(r){return i(t[r],e[r])})}function i(t,e){return t===e||(Array.isArray(t)&&Array.isArray(e)?o(t,e):Object(t)===t&&Object(e)===e&&a(t,e))}r.compare=i,Object.defineProperty(r,"__esModule",{value:!0})},{}],3:[function(t,e,r){var n=function t(e,r,n){var o=Object.getOwnPropertyDescriptor(e,r);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,r,n)}if("value"in o&&o.writable)return o.value;var i=o.get;if(void 0!==i)return i.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":u(e)));t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(r,"__esModule",{value:!0});r.MissingError=function(t){function e(t){a(this,e),n(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,"Value required at path: "+t),this.path=t,this.name=this.constructor.name}return o(e,t),e}(Error),r.InvalidOperationError=function(t){function e(t){a(this,e),n(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,"Invalid operation: "+t),this.op=t,this.name=this.constructor.name}return o(e,t),e}(Error),r.TestError=function(t){function e(t,r){a(this,e),n(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,"Test failed: "+t+" != "+r),this.actual=t,this.expected=r,this.name=this.constructor.name,this.actual=t,this.expected=r}return o(e,t),e}(Error)},{}],4:[function(t,e,r){function n(t,e){return e.map(function(e){var r=c[e.op];return void 0===r?new u(e.op):r(t,e)})}function o(t,e){var r=new f;return l(t,e,r)}function a(t,e){var r=f.fromJSON(e).evaluate(t);if(void 0!==r)return{op:"test",path:e,value:r.value}}function i(t,e){var r=new Array;return e.filter(p).forEach(function(e){var n=a(t,e.path);if(n&&r.push(n),"from"in e){var o=a(t,e.from);o&&r.push(o)}}),r}r.applyPatch=n,r.createPatch=o,r.createTests=i,Object.defineProperty(r,"__esModule",{value:!0});var u=t("./errors").InvalidOperationError,f=t("./pointer").Pointer,c=function(t){return t&&t.__esModule?t:{default:t}}(t("./patch")),s=t("./diff"),l=s.diffAny,p=s.isDestructive},{"./diff":1,"./errors":3,"./patch":5,"./pointer":6}],5:[function(t,e,r){function n(t,e,r){Array.isArray(t)?"-"==e?t.push(r):t.splice(e,0,r):t[e]=r}function o(t,e){Array.isArray(t)?t.splice(e,1):delete t[e]}function a(t,e){var r=l.fromJSON(e.path).evaluate(t);return void 0===r.parent?new h(e.path):(n(r.parent,r.key,e.value),null)}function i(t,e){var r=l.fromJSON(e.path).evaluate(t);return void 0===r.value?new h(e.path):(o(r.parent,r.key),null)}function u(t,e){var r=l.fromJSON(e.path).evaluate(t);return void 0===r.value?new h(e.path):(r.parent[r.key]=e.value,null)}function f(t,e){var r=l.fromJSON(e.from).evaluate(t);if(void 0===r.value)return new h(e.from);var a=l.fromJSON(e.path).evaluate(t);return void 0===a.parent?new h(e.path):(o(r.parent,r.key),n(a.parent,a.key,r.value),null)}function c(t,e){var r=l.fromJSON(e.from).evaluate(t);if(void 0===r.value)return new h(e.from);var a=l.fromJSON(e.path).evaluate(t);return void 0===a.parent?new h(e.path):(o(r.parent,r.key),n(a.parent,a.key,r.value),null)}function s(t,e){var r=l.fromJSON(e.path).evaluate(t);return p(r.value,e.value)?null:new v(r.value,e.value)}r.add=a,r.remove=i,r.replace=u,r.move=f,r.copy=c,r.test=s,Object.defineProperty(r,"__esModule",{value:!0});var l=t("./pointer").Pointer,p=t("./equal").compare,d=t("./errors"),h=d.MissingError,v=d.TestError},{"./equal":2,"./errors":3,"./pointer":6}],6:[function(t,e,r){function n(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function o(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}var a=function(){function t(t,e){for(var r in e){var n=e[r];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(r,"__esModule",{value:!0});r.Pointer=function(){function t(){var e=void 0===arguments[0]?[""]:arguments[0];i(this,t),this.tokens=e}return a(t,{toString:{value:function(){return this.tokens.map(o).join("/")}},evaluate:{value:function(t){for(var e=null,r=null,n=1,o=this.tokens.length;n<o;n++)e=t,r=this.tokens[n],t=(e||{})[r];return{parent:e,key:r,value:t}}},push:{value:function(t){this.tokens.push(t)}},add:{value:function(e){return new t(this.tokens.concat(String(e)))}}},{fromJSON:{value:function(e){var r=e.split("/").map(n);if(""!==r[0])throw new Error("Invalid JSON Pointer: "+e);return new t(r)}}}),t}()},{}]},{},[4])(4)})},function(t,e,r){"use strict";function n(t){var e=[];for(var r in t)e.push(r);return e}e=t.exports="function"==typeof Object.keys?Object.keys:n,e.shim=n},function(t,e,r){"use strict";function n(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==(void 0===t?"undefined":a(t))&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();e=t.exports=i?n:o,e.supported=n,e.unsupported=o},function(t,e,r){"use strict";function n(t){if(void 0!==t&&null!==t&&"object"!==(void 0===t?"undefined":a(t))&&"function"!=typeof t)throw new Error("Credentials can be object or function(req)")}function o(t,e){if(void 0===e||null===e)return fetch(t);if("object"===(void 0===e?"undefined":a(e)))return fetch(t,e);var r=e(t);return Promise.resolve(r).then(function(t){return fetch(t)})}Object.defineProperty(e,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.checkCredentials=n,e.fetchWithCredentials=o},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(){return d.default.createElement("div",{className:"container"},d.default.createElement("h1",null,"Loading"))}function f(t){var e=t.error.message;return d.default.createElement("div",{className:"container"},d.default.createElement("h4",null,"Error"),d.default.createElement("h2",null,e))}function c(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.ignoreUpdateStrategy;r=r(e),v.default.checkPropTypes(g,{configPromise:t,manager:e,updateStrategy:r},"props","react-jsonschema-form-manager");var n=e.updateIfChanged;return e.updateIfChanged=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=n(t);return r&&r.then(function(t){return e.onUpdate(t)}),r},function(n,c,h){return function(p){function v(n){o(this,v);var i=a(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,n));return i.updateExternal=function(t,e){i.formData=t.formData,i.setState({formData:t.formData}),e&&e(t)},i.handleChange=function(t){e.onChange(t),r.onChange(t),i.updateExternal(t,i.props.onChange)},i.handleSubmit=function(t){e.submit(t.formData).then(function(){i.updateExternal(t,i.props.onSubmit)})},i.handleUpdate=function(t){i.setState({formData:t}),i.props.onUpdate&&i.props.onUpdate(t)},i.state={isLoading:!0,isError:!1,configPromise:t},e.onUpdate=i.handleUpdate,i}return i(v,p),l(v,[{key:"componentWillUnmount",value:function(){e.stop()}},{key:"shouldComponentUpdate",value:function(t,e){var r=(0,m.default)(e.formData,this.formData),n=e.isLoading===this.state.isLoading&&e.isError===this.state.isError;return!(0,m.default)(this.props,t)||!r||!n}},{key:"componentWillMount",value:function(){var t=this;this.state.configPromise.then(function(e){t.setState({isLoading:!1,isEqual:!1,config:e,formData:e.formData})}).catch(function(e){t.setState({isLoading:!1,isError:!0,error:e})})}},{key:"render",value:function(){var t=this.state,e=t.isLoading,r=t.isError,o=t.error,a=t.config,i=t.formData;if(e)return c?d.default.createElement(c,null):d.default.createElement(u,null);if(r)return h?d.default.createElement(h,{error:o}):d.default.createElement(f,{error:o});var l=Object.assign({},this.props,a,{formData:i});return d.default.createElement(n,s({},l,{onSubmit:this.handleSubmit,onChange:this.handleChange}))}}]),v}(p.Component)}}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},l=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.default=c;var p=r(9),d=n(p),h=r(10),v=n(h),y=r(0),m=n(y),b=r(1),g={configPromise:v.default.shape({then:v.default.func.isRequired}).isRequired,manager:v.default.shape({onChange:v.default.func.isRequired,submit:v.default.func.isRequired,updateIfChanged:v.default.func.isRequired}).isRequired,updateStrategy:v.default.shape({onChange:v.default.func.isRequired,stop:v.default.func.isRequired}).isRequired}},function(e,r){e.exports=t},function(t,e,r){"use strict";"function"==typeof Symbol&&Symbol.iterator;t.exports=r(11)()},function(t,e,r){"use strict";var n=r(12),o=r(13),a=r(14);t.exports=function(){function t(t,e,r,n,i,u){u!==a&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function e(){return t}t.isRequired=t;var r={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e};return r.checkPropTypes=n,r.PropTypes=r,r}},function(t,e,r){"use strict";function n(t){return function(){return t}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(t){return t},t.exports=o},function(t,e,r){"use strict";function n(t,e,r,n,a,i,u,f){if(o(e),!t){var c;if(void 0===e)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[r,n,a,i,u,f],l=0;c=new Error(e.replace(/%s/g,function(){return s[l++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var o=function(t){};t.exports=n},function(t,e,r){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); | ||
//# sourceMappingURL=main.js.map |
@@ -86,3 +86,3 @@ "use strict"; | ||
var RESTAPI = function RESTAPI(url, id, credentials) { | ||
var RESTAPI = function RESTAPI(url, credentials) { | ||
var _this2 = this; | ||
@@ -102,4 +102,4 @@ | ||
this.put = function (formData) { | ||
var putUrl = _this2.url + "/" + formData[_this2.idAttribute]; | ||
this.put = function (id, formData) { | ||
var putUrl = _this2.url + "/" + id; | ||
var putReq = new Request(putUrl, { | ||
@@ -114,4 +114,4 @@ method: "PUT", | ||
this.patch = function (oldFormData, formData) { | ||
var patchUrl = _this2.url + "/" + formData[_this2.idAttribute]; | ||
this.patch = function (id, oldFormData, formData) { | ||
var patchUrl = _this2.url + "/" + id; | ||
var patchReq = new Request(patchUrl, { | ||
@@ -126,11 +126,3 @@ method: "PATCH", | ||
this.delete = function () { | ||
var deleteReq = new Request(_this2.url, { | ||
method: "DELETE" | ||
}); | ||
return (0, _utils.fetchWithCredentials)(deleteReq); | ||
}; | ||
this.url = url; | ||
this.idAttribute = id; | ||
this.credentials = credentials; | ||
@@ -143,3 +135,3 @@ }; | ||
function RESTFormManager(url) { | ||
var idAttribute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "id"; | ||
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "id"; | ||
var credentials = arguments[2]; | ||
@@ -156,10 +148,12 @@ var patch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
_this3.formData = formData; | ||
if (_this3.id && !formData[_this3.idAttribute]) { | ||
_this3.formData[_this3.idAttribute] = _this3.id; | ||
if (!_this3.id) { | ||
_this3.id = _this3.toID(formData); | ||
} | ||
}; | ||
_this3.submit = function (formData) { | ||
_this3.submit = function () { | ||
var formData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return _this3.api.post(formData).then(function (saved) { | ||
_this3.id = saved[_this3.idAttribute]; | ||
_this3.id = _this3.toID(saved); | ||
return saved; | ||
@@ -170,3 +164,3 @@ }); | ||
_this3.isNew = function () { | ||
return _this3.formData[_this3.idAttribute] === undefined; | ||
return _this3.id === undefined; | ||
}; | ||
@@ -184,11 +178,13 @@ | ||
_this3.savedFormData = _this3.formData; | ||
return _this3.api.patch(_this3.savedFormData, _this3.formData); | ||
return _this3.api.patch(_this3.id, _this3.savedFormData, _this3.formData); | ||
} else { | ||
_this3.savedFormData = _this3.formData; | ||
return _this3.api.put(_this3.formData); | ||
return _this3.api.put(_this3.id, _this3.formData); | ||
} | ||
}; | ||
_this3.idAttribute = idAttribute; | ||
_this3.api = new RESTAPI(url, idAttribute, credentials); | ||
_this3.toID = typeof id === "function" ? id : function (formData) { | ||
return formData[id]; | ||
}; | ||
_this3.api = new RESTAPI(url, id, credentials); | ||
_this3.patch = patch; | ||
@@ -195,0 +191,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"author": "mavarazy@gmail.com", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"scripts": { | ||
@@ -9,0 +9,0 @@ "build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226605
477