formhero/docs/errorsAndValidation.1ec8a0d3.js

19 lines
127 KiB
JavaScript
Raw Normal View History

2019-09-28 17:05:41 +00:00
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"J4Nk":[function(require,module,exports) {
"use strict";var r=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(r){if(null==r)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function o(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de","5"===Object.getOwnPropertyNames(r)[0])return!1;for(var t={},e=0;e<10;e++)t["_"+String.fromCharCode(e)]=e;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(r){return t[r]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(r){n[r]=r}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(o){return!1}}module.exports=o()?Object.assign:function(o,c){for(var a,i,s=n(o),f=1;f<arguments.length;f++){for(var u in a=Object(arguments[f]))t.call(a,u)&&(s[u]=a[u]);if(r){i=r(a);for(var b=0;b<i.length;b++)e.call(a,i[b])&&(s[i[b]]=a[i[b]])}}return s};
},{}],"awqi":[function(require,module,exports) {
"use strict";var e=require("object-assign"),t="function"==typeof Symbol&&Symbol.for,r=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,o=t?Symbol.for("react.fragment"):60107,u=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,f=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,i=t?Symbol.for("react.forward_ref"):60112,a=t?Symbol.for("react.suspense"):60113,s=t?Symbol.for("react.suspense_list"):60120,p=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116;t&&Symbol.for("react.fundamental"),t&&Symbol.for("react.responder");var d="function"==typeof Symbol&&Symbol.iterator;function m(e){for(var t=e.message,r="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)r+="&args[]="+encodeURIComponent(arguments[n]);return e.message="Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",e}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function b(e,t,r){this.props=e,this.context=t,this.refs=h,this.updater=r||v}function S(){}function _(e,t,r){this.props=e,this.context=t,this.refs=h,this.updater=r||v}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw m(Error(85));this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},S.prototype=b.prototype;var g=_.prototype=new S;g.constructor=_,e(g,b.prototype),g.isPureReactComponent=!0;var k={current:null},$={suspense:null},w={current:null},C=Object.prototype.hasOwnProperty,E={key:!0,ref:!0,__self:!0,__source:!0};function R(e,t,n){var o=void 0,u={},l=null,f=null;if(null!=t)for(o in void 0!==t.ref&&(f=t.ref),void 0!==t.key&&(l=""+t.key),t)C.call(t,o)&&!E.hasOwnProperty(o)&&(u[o]=t[o]);var c=arguments.length-2;if(1===c)u.children=n;else if(1<c){for(var i=Array(c),a=0;a<c;a++)i[a]=arguments[a+2];u.children=i}if(e&&e.defaultProps)for(o in c=e.defaultProps)void 0===u[o]&&(u[o]=c[o]);return{$$typeof:r,type:e,key:l,ref:f,props:u,_owner:w.current}}function x(e,t){return{$$typeof:r,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function P(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function j(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}var O=/\/+/g,A=[];function I(e,t,r,n){if(A.length){var o=A.pop();return o.result=e,o.keyPrefix=t,o.func=r,o.context=n,o.count=0,o}return{result:e,keyPrefix:t,func:r,context:n,count:0}}function U(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>A.length&&A.push(e)}function q(e,t,o,u){var l=typeof e;"undefined"!==l&&"boolean"!==l||(e=null);var f=!1;if(null===e)f=!0;else switch(l){case"string":case"number":f=!0;break;case"object":switch(e.$$typeof){case r:case n:f=!0}}if(f)return o(u,e,""===t?"."+F(e,0):t),1;if(f=0,t=""===t?".":t+":",Array.isArray(e))for(var c=0;c<e.length;c++){var i=t+F(l=e[c],c);f+=q(l,i,o,u)}else if(null===e||"object"!=typeof e?i=null:i="function"==typeof(i=d&&e[d]||e["@@iterator"])?i:null,"function"==typeof i)for(e=i.call(e),c=0;!(l=e.next()).done;)f+=q(l=l.value,i=t+F(l,c++),o,u);else if("object"===l)throw o=""+e,m(Error(31),"[object Object]"===o?"object with keys {"+Object.keys(e).join(", ")+"}":o,"");return f}function L(e,t,r){return null==e?0:q(e,"",t,r)}function F(e,t){return"object"==typeof e&&null!==e&&null!=e.key?j(e.key):t.toString(36)}function M(e,t){e.func.call(e.context,t,e.count++)}function D(e,t,r){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,t,e.count++),Array.isArray(e)?V(e,n,r,function(e){return e}):null!=e&&(P(e)&&(e=x(e,o+(!e.key||t&&t.key===e.key?"":(""+e.key).replace(O,"$&/")+"/")+r)),n.push(e))}function V(e,t,r,n,o){var u="";null!=r&&(u=(""+r).replace(O,"$&/")+"/"),L(e,D,t=I(t,u,n,o)),U(t)}function B(){var e=k.current;if(null===e)throw m(Error(321));return e}var N={Children
},{"object-assign":"J4Nk"}],"1n8/":[function(require,module,exports) {
"use strict";module.exports=require("./cjs/react.production.min.js");
},{"./cjs/react.production.min.js":"awqi"}],"5IvP":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=void 0,n=void 0,t=void 0,r=void 0,o=void 0;if(exports.unstable_now=void 0,exports.unstable_forceFrameRate=void 0,"undefined"==typeof window||"function"!=typeof MessageChannel){var i=null,l=null,u=function(){if(null!==i)try{var e=exports.unstable_now();i(!0,e),i=null}catch(n){throw setTimeout(u,0),n}};exports.unstable_now=function(){return Date.now()},e=function(n){null!==i?setTimeout(e,0,n):(i=n,setTimeout(u,0))},n=function(e,n){l=setTimeout(e,n)},t=function(){clearTimeout(l)},r=function(){return!1},o=exports.unstable_forceFrameRate=function(){}}else{var a=window.performance,s=window.Date,c=window.setTimeout,f=window.clearTimeout,p=window.requestAnimationFrame,x=window.cancelAnimationFrame;"undefined"!=typeof console&&("function"!=typeof p&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!=typeof x&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills")),exports.unstable_now="object"==typeof a&&"function"==typeof a.now?function(){return a.now()}:function(){return s.now()};var v=!1,b=null,w=-1,m=-1,d=33.33,y=-1,_=-1,h=0,T=!1;r=function(){return exports.unstable_now()>=h},o=function(){},exports.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):0<e?(d=Math.floor(1e3/e),T=!0):(d=33.33,T=!1)};var k=function(){if(null!==b){var e=exports.unstable_now(),n=0<h-e;try{b(n,e)||(b=null)}catch(t){throw F.postMessage(null),t}}},g=new MessageChannel,F=g.port2;g.port1.onmessage=k;var P=function(e){if(null===b)_=y=-1,v=!1;else{v=!0,p(function(e){f(w),P(e)});var n=function(){h=exports.unstable_now()+d/2,k(),w=c(n,3*d)};if(w=c(n,3*d),-1!==y&&.1<e-y){var t=e-y;!T&&-1!==_&&t<d&&_<d&&(8.33>(d=t<_?_:t)&&(d=8.33)),_=t}y=e,h=e+d,F.postMessage(null)}};e=function(e){b=e,v||(v=!0,p(function(e){P(e)}))},n=function(e,n){m=c(function(){e(exports.unstable_now())},n)},t=function(){f(m),m=-1}}var M=null,C=null,A=null,L=3,R=!1,j=!1,q=!1;function D(e,n){var t=e.next;if(t===e)M=null;else{e===M&&(M=t);var r=e.previous;r.next=t,t.previous=r}e.next=e.previous=null,t=e.callback,r=L;var o=A;L=e.priorityLevel,A=e;try{var i=e.expirationTime<=n;switch(L){case 1:var l=t(i);break;case 2:case 3:case 4:l=t(i);break;case 5:l=t(i)}}catch(u){throw u}finally{L=r,A=o}if("function"==typeof l)if(n=e.expirationTime,e.callback=l,null===M)M=e.next=e.previous=e;else{l=null,i=M;do{if(n<=i.expirationTime){l=i;break}i=i.next}while(i!==M);null===l?l=M:l===M&&(M=e),(n=l.previous).next=l.previous=e,e.next=l,e.previous=n}}function E(e){if(null!==C&&C.startTime<=e)do{var n=C,t=n.next;if(n===t)C=null;else{C=t;var r=n.previous;r.next=t,t.previous=r}n.next=n.previous=null,O(n,n.expirationTime)}while(null!==C&&C.startTime<=e)}function I(t){q=!1,E(t),j||(null!==M?(j=!0,e(N)):null!==C&&n(I,C.startTime-t))}function N(e,o){j=!1,q&&(q=!1,t()),E(o),R=!0;try{if(e){if(null!==M)do{D(M,o),E(o=exports.unstable_now())}while(null!==M&&!r())}else for(;null!==M&&M.expirationTime<=o;)D(M,o),E(o=exports.unstable_now());return null!==M||(null!==C&&n(I,C.startTime-o),!1)}finally{R=!1}}function B(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}function O(e,n){if(null===M)M=e.next=e.previous=e;else{var t=null,r=M;do{if(n<r.expirationTime){t=r;break}r=r.next}while(r!==M);null===t?t=M:t===M&&(M=e),(n=t.previous).next=t.previous=e,e.next=t,e.previous=n}}var U=o;exports.unstable_ImmediatePriority=1,exports.unstable_UserBlockingPriority=2,exports.unstable_NormalPriority=3,exports.unstable_IdlePriority=5,exports.unstable_LowPriority=4,exports.unstable_runWithPriority=function(e,n){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var t=L;L=e;try{return n()}finally{L=t}},exports.unstable_next=function(e){switch(L){case 1:case 2:case 3:var n
},{}],"MDSO":[function(require,module,exports) {
"use strict";module.exports=require("./cjs/scheduler.production.min.js");
},{"./cjs/scheduler.production.min.js":"5IvP"}],"i17t":[function(require,module,exports) {
"use strict";var e=require("react"),t=require("object-assign"),n=require("scheduler");function r(e){for(var t=e.message,n="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r]);return e.message="Minified React error #"+t+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",e}if(!e)throw r(Error(227));var l=null,i={};function a(){if(l)for(var e in i){var t=i[e],n=l.indexOf(e);if(!(-1<n))throw r(Error(96),e);if(!u[n]){if(!t.extractEvents)throw r(Error(97),e);for(var a in u[n]=t,n=t.eventTypes){var s=void 0,f=n[a],d=t,p=a;if(c.hasOwnProperty(p))throw r(Error(99),p);c[p]=f;var h=f.phasedRegistrationNames;if(h){for(s in h)h.hasOwnProperty(s)&&o(h[s],d,p);s=!0}else f.registrationName?(o(f.registrationName,d,p),s=!0):s=!1;if(!s)throw r(Error(98),a,e)}}}}function o(e,t,n){if(s[e])throw r(Error(100),e);s[e]=t,f[e]=t.eventTypes[n].dependencies}var u=[],c={},s={},f={};function d(e,t,n,r,l,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(s){this.onError(s)}}var p=!1,h=null,m=!1,g=null,v={onError:function(e){p=!0,h=e}};function y(e,t,n,r,l,i,a,o,u){p=!1,h=null,d.apply(v,arguments)}function b(e,t,n,l,i,a,o,u,c){if(y.apply(this,arguments),p){if(!p)throw r(Error(198));var s=h;p=!1,h=null,m||(m=!0,g=s)}}var w=null,k=null,E=null;function x(e,t,n){var r=e.type||"unknown-event";e.currentTarget=E(n),b(r,t,void 0,e),e.currentTarget=null}function T(e,t){if(null==t)throw r(Error(30));return null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function C(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}var S=null;function _(e){if(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))for(var r=0;r<t.length&&!e.isPropagationStopped();r++)x(e,t[r],n[r]);else t&&x(e,t,n);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function P(e){if(null!==e&&(S=T(S,e)),e=S,S=null,e){if(C(e,_),S)throw r(Error(95));if(m)throw e=g,m=!1,g=null,e}}var N={injectEventPluginOrder:function(e){if(l)throw r(Error(101));l=Array.prototype.slice.call(e),a()},injectEventPluginsByName:function(e){var t,n=!1;for(t in e)if(e.hasOwnProperty(t)){var l=e[t];if(!i.hasOwnProperty(t)||i[t]!==l){if(i[t])throw r(Error(102),t);i[t]=l,n=!0}}n&&a()}};function z(e,t){var n=e.stateNode;if(!n)return null;var l=w(n);if(!l)return null;n=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":(l=!l.disabled)||(l=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!l;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw r(Error(231),t,typeof n);return n}var M=Math.random().toString(36).slice(2),U="__reactInternalInstance$"+M,R="__reactEventHandlers$"+M;function F(e){if(e[U])return e[U];for(;!e[U];){if(!e.parentNode)return null;e=e.parentNode}return 5===(e=e[U]).tag||6===e.tag?e:null}function I(e){return!(e=e[U])||5!==e.tag&&6!==e.tag?null:e}function D(e){if(5===e.tag||6===e.tag)return e.stateNode;throw r(Error(33))}function O(e){return e[R]||null}function L(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function A(e,t,n){(t=z(e,n.dispatchConfig.phasedRegistrationNames[t]))&&(n._dispatchListeners=T(n._dispatchListeners,t),n._dispatchInstances=T(n._dispatchInstances,e))}function W(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,n=[];t;)n.push(t),t=L(t);for(t=n.length;0<t--;)A(n[t],"captured",e);for(t=0;t<n.length;t++)A(n[t],"bubbled",e)}}function V(e,t,n){e&&n&&n.dispatchConfig.registrationName&&(t=z(e,n.dispatchConfig.registrationName))&&(n._dispatchListeners=T(n._dispatchListeners,t),n._dispatchInstances=T(n._dispatchInstances,e))}function B(e){e&&e.dispatchConfig.registrationName&&V(e._targetInst,null,e)}function j(e){C(e,W)}var H=!("undefined"==typeof w
},{"react":"1n8/","object-assign":"J4Nk","scheduler":"MDSO"}],"NKHc":[function(require,module,exports) {
"use strict";function _(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_)}catch(O){console.error(O)}}}_(),module.exports=require("./cjs/react-dom.production.min.js");
},{"./cjs/react-dom.production.min.js":"i17t"}],"Bzn5":[function(require,module,exports) {
2019-10-19 06:46:03 +00:00
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("react");function t(e){return"Object"===e.constructor.name}exports.HTMLInputExtractor=(e=>e.currentTarget.value),exports.HTMLCheckboxExtractor=(e=>e.currentTarget.checked);const r=e=>`Error in ${e}`;exports.useForm=((s,c={},n={})=>{const[o,a]=e.useState(s),[u,i]=e.useState({}),[g,x]=e.useState(!0);e.useEffect(()=>{x(!Object.values(u).reduce((e,t)=>e||void 0!==t,!1))},[u]);const d=async(e,r)=>{const s=t(r)?r.validator:r;return"Function"===s.constructor.name?s(e):"AsyncFunction"===s.constructor.name?await s(e):"RegExp"===s.constructor.name&&s.test(e)},m=(e,s=n.extractor)=>n=>{const g=s?s(n):exports.HTMLInputExtractor(n);((e,t)=>{a(Object.assign(Object.assign({},o),{[e]:t}))})(e,g),((e,s)=>{const n=c[e];n&&(Array.isArray(n)?Promise.all(n.map(e=>d(s,e))).then(s=>{const c=s.indexOf(!1);i(Object.assign(Object.assign({},u),{[e]:-1===c?void 0:t(n[c])&&n[c].message?n[c].message:r(e)}))}):d(s,n).then(s=>{i(Object.assign(Object.assign({},u),{[e]:s?void 0:t(n)&&n.message?n.message:r(e)}))}))})(e,g)};return{form:o,update:m,field:(e,t={})=>({[t.getter||n.getter||"onChange"]:m(e,t.extractor),[t.setter||n.setter||"value"]:o[e]}),errors:u,isValid:g}});
2019-09-28 17:05:41 +00:00
},{"react":"1n8/"}],"i5Ue":[function(require,module,exports) {
2019-10-19 06:46:03 +00:00
"use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const t=e(require("react")),a=e(require("react-dom")),r=require("../"),s=()=>{const{field:e,form:a,errors:s,isValid:l}=r.useForm({username:"",email:"",password:""},{username:e=>e.length>3,email:{validator:/@/,message:"Must contain an @"},password:[{validator:/[A-Z]/,message:"Must contain an uppercase letter"},{validator:/[\d]/,message:"Must contain a digit"}]});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),l&&console.log(a)}},t.default.createElement("h1",null,"Errors & Validation"),t.default.createElement("input",Object.assign({},e("username"),{placeholder:"Username"})),s.username&&"Must be longer than 3",t.default.createElement("input",Object.assign({},e("email"),{placeholder:"EMail"})),s.email,t.default.createElement("input",Object.assign({},e("password"),{placeholder:"Password",type:"password"})),s.password,t.default.createElement("input",{type:"submit"}))};a.default.render(t.default.createElement(s,null),document.getElementById("errors"));
2019-09-28 17:05:41 +00:00
},{"react":"1n8/","react-dom":"NKHc","../":"Bzn5"}]},{},["i5Ue"], null)