mirror of
https://github.com/cupcakearmy/formhero.git
synced 2024-12-23 00:26:23 +00:00
examples
This commit is contained in:
parent
5d6a420283
commit
39532fe718
@ -13,7 +13,7 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
|
|||||||
},{"react":"1n8/","object-assign":"J4Nk","scheduler":"MDSO"}],"NKHc":[function(require,module,exports) {
|
},{"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");
|
"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) {
|
},{"./cjs/react-dom.production.min.js":"i17t"}],"Bzn5":[function(require,module,exports) {
|
||||||
"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 m=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)},d=(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=>m(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)}))}):m(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:d,auto:(e,t={})=>({[t.getter||n.getter||"onChange"]:d(e,t.extractor),[t.setter||n.setter||"value"]:o[e]}),errors:u,isValid:g}});
|
"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}});
|
||||||
},{"react":"1n8/"}],"mvMA":[function(require,module,exports) {
|
},{"react":"1n8/"}],"mvMA":[function(require,module,exports) {
|
||||||
"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")),r=e(require("react-dom")),u=require("../dist"),l=()=>{const{auto:e,form:r,errors:l}=u.useForm({awesome:!0});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),console.log(r)}},t.default.createElement("h1",null,"Custom"),t.default.createElement("label",null,t.default.createElement("input",Object.assign({type:"checkbox"},e("awesome",{setter:"checked",getter:"onChange",extractor:e=>e.target.checked}))),"Is it awesome?"),t.default.createElement("input",{type:"submit"}))};r.default.render(t.default.createElement(l,null),document.getElementById("custom"));
|
"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")),r=e(require("react-dom")),l=require("../dist"),u=()=>{const{field:e,form:r,errors:u}=l.useForm({awesome:!0});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),console.log(r)}},t.default.createElement("h1",null,"Custom"),t.default.createElement("label",null,t.default.createElement("input",Object.assign({type:"checkbox"},e("awesome",{setter:"checked",getter:"onChange",extractor:e=>e.target.checked}))),"Is it awesome?"),t.default.createElement("input",{type:"submit"}))};r.default.render(t.default.createElement(u,null),document.getElementById("custom"));
|
||||||
},{"react":"1n8/","react-dom":"NKHc","../dist":"Bzn5"}]},{},["mvMA"], null)
|
},{"react":"1n8/","react-dom":"NKHc","../dist":"Bzn5"}]},{},["mvMA"], null)
|
@ -13,7 +13,7 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
|
|||||||
},{"react":"1n8/","object-assign":"J4Nk","scheduler":"MDSO"}],"NKHc":[function(require,module,exports) {
|
},{"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");
|
"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) {
|
},{"./cjs/react-dom.production.min.js":"i17t"}],"Bzn5":[function(require,module,exports) {
|
||||||
"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 m=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)},d=(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=>m(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)}))}):m(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:d,auto:(e,t={})=>({[t.getter||n.getter||"onChange"]:d(e,t.extractor),[t.setter||n.setter||"value"]:o[e]}),errors:u,isValid:g}});
|
"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}});
|
||||||
},{"react":"1n8/"}],"i5Ue":[function(require,module,exports) {
|
},{"react":"1n8/"}],"i5Ue":[function(require,module,exports) {
|
||||||
"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{auto: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"));
|
"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"));
|
||||||
},{"react":"1n8/","react-dom":"NKHc","../":"Bzn5"}]},{},["i5Ue"], null)
|
},{"react":"1n8/","react-dom":"NKHc","../":"Bzn5"}]},{},["i5Ue"], null)
|
@ -1,2 +1 @@
|
|||||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Form Hero</title><style>body{padding:1em;margin:0;font-family:Courier New,Courier,monospace}section{text-align:center;max-width:25em;margin:1em auto;padding:1em;background-color:#f3f3f3;border-radius:.5em;box-shadow:0 8px 16px -16px rgba(0,0,0,.5)}input{font-size:1.25em;display:block;padding:.5em 1em;margin-top:.5em;border-radius:1em;width:100%;outline:none;border:.15em solid #fff}input:focus,input:hover{border-color:#31def5}input[type=submit]{cursor:pointer}input[type=checkbox]{display:inline;width:auto}</style></head><body> <section> <h3>Open the console to see the submitted data</h3> </section> <section id="simple"></section> <section id="errors"></section> <section id="select"></section> <section id="custom"></section> <script src="/formhero/simple.a7008172.js"></script> <script src="/formhero/errorsAndValidation.6891c1b3.js"></script> <script src="/formhero/select.fb8895c3.js"></script> <script src="/formhero/custom.6b7d60dc.js"></script>
|
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Form Hero</title><style>body{padding:1em;margin:0;font-family:Courier New,Courier,monospace}section{text-align:center;max-width:25em;margin:1em auto;padding:1em;background-color:#f3f3f3;border-radius:.5em;box-shadow:0 8px 16px -16px rgba(0,0,0,.5)}input{font-size:1.25em;display:block;padding:.5em 1em;margin-top:.5em;border-radius:1em;width:100%;outline:none;border:.15em solid #fff}input:focus,input:hover{border-color:#31def5}input[type=submit]{cursor:pointer}input[type=checkbox]{display:inline;width:auto}</style></head><body> <section> <h3>Open the console to see the submitted data</h3> </section> <section id="simple"></section> <section id="errors"></section> <section id="select"></section> <section id="custom"></section> <script src="/formhero/simple.2520a232.js"></script> <script src="/formhero/errorsAndValidation.1ec8a0d3.js"></script> <script src="/formhero/select.c810e4f2.js"></script> <script src="/formhero/custom.7cabc6c1.js"></script> </body></html>
|
||||||
</body></html>
|
|
@ -13,7 +13,7 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
|
|||||||
},{"react":"1n8/","object-assign":"J4Nk","scheduler":"MDSO"}],"NKHc":[function(require,module,exports) {
|
},{"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");
|
"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) {
|
},{"./cjs/react-dom.production.min.js":"i17t"}],"Bzn5":[function(require,module,exports) {
|
||||||
"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 m=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)},d=(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=>m(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)}))}):m(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:d,auto:(e,t={})=>({[t.getter||n.getter||"onChange"]:d(e,t.extractor),[t.setter||n.setter||"value"]:o[e]}),errors:u,isValid:g}});
|
"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}});
|
||||||
},{"react":"1n8/"}],"884M":[function(require,module,exports) {
|
},{"react":"1n8/"}],"884M":[function(require,module,exports) {
|
||||||
"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")),r=e(require("react-dom")),o=require("../dist"),l=()=>{const{auto:e,form:r,errors:l}=o.useForm({type:"formhero"});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),console.log(r)}},t.default.createElement("h1",null,"Select"),t.default.createElement("select",Object.assign({},e("type")),t.default.createElement("option",{value:"redux-form"},"Redux-Form"),t.default.createElement("option",{value:"react-hook-forms"},"React-Hook-Forms"),t.default.createElement("option",{value:"formik"},"Formik"),t.default.createElement("option",{value:"formhero"},"FormHero")),t.default.createElement("input",{type:"submit"}))};r.default.render(t.default.createElement(l,null),document.getElementById("select"));
|
"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")),r=e(require("react-dom")),o=require("../dist"),l=()=>{const{field:e,form:r,errors:l}=o.useForm({type:"formhero"});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),console.log(r)}},t.default.createElement("h1",null,"Select"),t.default.createElement("select",Object.assign({},e("type")),t.default.createElement("option",{value:"redux-form"},"Redux-Form"),t.default.createElement("option",{value:"react-hook-forms"},"React-Hook-Forms"),t.default.createElement("option",{value:"formik"},"Formik"),t.default.createElement("option",{value:"formhero"},"FormHero")),t.default.createElement("input",{type:"submit"}))};r.default.render(t.default.createElement(l,null),document.getElementById("select"));
|
||||||
},{"react":"1n8/","react-dom":"NKHc","../dist":"Bzn5"}]},{},["884M"], null)
|
},{"react":"1n8/","react-dom":"NKHc","../dist":"Bzn5"}]},{},["884M"], null)
|
@ -13,7 +13,7 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
|
|||||||
},{"react":"1n8/","object-assign":"J4Nk","scheduler":"MDSO"}],"NKHc":[function(require,module,exports) {
|
},{"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");
|
"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) {
|
},{"./cjs/react-dom.production.min.js":"i17t"}],"Bzn5":[function(require,module,exports) {
|
||||||
"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 m=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)},d=(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=>m(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)}))}):m(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:d,auto:(e,t={})=>({[t.getter||n.getter||"onChange"]:d(e,t.extractor),[t.setter||n.setter||"value"]:o[e]}),errors:u,isValid:g}});
|
"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}});
|
||||||
},{"react":"1n8/"}],"9BWQ":[function(require,module,exports) {
|
},{"react":"1n8/"}],"9BWQ":[function(require,module,exports) {
|
||||||
"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")),r=e(require("react-dom")),u=require("../dist"),a=()=>{const{auto:e,form:r,errors:a}=u.useForm({username:"unicorn",password:""});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),console.log(r)}},t.default.createElement("h1",null,"Simple"),t.default.createElement("input",Object.assign({},e("username"),{placeholder:"Username"})),t.default.createElement("input",Object.assign({},e("password"),{placeholder:"Password",type:"password"})),t.default.createElement("input",{type:"submit"}))};r.default.render(t.default.createElement(a,null),document.getElementById("simple"));
|
"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")),r=e(require("react-dom")),l=require("../dist"),u=()=>{const{field:e,form:r,errors:u}=l.useForm({username:"unicorn",password:""});return t.default.createElement("form",{onSubmit:e=>{e.preventDefault(),console.log(r)}},t.default.createElement("h1",null,"Simple"),t.default.createElement("input",Object.assign({},e("username"),{placeholder:"Username"})),t.default.createElement("input",Object.assign({},e("password"),{placeholder:"Password",type:"password"})),t.default.createElement("input",{type:"submit"}))};r.default.render(t.default.createElement(u,null),document.getElementById("simple"));
|
||||||
},{"react":"1n8/","react-dom":"NKHc","../dist":"Bzn5"}]},{},["9BWQ"], null)
|
},{"react":"1n8/","react-dom":"NKHc","../dist":"Bzn5"}]},{},["9BWQ"], null)
|
Loading…
Reference in New Issue
Block a user