react-hook-form-jsonschema
Advanced tools
Comparing version 0.1.3 to 0.2.0-beta
@@ -10,2 +10,8 @@ # Changelog | ||
## [0.2.0-beta] - 2020-01-22 | ||
### Added | ||
- Now re-exports the `react-hook-form` public API | ||
## [0.1.3] - 2020-01-21 | ||
@@ -12,0 +18,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-hook-form");const s=e=>{const t=e.split("/");return"#"===t[0]&&t.shift(),""===t[t.length-1]&&t.pop(),t},i=(e,t)=>{const r=Object.keys(t).sort(),n={};for(const i of r){const r=s(i);if(!r)continue;let a=n,p=e;for(let e=0;e<r.length&&void 0!==p;e++)p.type&&"object"===p.type?p=p.properties:!p.type&&p[r[e]]&&"object"===p[r[e]].type&&(p=p[r[e]]),e===r.length-1&&(p[r[e]]&&p[r[e]].type&&"integer"===p[r[e]].type?a[r[e]]=parseInt(t[i]):p[r[e]]&&p[r[e]].type&&"number"===p[r[e]].type?a[r[e]]=parseFloat(t[i]):a[r[e]]=t[i]),void 0===a[r[e]]&&(a[r[e]]={}),a=a[r[e]]}return n},a=t.createContext(null);function p(){return t.useContext(a)}var o,u;(o=exports.InputTypes||(exports.InputTypes={})).generic="__input_type_generic__",o.radio="__input_type_radio__",o.select="__input_type_select__",o.input="__input_type_input__",o.textArea="__input_type_textArea__",(u=exports.UITypes||(exports.UITypes={})).default="__input_type_default__",u.radio="__input_type_radio__",u.select="__input_type_select__",u.input="__input_type_input__",u.hidden="__input_type_hidden__",u.password="__input_type_password__",u.textArea="__input_type_textArea__";const m=(e,t)=>e+"/"+t,c=e=>{const t=s(e);let r=p().schema,n=!1,i="";for(let e=0;e<t.length;e++){if(!r||!r.type||"object"!==r.type){r={};break}n=!!(r.required&&r.required.indexOf(t[e])>-1),i=t[e],r=r.properties[t[e]]}return{JSONSchema:r,isRequired:n,objectName:i}};var l;!function(e){e.required="__form_error_required__",e.maxLength="__form_error_maxLenght__",e.minLength="__form_error_minLenght__",e.maxValue="__form_error_maxValue__",e.minValue="__form_error_minValue__",e.pattern="__form_error_pattern__",e.multipleOf="__form_error_multipleOf",e.undefinedError="__form_error_undefinedError__"}(l||(l={}));const d=e=>{const t={};return e&&(t.required=l.required),t},_=(e,t)=>{const r=Math.pow(10,t||0);return String(Math.round(e*r)/r)},g=e=>{const t=void 0!==e.multipleOf?"integer"===e.type?parseInt(e.multipleOf):parseFloat(e.multipleOf):"integer"===e.type?1:"any";let r=void 0;if(e.multipleOf){const t=e.multipleOf.toString().split(".")[1];r=t?t.length:0}return[t,r]},h=e=>{const[t]=g(e);let r=void 0!==e.exclusiveMinimum?e.exclusiveMinimum:void 0!==e.minimum?e.minimum:void 0;return void 0!==r&&void 0!==e.exclusiveMinimum&&(r+=t&&"any"!=t?t:1e-4),r},x=e=>{const[t]=g(e);let r=void 0!==e.exclusiveMaximum?parseFloat(e.exclusiveMaximum):void 0!==e.maximum?parseFloat(e.maximum):void 0;return void 0!==r&&void 0!==e.exclusiveMaximum&&(r-=t&&"any"!=t?t:1e-4),r},y=(e,t)=>{const r=h(e),n=x(e),s={validate:{multipleOf:t=>"integer"!==e.type||e.multipleOf&&(parseInt(t)%parseInt(e.multipleOf)==0||l.multipleOf)}};return t&&(s.required=l.required),"integer"===e.type?s.pattern={value:/^([+-]?[1-9]\d*|0)$/,message:l.pattern}:s.pattern={value:/^([0-9]+([,.][0-9]+))?$/,message:l.pattern},(r||0===r)&&(s.min={value:r,message:l.minValue}),(n||0===n)&&(s.max={value:n,message:l.maxValue}),s},b=(e,t)=>{const r={};return t&&(r.required=l.required),e.minLength&&(r.minLength={value:e.minLength,message:l.minLength}),e.maxLength&&(r.maxLength={value:e.maxLength,message:l.maxLength}),e.pattern&&(r.pattern={value:new RegExp(e.pattern),message:l.pattern}),r},f=(e,t,r)=>{const{JSONSchema:n,isRequired:s,objectName:i}=t;let a,p,o;if("number"===n.type||"integer"===n.type){const e=g(n);o=e[0],a=h(n),p=x(n)}return{name:i,path:r,isRequired:s,formContext:e,type:exports.InputTypes.generic,getError:()=>((e,t,r,n,s,i)=>{if(!e)return;const a={message:l.undefinedError,expected:void 0};switch(e.message){case l.required:a.message=l.required,a.expected=r;break;case l.maxLength:a.message=l.maxLength,a.expected=t.maxLength;break;case l.minLength:a.message=l.minLength,a.expected=t.minLength;break;case l.maxValue:a.message=l.maxValue,a.expected=n;break;case l.minValue:a.message=l.minValue,a.expected=s;break;case l.multipleOf:a.message=l.multipleOf,a.expected=i;break;case l.pattern:a.message=l.pattern,a.expected=t.pattern}return a})(e.errors[r]?e.errors[r]:void 0,n,s,a,p,o),getObject:()=>n}},v=e=>{const t=p(),r=c(e);return f(t,r,e)},O=(e,t)=>e+"-"+t+"-input",q=(e,t)=>{const{register:r}=e.formContext,n=e.getObject();let s,i,a,p,o={};const u={key:""};if("string"===n.type)o=b(n,e.isRequired),u.pattern=n.pattern,u.minLength=n.minLength,u.maxLength=n.maxLength;else if("number"===n.type||"integer"===n.type){const t=g(n);a=t[0],p=t[1],s=h(n),i=x(n),o=y(n,e.isRequired),u.min=s,u.max=i,u.step="any"===a?"any":_(a,p||0)}return Object.assign(Object.assign({},e),{type:exports.InputTypes.input,getLabelProps:()=>{const r={};return r.id=((e,t)=>e+"-"+t+"-label")(e.path,t),r.htmlFor=O(e.path,t),r},getInputProps:()=>(u.name=e.path,u.ref=r(o),u.type=t,u.required=e.isRequired,u.id=O(e.path,t),u)})},j=()=>({}),L=e=>Object.assign(Object.assign({},q(e,"hidden")),{isRequired:!1,getLabelProps:j}),I=e=>{let t;switch(e.getObject().format){case"date-time":t="datetime-local";break;case"email":t="email";break;case"hostname":case"uri":t="url";break;default:t="text"}return q(e,t)},k=(e,t,r)=>e+"-radio-input-"+(r[t]?r[t]:""),R=e=>{const t=e.getObject();let r,n,s,i,a={},p=[];if("string"===t.type)p=t.enum?t.enum:[],a=b(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const o=g(t);if(s=o[0],i=o[1],r=h(t),n=x(t),void 0!==r&&void 0!==n&&"any"!=s){a=y(t,e.isRequired);for(let e=r;e<=n;e+=s)p.push(_(e,i||0))}}else"boolean"===t.type&&(a=d(e.isRequired),p=["true","false"]);return Object.assign(Object.assign({},e),{type:exports.InputTypes.radio,getLabelProps:()=>{const r={};return r.id=e.path+"-label",r.htmlFor=void 0!==t.title?t.title:e.path,r},getItemInputProps:t=>{const r={key:""};return r.name=e.path,r.ref=e.formContext.register(a),r.type="radio",r.required=e.isRequired,r.id=k(e.path,t,p),r.value=p[t],r},getItemLabelProps:t=>{const r={};return r.id=((e,t,r)=>e+"-radio-label-"+(r[t]?r[t]:""))(e.path,t,p),r.htmlFor=k(e.path,t,p),r},getItems:()=>p})},S=e=>e+"-select",T=e=>{const t=e.getObject();let r,n,s,i,a={},p=[""];if("string"===t.type)p=p.concat(t.enum?t.enum:[]),a=b(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const o=g(t);if(s=o[0],i=o[1],r=h(t),n=x(t),void 0!==r&&void 0!==n&&"any"!=s){a=y(t,e.isRequired);for(let e=r;e<=n;e+=s)p.push(_(e,i||0))}}else"boolean"===t.type&&(a=d(e.isRequired),p=["true","false"]);return Object.assign(Object.assign({},e),{type:exports.InputTypes.select,getLabelProps:()=>{const t={};return t.id=e.path+"-label",t.htmlFor=S(e.path),t},getSelectProps:()=>{const t={};return t.name=e.path,t.ref=e.formContext.register(a),t.required=e.isRequired,t.id=S(e.path),t},getItemOptionProps:t=>{const r={};return r.id=((e,t,r)=>e+"-select-option-"+(r[t]?r[t]:""))(e.path,t,p),r.value=p[t],r},getItems:()=>p})},F=e=>q(e,"password"),P=e=>e+"-textarea-input",V=e=>{const t=e.getObject();let r={};const n={};return"string"===t.type?(r=b(t,e.isRequired),n.minLength=t.minLength,n.maxLength=t.maxLength):"number"!==t.type&&"integer"!==t.type||(r=y(t,e.isRequired)),Object.assign(Object.assign({},e),{type:exports.InputTypes.textArea,getLabelProps:()=>{const t={};return t.id=e.path+"-textarea-label",t.htmlFor=P(e.path),t},getTextAreaProps:()=>(n.name=e.path,n.ref=e.formContext.register(r),n.required=e.isRequired,n.id=P(e.path),n)})};function w(e){const t=e.getObject(),r=[];switch(t.type){case"string":t.enum?r.push(T(e)):r.push(I(e));break;case"integer":case"number":r.push(I(e));break;case"boolean":r.push(R(e))}return r}function M(e,t,r,n){let s=[];const{JSONSchema:i}=t,a=f(e,t,r);if("object"===i.type){return Object.keys(i.properties).reduce(function(e,t,r,n){const s=t.required;return(i,a)=>{const p=!!s&&-1!==s.indexOf(a),o=r&&r.properties?r.properties[a]:void 0,u=m(e,a),c={JSONSchema:t.properties[a],isRequired:p,objectName:a},l=M(n,c,u,o);return i.concat(l)}}(r,i,n,e),[])}if(!n)return s.concat(w(a));switch(n.type){case exports.UITypes.default:s=s.concat(w(a));break;case exports.UITypes.hidden:s.push(L(a));break;case exports.UITypes.input:s.push(I(a));break;case exports.UITypes.password:s.push(F(a));break;case exports.UITypes.radio:s.push(R(a));break;case exports.UITypes.select:s.push(T(a));break;case exports.UITypes.textArea:s.push(V(a))}return s}exports.FormContext=e=>{const{mode:t="onSubmit",revalidateMode:s="onChange",submitFocusError:p=!0}=e,o=n.useForm({mode:t,reValidateMode:s,submitFocusError:p}),u={};return u.onSubmit=o.handleSubmit((t,r)=>{e.onSubmit&&e.onSubmit(i(e.schema,t),r)}),e.noNativeValidate&&(u.noValidate=e.noNativeValidate),r.createElement(a.Provider,{value:Object.assign(Object.assign({},o),{schema:e.schema})},r.createElement("form",Object.assign({},u),e.children))},exports.concatFormPath=m,exports.useGenericInput=v,exports.useHidden=e=>L(v(e)),exports.useInput=e=>I(v(e)),exports.useObject=e=>M(p(),c(e.path),e.path,e.UISchema),exports.useObjectFromForm=e=>i(p().schema,e),exports.useObjectFromPath=c,exports.usePassword=e=>F(v(e)),exports.useRadio=e=>R(v(e)),exports.useSelect=e=>T(v(e)),exports.useTextArea=e=>V(v(e)); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react-hook-form"),r=require("react"),n=(e=r)&&"object"==typeof e&&"default"in e?e.default:e;const s=e=>{const t=e.split("/");return"#"===t[0]&&t.shift(),""===t[t.length-1]&&t.pop(),t},i=(e,t)=>{const r=Object.keys(t).sort(),n={};for(const i of r){const r=s(i);if(!r)continue;let a=n,p=e;for(let e=0;e<r.length&&void 0!==p;e++)p.type&&"object"===p.type?p=p.properties:!p.type&&p[r[e]]&&"object"===p[r[e]].type&&(p=p[r[e]]),e===r.length-1&&(p[r[e]]&&p[r[e]].type&&"integer"===p[r[e]].type?a[r[e]]=parseInt(t[i]):p[r[e]]&&p[r[e]].type&&"number"===p[r[e]].type?a[r[e]]=parseFloat(t[i]):a[r[e]]=t[i]),void 0===a[r[e]]&&(a[r[e]]={}),a=a[r[e]]}return n},a=r.createContext(null);function p(){return r.useContext(a)}var o,u;(o=exports.InputTypes||(exports.InputTypes={})).generic="__input_type_generic__",o.radio="__input_type_radio__",o.select="__input_type_select__",o.input="__input_type_input__",o.textArea="__input_type_textArea__",(u=exports.UITypes||(exports.UITypes={})).default="__input_type_default__",u.radio="__input_type_radio__",u.select="__input_type_select__",u.input="__input_type_input__",u.hidden="__input_type_hidden__",u.password="__input_type_password__",u.textArea="__input_type_textArea__";const c=(e,t)=>e+"/"+t,m=e=>{const t=s(e);let r=p().schema,n=!1,i="";for(let e=0;e<t.length;e++){if(!r||!r.type||"object"!==r.type){r={};break}n=!!(r.required&&r.required.indexOf(t[e])>-1),i=t[e],r=r.properties[t[e]]}return{JSONSchema:r,isRequired:n,objectName:i}};var l;!function(e){e.required="__form_error_required__",e.maxLength="__form_error_maxLenght__",e.minLength="__form_error_minLenght__",e.maxValue="__form_error_maxValue__",e.minValue="__form_error_minValue__",e.pattern="__form_error_pattern__",e.multipleOf="__form_error_multipleOf",e.undefinedError="__form_error_undefinedError__"}(l||(l={}));const d=e=>{const t={};return e&&(t.required=l.required),t},_=(e,t)=>{const r=Math.pow(10,t||0);return String(Math.round(e*r)/r)},g=e=>{const t=void 0!==e.multipleOf?"integer"===e.type?parseInt(e.multipleOf):parseFloat(e.multipleOf):"integer"===e.type?1:"any";let r=void 0;if(e.multipleOf){const t=e.multipleOf.toString().split(".")[1];r=t?t.length:0}return[t,r]},h=e=>{const[t]=g(e);let r=void 0!==e.exclusiveMinimum?e.exclusiveMinimum:void 0!==e.minimum?e.minimum:void 0;return void 0!==r&&void 0!==e.exclusiveMinimum&&(r+=t&&"any"!=t?t:1e-4),r},x=e=>{const[t]=g(e);let r=void 0!==e.exclusiveMaximum?parseFloat(e.exclusiveMaximum):void 0!==e.maximum?parseFloat(e.maximum):void 0;return void 0!==r&&void 0!==e.exclusiveMaximum&&(r-=t&&"any"!=t?t:1e-4),r},b=(e,t)=>{const r=h(e),n=x(e),s={validate:{multipleOf:t=>"integer"!==e.type||e.multipleOf&&(parseInt(t)%parseInt(e.multipleOf)==0||l.multipleOf)}};return t&&(s.required=l.required),"integer"===e.type?s.pattern={value:/^([+-]?[1-9]\d*|0)$/,message:l.pattern}:s.pattern={value:/^([0-9]+([,.][0-9]+))?$/,message:l.pattern},(r||0===r)&&(s.min={value:r,message:l.minValue}),(n||0===n)&&(s.max={value:n,message:l.maxValue}),s},y=(e,t)=>{const r={};return t&&(r.required=l.required),e.minLength&&(r.minLength={value:e.minLength,message:l.minLength}),e.maxLength&&(r.maxLength={value:e.maxLength,message:l.maxLength}),e.pattern&&(r.pattern={value:new RegExp(e.pattern),message:l.pattern}),r},f=(e,t,r)=>{const{JSONSchema:n,isRequired:s,objectName:i}=t;let a,p,o;if("number"===n.type||"integer"===n.type){const e=g(n);o=e[0],a=h(n),p=x(n)}return{name:i,path:r,isRequired:s,formContext:e,type:exports.InputTypes.generic,getError:()=>((e,t,r,n,s,i)=>{if(!e)return;const a={message:l.undefinedError,expected:void 0};switch(e.message){case l.required:a.message=l.required,a.expected=r;break;case l.maxLength:a.message=l.maxLength,a.expected=t.maxLength;break;case l.minLength:a.message=l.minLength,a.expected=t.minLength;break;case l.maxValue:a.message=l.maxValue,a.expected=n;break;case l.minValue:a.message=l.minValue,a.expected=s;break;case l.multipleOf:a.message=l.multipleOf,a.expected=i;break;case l.pattern:a.message=l.pattern,a.expected=t.pattern}return a})(e.errors[r]?e.errors[r]:void 0,n,s,a,p,o),getObject:()=>n}},O=e=>{const t=p(),r=m(e);return f(t,r,e)},v=(e,t)=>e+"-"+t+"-input",q=(e,t)=>{const{register:r}=e.formContext,n=e.getObject();let s,i,a,p,o={};const u={key:""};if("string"===n.type)o=y(n,e.isRequired),u.pattern=n.pattern,u.minLength=n.minLength,u.maxLength=n.maxLength;else if("number"===n.type||"integer"===n.type){const t=g(n);a=t[0],p=t[1],s=h(n),i=x(n),o=b(n,e.isRequired),u.min=s,u.max=i,u.step="any"===a?"any":_(a,p||0)}return Object.assign(Object.assign({},e),{type:exports.InputTypes.input,getLabelProps:()=>{const r={};return r.id=((e,t)=>e+"-"+t+"-label")(e.path,t),r.htmlFor=v(e.path,t),r},getInputProps:()=>(u.name=e.path,u.ref=r(o),u.type=t,u.required=e.isRequired,u.id=v(e.path,t),u)})},j=()=>({}),L=e=>Object.assign(Object.assign({},q(e,"hidden")),{isRequired:!1,getLabelProps:j}),I=e=>{let t;switch(e.getObject().format){case"date-time":t="datetime-local";break;case"email":t="email";break;case"hostname":case"uri":t="url";break;default:t="text"}return q(e,t)},k=(e,t,r)=>e+"-radio-input-"+(r[t]?r[t]:""),R=e=>{const t=e.getObject();let r,n,s,i,a={},p=[];if("string"===t.type)p=t.enum?t.enum:[],a=y(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const o=g(t);if(s=o[0],i=o[1],r=h(t),n=x(t),void 0!==r&&void 0!==n&&"any"!=s){a=b(t,e.isRequired);for(let e=r;e<=n;e+=s)p.push(_(e,i||0))}}else"boolean"===t.type&&(a=d(e.isRequired),p=["true","false"]);return Object.assign(Object.assign({},e),{type:exports.InputTypes.radio,getLabelProps:()=>{const r={};return r.id=e.path+"-label",r.htmlFor=void 0!==t.title?t.title:e.path,r},getItemInputProps:t=>{const r={key:""};return r.name=e.path,r.ref=e.formContext.register(a),r.type="radio",r.required=e.isRequired,r.id=k(e.path,t,p),r.value=p[t],r},getItemLabelProps:t=>{const r={};return r.id=((e,t,r)=>e+"-radio-label-"+(r[t]?r[t]:""))(e.path,t,p),r.htmlFor=k(e.path,t,p),r},getItems:()=>p})},S=e=>e+"-select",T=e=>{const t=e.getObject();let r,n,s,i,a={},p=[""];if("string"===t.type)p=p.concat(t.enum?t.enum:[]),a=y(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const o=g(t);if(s=o[0],i=o[1],r=h(t),n=x(t),void 0!==r&&void 0!==n&&"any"!=s){a=b(t,e.isRequired);for(let e=r;e<=n;e+=s)p.push(_(e,i||0))}}else"boolean"===t.type&&(a=d(e.isRequired),p=["true","false"]);return Object.assign(Object.assign({},e),{type:exports.InputTypes.select,getLabelProps:()=>{const t={};return t.id=e.path+"-label",t.htmlFor=S(e.path),t},getSelectProps:()=>{const t={};return t.name=e.path,t.ref=e.formContext.register(a),t.required=e.isRequired,t.id=S(e.path),t},getItemOptionProps:t=>{const r={};return r.id=((e,t,r)=>e+"-select-option-"+(r[t]?r[t]:""))(e.path,t,p),r.value=p[t],r},getItems:()=>p})},F=e=>q(e,"password"),P=e=>e+"-textarea-input",V=e=>{const t=e.getObject();let r={};const n={};return"string"===t.type?(r=y(t,e.isRequired),n.minLength=t.minLength,n.maxLength=t.maxLength):"number"!==t.type&&"integer"!==t.type||(r=b(t,e.isRequired)),Object.assign(Object.assign({},e),{type:exports.InputTypes.textArea,getLabelProps:()=>{const t={};return t.id=e.path+"-textarea-label",t.htmlFor=P(e.path),t},getTextAreaProps:()=>(n.name=e.path,n.ref=e.formContext.register(r),n.required=e.isRequired,n.id=P(e.path),n)})};function w(e){const t=e.getObject(),r=[];switch(t.type){case"string":t.enum?r.push(T(e)):r.push(I(e));break;case"integer":case"number":r.push(I(e));break;case"boolean":r.push(R(e))}return r}function M(e,t,r,n){let s=[];const{JSONSchema:i}=t,a=f(e,t,r);if("object"===i.type){return Object.keys(i.properties).reduce(function(e,t,r,n){const s=t.required;return(i,a)=>{const p=!!s&&-1!==s.indexOf(a),o=r&&r.properties?r.properties[a]:void 0,u=c(e,a),m={JSONSchema:t.properties[a],isRequired:p,objectName:a},l=M(n,m,u,o);return i.concat(l)}}(r,i,n,e),[])}if(!n)return s.concat(w(a));switch(n.type){case exports.UITypes.default:s=s.concat(w(a));break;case exports.UITypes.hidden:s.push(L(a));break;case exports.UITypes.input:s.push(I(a));break;case exports.UITypes.password:s.push(F(a));break;case exports.UITypes.radio:s.push(R(a));break;case exports.UITypes.select:s.push(T(a));break;case exports.UITypes.textArea:s.push(V(a))}return s}Object.keys(t).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),exports.FormContext=e=>{const{mode:r="onSubmit",revalidateMode:s="onChange",submitFocusError:p=!0}=e,o=t.useForm({mode:r,reValidateMode:s,submitFocusError:p}),u={};return u.onSubmit=o.handleSubmit((t,r)=>{e.onSubmit&&e.onSubmit(i(e.schema,t),r)}),e.noNativeValidate&&(u.noValidate=e.noNativeValidate),n.createElement(a.Provider,{value:Object.assign(Object.assign({},o),{schema:e.schema})},n.createElement("form",Object.assign({},u),e.children))},exports.concatFormPath=c,exports.useGenericInput=O,exports.useHidden=e=>L(O(e)),exports.useInput=e=>I(O(e)),exports.useObject=e=>M(p(),m(e.path),e.path,e.UISchema),exports.useObjectFromForm=e=>i(p().schema,e),exports.useObjectFromPath=m,exports.usePassword=e=>F(O(e)),exports.useRadio=e=>R(O(e)),exports.useSelect=e=>T(O(e)),exports.useTextArea=e=>V(O(e)); |
@@ -0,3 +1,4 @@ | ||
export * from 'react-hook-form'; | ||
export { FormContext, FormContextProps } from './components'; | ||
export * from './hooks'; | ||
export * from './JSONSchema'; |
@@ -1,1 +0,1 @@ | ||
import e,{createContext as t,useContext as r}from"react";import{useForm as n}from"react-hook-form";const i=e=>{const t=e.split("/");return"#"===t[0]&&t.shift(),""===t[t.length-1]&&t.pop(),t},a=(e,t)=>{const r=Object.keys(t).sort(),n={};for(const a of r){const r=i(a);if(!r)continue;let s=n,o=e;for(let e=0;e<r.length&&void 0!==o;e++)o.type&&"object"===o.type?o=o.properties:!o.type&&o[r[e]]&&"object"===o[r[e]].type&&(o=o[r[e]]),e===r.length-1&&(o[r[e]]&&o[r[e]].type&&"integer"===o[r[e]].type?s[r[e]]=parseInt(t[a]):o[r[e]]&&o[r[e]].type&&"number"===o[r[e]].type?s[r[e]]=parseFloat(t[a]):s[r[e]]=t[a]),void 0===s[r[e]]&&(s[r[e]]={}),s=s[r[e]]}return n},s=t(null);function o(){return r(s)}const u=t=>{const{mode:r="onSubmit",revalidateMode:i="onChange",submitFocusError:o=!0}=t,u=n({mode:r,reValidateMode:i,submitFocusError:o}),p={};return p.onSubmit=u.handleSubmit((e,r)=>{t.onSubmit&&t.onSubmit(a(t.schema,e),r)}),t.noNativeValidate&&(p.noValidate=t.noNativeValidate),e.createElement(s.Provider,{value:Object.assign(Object.assign({},u),{schema:t.schema})},e.createElement("form",Object.assign({},p),t.children))};var p,m;!function(e){e.generic="__input_type_generic__",e.radio="__input_type_radio__",e.select="__input_type_select__",e.input="__input_type_input__",e.textArea="__input_type_textArea__"}(p||(p={})),function(e){e.default="__input_type_default__",e.radio="__input_type_radio__",e.select="__input_type_select__",e.input="__input_type_input__",e.hidden="__input_type_hidden__",e.password="__input_type_password__",e.textArea="__input_type_textArea__"}(m||(m={}));const c=(e,t)=>e+"/"+t,l=e=>{const t=i(e);let r=o().schema,n=!1,a="";for(let e=0;e<t.length;e++){if(!r||!r.type||"object"!==r.type){r={};break}n=!!(r.required&&r.required.indexOf(t[e])>-1),a=t[e],r=r.properties[t[e]]}return{JSONSchema:r,isRequired:n,objectName:a}},d=e=>a(o().schema,e);var _;!function(e){e.required="__form_error_required__",e.maxLength="__form_error_maxLenght__",e.minLength="__form_error_minLenght__",e.maxValue="__form_error_maxValue__",e.minValue="__form_error_minValue__",e.pattern="__form_error_pattern__",e.multipleOf="__form_error_multipleOf",e.undefinedError="__form_error_undefinedError__"}(_||(_={}));const g=e=>{const t={};return e&&(t.required=_.required),t},h=(e,t)=>{const r=Math.pow(10,t||0);return String(Math.round(e*r)/r)},b=e=>{const t=void 0!==e.multipleOf?"integer"===e.type?parseInt(e.multipleOf):parseFloat(e.multipleOf):"integer"===e.type?1:"any";let r=void 0;if(e.multipleOf){const t=e.multipleOf.toString().split(".")[1];r=t?t.length:0}return[t,r]},f=e=>{const[t]=b(e);let r=void 0!==e.exclusiveMinimum?e.exclusiveMinimum:void 0!==e.minimum?e.minimum:void 0;return void 0!==r&&void 0!==e.exclusiveMinimum&&(r+=t&&"any"!=t?t:1e-4),r},y=e=>{const[t]=b(e);let r=void 0!==e.exclusiveMaximum?parseFloat(e.exclusiveMaximum):void 0!==e.maximum?parseFloat(e.maximum):void 0;return void 0!==r&&void 0!==e.exclusiveMaximum&&(r-=t&&"any"!=t?t:1e-4),r},x=(e,t)=>{const r=f(e),n=y(e),i={validate:{multipleOf:t=>"integer"!==e.type||e.multipleOf&&(parseInt(t)%parseInt(e.multipleOf)==0||_.multipleOf)}};return t&&(i.required=_.required),"integer"===e.type?i.pattern={value:/^([+-]?[1-9]\d*|0)$/,message:_.pattern}:i.pattern={value:/^([0-9]+([,.][0-9]+))?$/,message:_.pattern},(r||0===r)&&(i.min={value:r,message:_.minValue}),(n||0===n)&&(i.max={value:n,message:_.maxValue}),i},v=(e,t)=>{const r={};return t&&(r.required=_.required),e.minLength&&(r.minLength={value:e.minLength,message:_.minLength}),e.maxLength&&(r.maxLength={value:e.maxLength,message:_.maxLength}),e.pattern&&(r.pattern={value:new RegExp(e.pattern),message:_.pattern}),r},O=(e,t,r)=>{const{JSONSchema:n,isRequired:i,objectName:a}=t;let s,o,u;if("number"===n.type||"integer"===n.type){const e=b(n);u=e[0],s=f(n),o=y(n)}return{name:a,path:r,isRequired:i,formContext:e,type:p.generic,getError:()=>((e,t,r,n,i,a)=>{if(!e)return;const s={message:_.undefinedError,expected:void 0};switch(e.message){case _.required:s.message=_.required,s.expected=r;break;case _.maxLength:s.message=_.maxLength,s.expected=t.maxLength;break;case _.minLength:s.message=_.minLength,s.expected=t.minLength;break;case _.maxValue:s.message=_.maxValue,s.expected=n;break;case _.minValue:s.message=_.minValue,s.expected=i;break;case _.multipleOf:s.message=_.multipleOf,s.expected=a;break;case _.pattern:s.message=_.pattern,s.expected=t.pattern}return s})(e.errors[r]?e.errors[r]:void 0,n,i,s,o,u),getObject:()=>n}},q=e=>{const t=o(),r=l(e);return O(t,r,e)},L=(e,t)=>e+"-"+t+"-input",j=(e,t)=>{const{register:r}=e.formContext,n=e.getObject();let i,a,s,o,u={};const m={key:""};if("string"===n.type)u=v(n,e.isRequired),m.pattern=n.pattern,m.minLength=n.minLength,m.maxLength=n.maxLength;else if("number"===n.type||"integer"===n.type){const t=b(n);s=t[0],o=t[1],i=f(n),a=y(n),u=x(n,e.isRequired),m.min=i,m.max=a,m.step="any"===s?"any":h(s,o||0)}return Object.assign(Object.assign({},e),{type:p.input,getLabelProps:()=>{const r={};return r.id=((e,t)=>e+"-"+t+"-label")(e.path,t),r.htmlFor=L(e.path,t),r},getInputProps:()=>(m.name=e.path,m.ref=r(u),m.type=t,m.required=e.isRequired,m.id=L(e.path,t),m)})},k=()=>({}),R=e=>Object.assign(Object.assign({},j(e,"hidden")),{isRequired:!1,getLabelProps:k}),S=e=>R(q(e)),V=e=>{let t;switch(e.getObject().format){case"date-time":t="datetime-local";break;case"email":t="email";break;case"hostname":case"uri":t="url";break;default:t="text"}return j(e,t)},I=e=>V(q(e)),P=(e,t,r)=>e+"-radio-input-"+(r[t]?r[t]:""),F=e=>{const t=e.getObject();let r,n,i,a,s={},o=[];if("string"===t.type)o=t.enum?t.enum:[],s=v(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const u=b(t);if(i=u[0],a=u[1],r=f(t),n=y(t),void 0!==r&&void 0!==n&&"any"!=i){s=x(t,e.isRequired);for(let e=r;e<=n;e+=i)o.push(h(e,a||0))}}else"boolean"===t.type&&(s=g(e.isRequired),o=["true","false"]);return Object.assign(Object.assign({},e),{type:p.radio,getLabelProps:()=>{const r={};return r.id=e.path+"-label",r.htmlFor=void 0!==t.title?t.title:e.path,r},getItemInputProps:t=>{const r={key:""};return r.name=e.path,r.ref=e.formContext.register(s),r.type="radio",r.required=e.isRequired,r.id=P(e.path,t,o),r.value=o[t],r},getItemLabelProps:t=>{const r={};return r.id=((e,t,r)=>e+"-radio-label-"+(r[t]?r[t]:""))(e.path,t,o),r.htmlFor=P(e.path,t,o),r},getItems:()=>o})},w=e=>F(q(e)),M=e=>e+"-select",E=e=>{const t=e.getObject();let r,n,i,a,s={},o=[""];if("string"===t.type)o=o.concat(t.enum?t.enum:[]),s=v(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const u=b(t);if(i=u[0],a=u[1],r=f(t),n=y(t),void 0!==r&&void 0!==n&&"any"!=i){s=x(t,e.isRequired);for(let e=r;e<=n;e+=i)o.push(h(e,a||0))}}else"boolean"===t.type&&(s=g(e.isRequired),o=["true","false"]);return Object.assign(Object.assign({},e),{type:p.select,getLabelProps:()=>{const t={};return t.id=e.path+"-label",t.htmlFor=M(e.path),t},getSelectProps:()=>{const t={};return t.name=e.path,t.ref=e.formContext.register(s),t.required=e.isRequired,t.id=M(e.path),t},getItemOptionProps:t=>{const r={};return r.id=((e,t,r)=>e+"-select-option-"+(r[t]?r[t]:""))(e.path,t,o),r.value=o[t],r},getItems:()=>o})},N=e=>E(q(e)),A=e=>j(e,"password"),C=e=>A(q(e)),J=e=>e+"-textarea-input",$=e=>{const t=e.getObject();let r={};const n={};return"string"===t.type?(r=v(t,e.isRequired),n.minLength=t.minLength,n.maxLength=t.maxLength):"number"!==t.type&&"integer"!==t.type||(r=x(t,e.isRequired)),Object.assign(Object.assign({},e),{type:p.textArea,getLabelProps:()=>{const t={};return t.id=e.path+"-textarea-label",t.htmlFor=J(e.path),t},getTextAreaProps:()=>(n.name=e.path,n.ref=e.formContext.register(r),n.required=e.isRequired,n.id=J(e.path),n)})},T=e=>$(q(e));function U(e){const t=e.getObject(),r=[];switch(t.type){case"string":t.enum?r.push(E(e)):r.push(V(e));break;case"integer":case"number":r.push(V(e));break;case"boolean":r.push(F(e))}return r}function z(e,t,r,n){let i=[];const{JSONSchema:a}=t,s=O(e,t,r);if("object"===a.type){return Object.keys(a.properties).reduce(function(e,t,r,n){const i=t.required;return(a,s)=>{const o=!!i&&-1!==i.indexOf(s),u=r&&r.properties?r.properties[s]:void 0,p=c(e,s),m={JSONSchema:t.properties[s],isRequired:o,objectName:s},l=z(n,m,p,u);return a.concat(l)}}(r,a,n,e),[])}if(!n)return i.concat(U(s));switch(n.type){case m.default:i=i.concat(U(s));break;case m.hidden:i.push(R(s));break;case m.input:i.push(V(s));break;case m.password:i.push(A(s));break;case m.radio:i.push(F(s));break;case m.select:i.push(E(s));break;case m.textArea:i.push($(s))}return i}const B=e=>z(o(),l(e.path),e.path,e.UISchema);export{u as FormContext,p as InputTypes,m as UITypes,c as concatFormPath,q as useGenericInput,S as useHidden,I as useInput,B as useObject,d as useObjectFromForm,l as useObjectFromPath,C as usePassword,w as useRadio,N as useSelect,T as useTextArea}; | ||
import{useForm as e}from"react-hook-form";export*from"react-hook-form";import t,{createContext as r,useContext as n}from"react";const i=e=>{const t=e.split("/");return"#"===t[0]&&t.shift(),""===t[t.length-1]&&t.pop(),t},a=(e,t)=>{const r=Object.keys(t).sort(),n={};for(const a of r){const r=i(a);if(!r)continue;let s=n,o=e;for(let e=0;e<r.length&&void 0!==o;e++)o.type&&"object"===o.type?o=o.properties:!o.type&&o[r[e]]&&"object"===o[r[e]].type&&(o=o[r[e]]),e===r.length-1&&(o[r[e]]&&o[r[e]].type&&"integer"===o[r[e]].type?s[r[e]]=parseInt(t[a]):o[r[e]]&&o[r[e]].type&&"number"===o[r[e]].type?s[r[e]]=parseFloat(t[a]):s[r[e]]=t[a]),void 0===s[r[e]]&&(s[r[e]]={}),s=s[r[e]]}return n},s=r(null);function o(){return n(s)}const u=r=>{const{mode:n="onSubmit",revalidateMode:i="onChange",submitFocusError:o=!0}=r,u=e({mode:n,reValidateMode:i,submitFocusError:o}),p={};return p.onSubmit=u.handleSubmit((e,t)=>{r.onSubmit&&r.onSubmit(a(r.schema,e),t)}),r.noNativeValidate&&(p.noValidate=r.noNativeValidate),t.createElement(s.Provider,{value:Object.assign(Object.assign({},u),{schema:r.schema})},t.createElement("form",Object.assign({},p),r.children))};var p,m;!function(e){e.generic="__input_type_generic__",e.radio="__input_type_radio__",e.select="__input_type_select__",e.input="__input_type_input__",e.textArea="__input_type_textArea__"}(p||(p={})),function(e){e.default="__input_type_default__",e.radio="__input_type_radio__",e.select="__input_type_select__",e.input="__input_type_input__",e.hidden="__input_type_hidden__",e.password="__input_type_password__",e.textArea="__input_type_textArea__"}(m||(m={}));const c=(e,t)=>e+"/"+t,l=e=>{const t=i(e);let r=o().schema,n=!1,a="";for(let e=0;e<t.length;e++){if(!r||!r.type||"object"!==r.type){r={};break}n=!!(r.required&&r.required.indexOf(t[e])>-1),a=t[e],r=r.properties[t[e]]}return{JSONSchema:r,isRequired:n,objectName:a}},d=e=>a(o().schema,e);var _;!function(e){e.required="__form_error_required__",e.maxLength="__form_error_maxLenght__",e.minLength="__form_error_minLenght__",e.maxValue="__form_error_maxValue__",e.minValue="__form_error_minValue__",e.pattern="__form_error_pattern__",e.multipleOf="__form_error_multipleOf",e.undefinedError="__form_error_undefinedError__"}(_||(_={}));const g=e=>{const t={};return e&&(t.required=_.required),t},h=(e,t)=>{const r=Math.pow(10,t||0);return String(Math.round(e*r)/r)},f=e=>{const t=void 0!==e.multipleOf?"integer"===e.type?parseInt(e.multipleOf):parseFloat(e.multipleOf):"integer"===e.type?1:"any";let r=void 0;if(e.multipleOf){const t=e.multipleOf.toString().split(".")[1];r=t?t.length:0}return[t,r]},b=e=>{const[t]=f(e);let r=void 0!==e.exclusiveMinimum?e.exclusiveMinimum:void 0!==e.minimum?e.minimum:void 0;return void 0!==r&&void 0!==e.exclusiveMinimum&&(r+=t&&"any"!=t?t:1e-4),r},y=e=>{const[t]=f(e);let r=void 0!==e.exclusiveMaximum?parseFloat(e.exclusiveMaximum):void 0!==e.maximum?parseFloat(e.maximum):void 0;return void 0!==r&&void 0!==e.exclusiveMaximum&&(r-=t&&"any"!=t?t:1e-4),r},x=(e,t)=>{const r=b(e),n=y(e),i={validate:{multipleOf:t=>"integer"!==e.type||e.multipleOf&&(parseInt(t)%parseInt(e.multipleOf)==0||_.multipleOf)}};return t&&(i.required=_.required),"integer"===e.type?i.pattern={value:/^([+-]?[1-9]\d*|0)$/,message:_.pattern}:i.pattern={value:/^([0-9]+([,.][0-9]+))?$/,message:_.pattern},(r||0===r)&&(i.min={value:r,message:_.minValue}),(n||0===n)&&(i.max={value:n,message:_.maxValue}),i},v=(e,t)=>{const r={};return t&&(r.required=_.required),e.minLength&&(r.minLength={value:e.minLength,message:_.minLength}),e.maxLength&&(r.maxLength={value:e.maxLength,message:_.maxLength}),e.pattern&&(r.pattern={value:new RegExp(e.pattern),message:_.pattern}),r},O=(e,t,r)=>{const{JSONSchema:n,isRequired:i,objectName:a}=t;let s,o,u;if("number"===n.type||"integer"===n.type){const e=f(n);u=e[0],s=b(n),o=y(n)}return{name:a,path:r,isRequired:i,formContext:e,type:p.generic,getError:()=>((e,t,r,n,i,a)=>{if(!e)return;const s={message:_.undefinedError,expected:void 0};switch(e.message){case _.required:s.message=_.required,s.expected=r;break;case _.maxLength:s.message=_.maxLength,s.expected=t.maxLength;break;case _.minLength:s.message=_.minLength,s.expected=t.minLength;break;case _.maxValue:s.message=_.maxValue,s.expected=n;break;case _.minValue:s.message=_.minValue,s.expected=i;break;case _.multipleOf:s.message=_.multipleOf,s.expected=a;break;case _.pattern:s.message=_.pattern,s.expected=t.pattern}return s})(e.errors[r]?e.errors[r]:void 0,n,i,s,o,u),getObject:()=>n}},q=e=>{const t=o(),r=l(e);return O(t,r,e)},L=(e,t)=>e+"-"+t+"-input",j=(e,t)=>{const{register:r}=e.formContext,n=e.getObject();let i,a,s,o,u={};const m={key:""};if("string"===n.type)u=v(n,e.isRequired),m.pattern=n.pattern,m.minLength=n.minLength,m.maxLength=n.maxLength;else if("number"===n.type||"integer"===n.type){const t=f(n);s=t[0],o=t[1],i=b(n),a=y(n),u=x(n,e.isRequired),m.min=i,m.max=a,m.step="any"===s?"any":h(s,o||0)}return Object.assign(Object.assign({},e),{type:p.input,getLabelProps:()=>{const r={};return r.id=((e,t)=>e+"-"+t+"-label")(e.path,t),r.htmlFor=L(e.path,t),r},getInputProps:()=>(m.name=e.path,m.ref=r(u),m.type=t,m.required=e.isRequired,m.id=L(e.path,t),m)})},k=()=>({}),R=e=>Object.assign(Object.assign({},j(e,"hidden")),{isRequired:!1,getLabelProps:k}),S=e=>R(q(e)),V=e=>{let t;switch(e.getObject().format){case"date-time":t="datetime-local";break;case"email":t="email";break;case"hostname":case"uri":t="url";break;default:t="text"}return j(e,t)},I=e=>V(q(e)),P=(e,t,r)=>e+"-radio-input-"+(r[t]?r[t]:""),F=e=>{const t=e.getObject();let r,n,i,a,s={},o=[];if("string"===t.type)o=t.enum?t.enum:[],s=v(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const u=f(t);if(i=u[0],a=u[1],r=b(t),n=y(t),void 0!==r&&void 0!==n&&"any"!=i){s=x(t,e.isRequired);for(let e=r;e<=n;e+=i)o.push(h(e,a||0))}}else"boolean"===t.type&&(s=g(e.isRequired),o=["true","false"]);return Object.assign(Object.assign({},e),{type:p.radio,getLabelProps:()=>{const r={};return r.id=e.path+"-label",r.htmlFor=void 0!==t.title?t.title:e.path,r},getItemInputProps:t=>{const r={key:""};return r.name=e.path,r.ref=e.formContext.register(s),r.type="radio",r.required=e.isRequired,r.id=P(e.path,t,o),r.value=o[t],r},getItemLabelProps:t=>{const r={};return r.id=((e,t,r)=>e+"-radio-label-"+(r[t]?r[t]:""))(e.path,t,o),r.htmlFor=P(e.path,t,o),r},getItems:()=>o})},w=e=>F(q(e)),M=e=>e+"-select",E=e=>{const t=e.getObject();let r,n,i,a,s={},o=[""];if("string"===t.type)o=o.concat(t.enum?t.enum:[]),s=v(t,e.isRequired);else if("number"===t.type||"integer"===t.type){const u=f(t);if(i=u[0],a=u[1],r=b(t),n=y(t),void 0!==r&&void 0!==n&&"any"!=i){s=x(t,e.isRequired);for(let e=r;e<=n;e+=i)o.push(h(e,a||0))}}else"boolean"===t.type&&(s=g(e.isRequired),o=["true","false"]);return Object.assign(Object.assign({},e),{type:p.select,getLabelProps:()=>{const t={};return t.id=e.path+"-label",t.htmlFor=M(e.path),t},getSelectProps:()=>{const t={};return t.name=e.path,t.ref=e.formContext.register(s),t.required=e.isRequired,t.id=M(e.path),t},getItemOptionProps:t=>{const r={};return r.id=((e,t,r)=>e+"-select-option-"+(r[t]?r[t]:""))(e.path,t,o),r.value=o[t],r},getItems:()=>o})},N=e=>E(q(e)),A=e=>j(e,"password"),C=e=>A(q(e)),J=e=>e+"-textarea-input",$=e=>{const t=e.getObject();let r={};const n={};return"string"===t.type?(r=v(t,e.isRequired),n.minLength=t.minLength,n.maxLength=t.maxLength):"number"!==t.type&&"integer"!==t.type||(r=x(t,e.isRequired)),Object.assign(Object.assign({},e),{type:p.textArea,getLabelProps:()=>{const t={};return t.id=e.path+"-textarea-label",t.htmlFor=J(e.path),t},getTextAreaProps:()=>(n.name=e.path,n.ref=e.formContext.register(r),n.required=e.isRequired,n.id=J(e.path),n)})},T=e=>$(q(e));function U(e){const t=e.getObject(),r=[];switch(t.type){case"string":t.enum?r.push(E(e)):r.push(V(e));break;case"integer":case"number":r.push(V(e));break;case"boolean":r.push(F(e))}return r}function z(e,t,r,n){let i=[];const{JSONSchema:a}=t,s=O(e,t,r);if("object"===a.type){return Object.keys(a.properties).reduce(function(e,t,r,n){const i=t.required;return(a,s)=>{const o=!!i&&-1!==i.indexOf(s),u=r&&r.properties?r.properties[s]:void 0,p=c(e,s),m={JSONSchema:t.properties[s],isRequired:o,objectName:s},l=z(n,m,p,u);return a.concat(l)}}(r,a,n,e),[])}if(!n)return i.concat(U(s));switch(n.type){case m.default:i=i.concat(U(s));break;case m.hidden:i.push(R(s));break;case m.input:i.push(V(s));break;case m.password:i.push(A(s));break;case m.radio:i.push(F(s));break;case m.select:i.push(E(s));break;case m.textArea:i.push($(s))}return i}const B=e=>z(o(),l(e.path),e.path,e.UISchema);export{u as FormContext,p as InputTypes,m as UITypes,c as concatFormPath,q as useGenericInput,S as useHidden,I as useInput,B as useObject,d as useObjectFromForm,l as useObjectFromPath,C as usePassword,w as useRadio,N as useSelect,T as useTextArea}; |
{ | ||
"name": "react-hook-form-jsonschema", | ||
"version": "0.1.3", | ||
"version": "0.2.0-beta", | ||
"description": "Wrapper arround react-hook-form to create forms from a JSON schema.", | ||
@@ -22,3 +22,5 @@ "main": "output/index.cjs.js", | ||
"eslint-config-vtex-react": "^5.1.0", | ||
"husky": "^4.2.0", | ||
"mutationobserver-shim": "^0.3.3", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^1.18.2", | ||
@@ -42,4 +44,12 @@ "prop-types": "^15.7.2", | ||
"test": "vtex-test-tools test", | ||
"test:watch": "vtex-test-tools test --watch" | ||
"test:watch": "vtex-test-tools test --watch", | ||
"lint": "tsc --noEmit && eslint --quiet --fix --ext ts,tsx src/", | ||
"prepublishOnly": "run-s lint test build" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "run-s lint", | ||
"pre-push": "run-s lint" | ||
} | ||
}, | ||
"dependencies": { | ||
@@ -46,0 +56,0 @@ "react-hook-form": "^4.4.4" |
@@ -12,2 +12,3 @@ # react-hook-form-jsonschema | ||
- [Installation](#installation) | ||
- [API](#api) | ||
- [Components API](#components-api) | ||
@@ -74,2 +75,6 @@ - [FormContext component](#formcontext-component) | ||
## API | ||
This is the API documentation, `react-hook-form-jsonschema` also re-exports all the [`react-hook-form`](https://github.com/react-hook-form/react-hook-form) functionalities, except for the Components and/or functions with the same name as in the `react-hook-form` API in this case they are just wrappers around the original library ones. | ||
## Components API | ||
@@ -76,0 +81,0 @@ |
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
53210
407
523
19