@inntechcorp/it-design 2.2.9 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -2405,7 +2405,7 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
2405
2405
  margin-top: 10px;
2406
2406
  gap: 5px;
2407
2407
 
2408
- `;const Hn=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),Un=new RegExp(/^[a-zA-Z0-9_.-]+$/),Vn=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),Gn=new RegExp(/^[a-z0-9._-]+$/),Yn=new RegExp(/^[a-zA-Z0-9]+$/),Kn=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const Qn=M=>Vn.test(M),Jn=M=>Hn.test(M),Zn=M=>Un.test(M),MA=(M,b)=>M.length>=b,bA=(M,b)=>M.length<=b,zA=(M,b)=>M===b,pA=(M,b)=>M!==b,oA=(M,b)=>M.length===b,cA=M=>Gn.test(M),eA=M=>Yn.test(M),OA=M=>Kn.test(M),tA=M=>function(M){var b,z=0,p=0,o=0;if(11!=M.length)return!1;if(!/^-?\d+$/.test(M))return!1;if(0==Number(M[0]))return!1;if(z=parseInt(M[0])+parseInt(M[2])+parseInt(M[4])+parseInt(M[6])+parseInt(M[8]),b=parseInt(M[1])+parseInt(M[3])+parseInt(M[5])+parseInt(M[7]),z*=7,Math.abs(z-b)%10!=Number(M[9]))return!1;for(o=0;o<10;o++)p+=parseInt(M[o]);return p%10==Number(M[10])}(M),nA=M=>{if(Array.isArray(M)){if(0===M.length)return!1}else{if("object"==typeof M){let b=!0;return Object.keys(M).forEach((z=>{""===M[z]&&(b=!1)})),b}if("string"==typeof M){if(""===M)return!1}else if("boolean"==typeof M&&!1===M)return!1}return!0},AA=p.createContext({});AA.displayName="ITDFormContext";const aA=p.forwardRef((({name:M="",label:z="",placeholder:o="",error:c="",rules:e=[],mask:O=null,locked:t=!1,dependency:n="",reset:A=[],query:a="",children:r=null},i)=>{const{t:d}=b.useTranslation("itd"),s=p.useRef(null),l=p.useRef(""),{register:W,unregister:u,hasField:f,updateField:h,setFieldError:R,getFieldValue:L,getFieldInstance:m,formId:g}=p.useContext(AA),[N,B]=p.useState(!1);p.useEffect((()=>(W({name:M,field:s,valid:x(s.current?.getValue(),!1),query:a,reset:A,error:c}),B(!0),l.current=JSON.stringify(e),()=>{B(!1),u(M)})),[]),p.useEffect((()=>{const b=JSON.stringify(e);if(N&&s.current&&l.current!==b){const z=s.current.getValue(),p=x(z);f(M)&&h(M,z,!1,p),l.current=b}}),[e,N]),p.useImperativeHandle(i,(()=>s.current));const v=(b,z=!0,p=!0)=>{N&&f(M)&&(h(M,b,z,x(b,p)),X())},x=(b,z=!0)=>{const p=function(M,b,z,p){let o=[];return M.forEach((M=>{M.hasOwnProperty(q.REQUIRED)&&!nA(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(q.TYPE)&&(M.type===exports.FormValidationTypes.MIN_LENGTH&&(MA(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.MAX_LENGTH&&(bA(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.EXACT_LENGTH&&(oA(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.SAME&&(zA(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeTheSame",{fields:M.field}))),M.type===exports.FormValidationTypes.NOT_SAME&&(pA(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeDifferent",{fields:M.field}))),M.type===exports.FormValidationTypes.TC_IDENTITY&&(tA(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===exports.FormValidationTypes.PASSWORD&&(Qn(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===exports.FormValidationTypes.EMAIL&&(Jn(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===exports.FormValidationTypes.USERNAME&&(Zn(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===exports.FormValidationTypes.SITE_USERNAME&&(cA(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===exports.FormValidationTypes.ADMIN_USERNAME&&(eA(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===exports.FormValidationTypes.URL&&(OA(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(e,b,L,d);return p.length>0?(z&&R(M,p[0],z),!1):(z&&R(M,""),!0)},X=()=>{if(""===n)return;if(""===L(n))return;const M=m(n);M&&M.forceUpdate&&M.forceUpdate()};return(()=>{if(!r)return null;let b=r.props;const c={id:b.id?b.id:g+"_"+M,label:z,placeholder:o,className:b.className?b.className+" itd-form-item":"itd-form-item",onUpdate:v,ref:s};return O&&(c.mask=O),t&&(c.locked=t),p.cloneElement(r,{...b,...c})})()})),rA=p.forwardRef((({name:M="",className:b="",initialValues:o={},useQueryString:c=!1,onUpdate:e,onFinish:t,onFinishFailed:n,onValidated:a,children:r},i)=>{const{updated:d,setInitialValues:q,isFormValid:s,getValues:l,getFields:W,setFieldValueByName:u,resetFields:f}=p.useContext(AA),h=S(),{search:R}=O.useLocation(),L=k(),[m,g]=p.useState([]),[N,B]=p.useState(!1),[v,x]=p.useState([]),[X,y]=p.useState(!1),[w,T]=p.useState(!1);p.useEffect((()=>{r&&F()}),[r]),p.useEffect((()=>{_(),E()}),[X]),p.useEffect((()=>{X||0!==Object.keys(W()).length&&0!==v.length&&Object.keys(W()).length===v.length&&y(!0)}),[W(),v]),p.useEffect((()=>{E()}),[o]),p.useEffect((()=>{_()}),[R]),p.useEffect((()=>{w&&X&&c&&Object.keys(d).length>0&&P(d)}),[d]),p.useEffect((()=>{a&&s()!==N&&a(s()),B(s())}),[s()]);const _=()=>{X&&c&&(j(),w||D())},E=()=>{X&&(c||w||C())},C=()=>{const M=!Object.values(o).some((M=>null!==M&&""!==M));M&&!w&&T(!0),M||w||(q(o,!1),T(!0))},D=()=>{const M=W(),b=!Object.values(M).some((M=>""!==h.get(M.query,"")));if(Object.values(M).some((M=>null===M.query||""===M.query))){let b=[];throw Object.keys(M).forEach((z=>{M[z].hasOwnProperty("query")&&null!==M[z].query&&""!==M[z].query||b.push(z)})),new Error(`ITD Form Initial Fields Error: "useQueryString" is activated but "query" value is not passed to whole form elements! Invalid fields are ${b.toString()}`)}if(b&&!w&&T(!0),!b&&!w){let b={};Object.keys(M).forEach((z=>{b[z]=h.get(M[z].query,"")})),q(b,!0,!0),T(!0)}},P=M=>{let b=[],z=[];const p=W();Object.keys(M).forEach((b=>{z.push(M[b])})),lc(z,m)||(Object.keys(p).forEach((z=>{b.push({type:p[z].query,value:M[z]})})),L.set(b))},j=()=>{let M=[],b=[];const z=W();if(Object.keys(z).forEach((b=>{let p=String(h.get(z[b].query,""));M.push(p)})),lc(M,m))return;g(M),Object.keys(z).forEach((M=>{b[M]=h.get(z[M].query,"")})),Object.keys(b).forEach((M=>{u(M,b[M],!1,!1)}));let p={};Object.keys(b).forEach((M=>{p[M]=b[M]})),e&&e(p)},F=()=>{let M=[];A.getChildrenDeep(r,(b=>(b.hasOwnProperty("type")&&b.type===aA&&M.push({[b.props.name]:b}),!0))),x(M)};return p.useImperativeHandle(i,(()=>({fieldUpdate(M){console.log("fieldUpdate"),console.log(M)}}))),z.jsx("form",{id:M,onSubmit:M=>{M&&(M.preventDefault(),M.stopPropagation()),s()?t&&t(l()):n&&n(W())},onReset:M=>{M&&(M.preventDefault(),M.stopPropagation());let b=[];Object.keys(W()).map((M=>{b.push({type:M,value:""})})),L.set(b),f(!0,!1)},autoComplete:"off",className:b,noValidate:!0,children:r})}));var iA=p.memo(rA);function dA({name:M="",useQueryString:b=!1,onUpdate:z,onReset:o,onFieldUpdate:c}){const[e,O]=p.useState({}),[t,n]=p.useState(M),[A,a]=p.useState(!1),[r,i]=p.useState({});function d(M){return e.hasOwnProperty(M)&&void 0!==e[M]}function q(){let M={};return Object.keys(e).forEach((b=>{M[b]=W(b)})),M}function s(M,b,z=!0){if(d(M)&&e[M].field.current){if(e[M].valid=!1,e[M].error=b,!e[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);e[M].field.current?.setError(z?b:"")}}function l(){let M=!0;return Object.keys(e).forEach((b=>{e[b].valid||(M=!1)})),a(M),M}function W(M){if(d(M)){if(e[M].field.current?.hasOwnProperty("getValue"))return e[M].field.current?.getValue();throw new Error(`ITD Reference Error: You must declare the 'getValue' function on the field "${M}"`)}console.error(`ITD Form Error [getFieldValueByName]: There is no field registered with this name: ${M}`)}function u(M,b,z,p){if(d(M)){if(!e[M].field.current?.hasOwnProperty("setValue"))throw new Error(`ITD Reference Error: You must declare the 'setValue' function on the field "${M}"`);{let o=W(M),c=!1;c=Array.isArray(o)&&Array.isArray(b)?lc(o,b):Array.isArray(o)||Array.isArray(b)?o.toString()===b.toString():o===b,c||e[M].field.current?.setValue(b,z,p)}}else console.error(`ITD Form Error [setFieldValueByName]: There is no field registered with this name: ${M}`)}return{register:function(M){e[M.name]={name:M.name,field:M.field,value:M.field.current?.getValue(),valid:M.valid,query:M.query,reset:M.reset,error:M.error}},unregister:function(M){d(M)?delete e[M]:console.error(`ITD Form Error [unregister]: There is no field registered with this name: ${M}`)},checkFormIsValid:l,hasField:d,getValues:q,getFieldValue:function(M){return d(M)?(b=e[M].value)instanceof Object?JSON.stringify(b):b:"";var b},getFieldValueByName:W,getFieldInstance:function(M){return d(M)?e[M].field.current:null},getFields:function(){let M={};return Object.keys(e).forEach((b=>{M[b]=e[b]})),M},getFieldsInstance:function(){let M={};return Object.keys(e).forEach((b=>{M[b]=e[b].field.current})),M},setName:function(M){n(M)},setInitialValues:function(M,p=!0,o=!1){Object.keys(M).forEach((b=>{u(b,M[b],p,o)}));let c={};return Object.keys(M).forEach((b=>{c[b]=M[b]})),p&&(b&&i(c),z&&z(c)),l(),c},setInvalidField:function(M="",b=""){s(M,b),l()},setInvalidFields:function(M=[],b=""){M.forEach((M=>{s(M,b)})),l()},setFieldValue:function(M,b){d(M)?(e[M].valid=!1,e[M].field.current?.setValue(b)):console.error(`ITD Form Error [setFieldValue]: There is no field registered with this name: ${M}`)},setFieldValueByName:u,setFieldError:s,removeFieldError:function(M){if(d(M)){if(e[M].valid=!0,e[M].error="",!e[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);e[M].field.current?.setError("")}else console.error(`ITD Form Error [removeFieldError]: There is no field registered with this name: ${M}`)},updateField:function(M,p,o,O){if(d(M)){if(e[M].value=p,e[M].valid=O,o){c&&c({name:M,value:p,valid:O}),e[M].reset.length>0&&e[M].reset.forEach((M=>{e[M].value="",e[M].valid=!1,e[M].field.current?.reset(!1)}));let o={...q(),[M]:p};e[M].reset.length>0&&e[M].reset.forEach((M=>{o[M]=""})),b&&O&&i(o),z&&z(o)}l()}else console.error(`ITD Form Error [updateField]: There is no field registered with this name: ${M}`)},isFormValid:p.useCallback((()=>A),[A]),isFieldsValid:function(M){let b=!0;return M.forEach((M=>{e[M].valid||(b=!1)})),b},isFieldValid:function(M){return e[M].valid},resetFields:function(M=!1,b=!1){Object.keys(e).forEach((z=>{if(!e[z].field.current?.hasOwnProperty("reset"))throw new Error(`ITD Reference Error: You must declare the 'reset' function on the field "${z}"`);e[z].field.current?.reset(M,b)})),o&&o()},removeFields:function(){O({})},formId:t,updated:r}}const qA=p.forwardRef((({initialValues:M,children:b,onUpdate:o,onReset:c,onFinish:e,onFinishFailed:O,onFieldUpdate:t,onValidated:n,useQueryString:A,className:a,name:r},i)=>{const d=p.useRef(null);p.useEffect((()=>()=>{d.current=null}),[]),d.current=dA({name:r,onUpdate:o,onReset:c,onFieldUpdate:t,useQueryString:A}),p.useImperativeHandle(i,(()=>d.current));return z.jsx(AA.Provider,{value:d.current,children:z.jsx(iA,{initialValues:M,useQueryString:A,onUpdate:o,onFinish:e,onFinishFailed:O,onValidated:n,name:r,className:(()=>{let M="itd-form";return r&&(M+=" "+r),a&&(M+=" "+a),M})(),children:b})})}));qA.Item=aA,qA.Group=function({gap:M=15,horizontal:b=!1,className:p,children:o}){const c=()=>{let M="itd-form-group";return p&&(M+=" "+p),M};return z.jsx(In,{className:c(),$gap:M,$horizontal:b,children:o})},qA.Control=function({position:M="end",className:b,children:p}){const o=()=>{let M="itd-form-control";return b&&(M+=" "+b),M};return z.jsx($n,{className:o(),$position:M,children:p})},qA.useForm=()=>p.useContext(AA),qA.useFormAPI=()=>{const M=p.useContext(AA);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const sA=n.div`
2408
+ `;const Hn=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),Un=new RegExp(/^[a-zA-Z0-9_.-]+$/),Vn=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),Gn=new RegExp(/^[a-z0-9._-]+$/),Yn=new RegExp(/^[a-zA-Z0-9]+$/),Kn=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const Qn=M=>Vn.test(M),Jn=M=>Hn.test(M),Zn=M=>Un.test(M),MA=(M,b)=>M.length>=b,bA=(M,b)=>M.length<=b,zA=(M,b)=>M===b,pA=(M,b)=>M!==b,oA=(M,b)=>M.length===b,cA=M=>Gn.test(M),eA=M=>Yn.test(M),OA=M=>Kn.test(M),tA=M=>function(M){var b,z=0,p=0,o=0;if(11!=M.length)return!1;if(!/^-?\d+$/.test(M))return!1;if(0==Number(M[0]))return!1;if(z=parseInt(M[0])+parseInt(M[2])+parseInt(M[4])+parseInt(M[6])+parseInt(M[8]),b=parseInt(M[1])+parseInt(M[3])+parseInt(M[5])+parseInt(M[7]),z*=7,Math.abs(z-b)%10!=Number(M[9]))return!1;for(o=0;o<10;o++)p+=parseInt(M[o]);return p%10==Number(M[10])}(M),nA=M=>{if(Array.isArray(M)){if(0===M.length)return!1}else{if("object"==typeof M){let b=!0;return Object.keys(M).forEach((z=>{""===M[z]&&(b=!1)})),b}if("string"==typeof M){if(""===M)return!1}else if("boolean"==typeof M&&!1===M)return!1}return!0},AA=p.createContext({});AA.displayName="ITDFormContext";const aA=p.forwardRef((({name:M="",label:z="",placeholder:o="",error:c="",rules:e=[],mask:O=null,locked:t=!1,dependency:n="",reset:A=[],query:a="",children:r=null},i)=>{const{t:d}=b.useTranslation("itd"),s=p.useRef(null),l=p.useRef(""),{register:W,unregister:u,hasField:f,updateField:h,setFieldError:R,getFieldValue:L,getFieldInstance:m,formId:g}=p.useContext(AA),[N,B]=p.useState(!1);p.useEffect((()=>(W({name:M,field:s,valid:x(s.current?.getValue(),!1),query:a,reset:A,error:c}),B(!0),l.current=JSON.stringify(e),()=>{B(!1),u(M)})),[]),p.useEffect((()=>{const b=JSON.stringify(e);N&&s.current&&l.current!==b&&(requestAnimationFrame((()=>{if(s.current&&f(M)){const b=s.current.getValue(),z=x(b);h(M,b,!1,z)}})),l.current=b)}),[e,N]),p.useImperativeHandle(i,(()=>s.current));const v=(b,z=!0,p=!0)=>{N&&f(M)&&(h(M,b,z,x(b,p)),X())},x=(b,z=!0)=>{const p=function(M,b,z,p){let o=[];return M.forEach((M=>{M.hasOwnProperty(q.REQUIRED)&&!nA(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(q.TYPE)&&(M.type===exports.FormValidationTypes.MIN_LENGTH&&(MA(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.MAX_LENGTH&&(bA(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.EXACT_LENGTH&&(oA(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.SAME&&(zA(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeTheSame",{fields:M.field}))),M.type===exports.FormValidationTypes.NOT_SAME&&(pA(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeDifferent",{fields:M.field}))),M.type===exports.FormValidationTypes.TC_IDENTITY&&(tA(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===exports.FormValidationTypes.PASSWORD&&(Qn(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===exports.FormValidationTypes.EMAIL&&(Jn(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===exports.FormValidationTypes.USERNAME&&(Zn(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===exports.FormValidationTypes.SITE_USERNAME&&(cA(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===exports.FormValidationTypes.ADMIN_USERNAME&&(eA(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===exports.FormValidationTypes.URL&&(OA(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(e,b,L,d);return p.length>0?(z&&R(M,p[0],z),!1):(z&&R(M,""),!0)},X=()=>{if(""===n)return;if(""===L(n))return;const M=m(n);M&&M.forceUpdate&&M.forceUpdate()};return(()=>{if(!r)return null;let b=r.props;const c={id:b.id?b.id:g+"_"+M,label:z,placeholder:o,className:b.className?b.className+" itd-form-item":"itd-form-item",onUpdate:v,ref:s};return O&&(c.mask=O),t&&(c.locked=t),p.cloneElement(r,{...b,...c})})()})),rA=p.forwardRef((({name:M="",className:b="",initialValues:o={},useQueryString:c=!1,onUpdate:e,onFinish:t,onFinishFailed:n,onValidated:a,children:r},i)=>{const{updated:d,setInitialValues:q,isFormValid:s,getValues:l,getFields:W,setFieldValueByName:u,resetFields:f}=p.useContext(AA),h=S(),{search:R}=O.useLocation(),L=k(),[m,g]=p.useState([]),[N,B]=p.useState(!1),[v,x]=p.useState([]),[X,y]=p.useState(!1),[w,T]=p.useState(!1);p.useEffect((()=>{r&&F()}),[r]),p.useEffect((()=>{_(),E()}),[X]),p.useEffect((()=>{X||0!==Object.keys(W()).length&&0!==v.length&&Object.keys(W()).length===v.length&&y(!0)}),[W(),v]),p.useEffect((()=>{E()}),[o]),p.useEffect((()=>{_()}),[R]),p.useEffect((()=>{w&&X&&c&&Object.keys(d).length>0&&P(d)}),[d]),p.useEffect((()=>{a&&s()!==N&&a(s()),B(s())}),[s()]);const _=()=>{X&&c&&(j(),w||D())},E=()=>{X&&(c||w||C())},C=()=>{const M=!Object.values(o).some((M=>null!==M&&""!==M));M&&!w&&T(!0),M||w||(q(o,!1),T(!0))},D=()=>{const M=W(),b=!Object.values(M).some((M=>""!==h.get(M.query,"")));if(Object.values(M).some((M=>null===M.query||""===M.query))){let b=[];throw Object.keys(M).forEach((z=>{M[z].hasOwnProperty("query")&&null!==M[z].query&&""!==M[z].query||b.push(z)})),new Error(`ITD Form Initial Fields Error: "useQueryString" is activated but "query" value is not passed to whole form elements! Invalid fields are ${b.toString()}`)}if(b&&!w&&T(!0),!b&&!w){let b={};Object.keys(M).forEach((z=>{b[z]=h.get(M[z].query,"")})),q(b,!0,!0),T(!0)}},P=M=>{let b=[],z=[];const p=W();Object.keys(M).forEach((b=>{z.push(M[b])})),lc(z,m)||(Object.keys(p).forEach((z=>{b.push({type:p[z].query,value:M[z]})})),L.set(b))},j=()=>{let M=[],b=[];const z=W();if(Object.keys(z).forEach((b=>{let p=String(h.get(z[b].query,""));M.push(p)})),lc(M,m))return;g(M),Object.keys(z).forEach((M=>{b[M]=h.get(z[M].query,"")})),Object.keys(b).forEach((M=>{u(M,b[M],!1,!1)}));let p={};Object.keys(b).forEach((M=>{p[M]=b[M]})),e&&e(p)},F=()=>{let M=[];A.getChildrenDeep(r,(b=>(b.hasOwnProperty("type")&&b.type===aA&&M.push({[b.props.name]:b}),!0))),x(M)};return p.useImperativeHandle(i,(()=>({fieldUpdate(M){console.log("fieldUpdate"),console.log(M)}}))),z.jsx("form",{id:M,onSubmit:M=>{M&&(M.preventDefault(),M.stopPropagation()),s()?t&&t(l()):n&&n(W())},onReset:M=>{M&&(M.preventDefault(),M.stopPropagation());let b=[];Object.keys(W()).map((M=>{b.push({type:M,value:""})})),L.set(b),f(!0,!1)},autoComplete:"off",className:b,noValidate:!0,children:r})}));var iA=p.memo(rA);function dA({name:M="",useQueryString:b=!1,onUpdate:z,onReset:o,onFieldUpdate:c}){const[e,O]=p.useState({}),[t,n]=p.useState(M),[A,a]=p.useState(!1),[r,i]=p.useState({});function d(M){return e.hasOwnProperty(M)&&void 0!==e[M]}function q(){let M={};return Object.keys(e).forEach((b=>{M[b]=W(b)})),M}function s(M,b,z=!0){if(d(M)&&e[M].field.current){if(e[M].valid=!1,e[M].error=b,!e[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);e[M].field.current?.setError(z?b:"")}}function l(){let M=!0;return Object.keys(e).forEach((b=>{e[b].valid||(M=!1)})),a(M),M}function W(M){if(d(M)){if(e[M].field.current?.hasOwnProperty("getValue"))return e[M].field.current?.getValue();throw new Error(`ITD Reference Error: You must declare the 'getValue' function on the field "${M}"`)}console.error(`ITD Form Error [getFieldValueByName]: There is no field registered with this name: ${M}`)}function u(M,b,z,p){if(d(M)){if(!e[M].field.current?.hasOwnProperty("setValue"))throw new Error(`ITD Reference Error: You must declare the 'setValue' function on the field "${M}"`);{let o=W(M),c=!1;c=Array.isArray(o)&&Array.isArray(b)?lc(o,b):Array.isArray(o)||Array.isArray(b)?o.toString()===b.toString():o===b,c||e[M].field.current?.setValue(b,z,p)}}else console.error(`ITD Form Error [setFieldValueByName]: There is no field registered with this name: ${M}`)}return{register:function(M){e[M.name]={name:M.name,field:M.field,value:M.field.current?.getValue(),valid:M.valid,query:M.query,reset:M.reset,error:M.error}},unregister:function(M){d(M)?delete e[M]:console.error(`ITD Form Error [unregister]: There is no field registered with this name: ${M}`)},checkFormIsValid:l,hasField:d,getValues:q,getFieldValue:function(M){return d(M)?(b=e[M].value)instanceof Object?JSON.stringify(b):b:"";var b},getFieldValueByName:W,getFieldInstance:function(M){return d(M)?e[M].field.current:null},getFields:function(){let M={};return Object.keys(e).forEach((b=>{M[b]=e[b]})),M},getFieldsInstance:function(){let M={};return Object.keys(e).forEach((b=>{M[b]=e[b].field.current})),M},setName:function(M){n(M)},setInitialValues:function(M,p=!0,o=!1){Object.keys(M).forEach((b=>{u(b,M[b],p,o)}));let c={};return Object.keys(M).forEach((b=>{c[b]=M[b]})),p&&(b&&i(c),z&&z(c)),l(),c},setInvalidField:function(M="",b=""){s(M,b),l()},setInvalidFields:function(M=[],b=""){M.forEach((M=>{s(M,b)})),l()},setFieldValue:function(M,b){d(M)?(e[M].valid=!1,e[M].field.current?.setValue(b)):console.error(`ITD Form Error [setFieldValue]: There is no field registered with this name: ${M}`)},setFieldValueByName:u,setFieldError:s,removeFieldError:function(M){if(d(M)){if(e[M].valid=!0,e[M].error="",!e[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);e[M].field.current?.setError("")}else console.error(`ITD Form Error [removeFieldError]: There is no field registered with this name: ${M}`)},updateField:function(M,p,o,O){if(d(M)){if(e[M].value=p,e[M].valid=O,o){c&&c({name:M,value:p,valid:O}),e[M].reset.length>0&&e[M].reset.forEach((M=>{e[M].value="",e[M].valid=!1,e[M].field.current?.reset(!1)}));let o={...q(),[M]:p};e[M].reset.length>0&&e[M].reset.forEach((M=>{o[M]=""})),b&&O&&i(o),z&&z(o)}l()}else console.error(`ITD Form Error [updateField]: There is no field registered with this name: ${M}`)},isFormValid:p.useCallback((()=>A),[A]),isFieldsValid:function(M){let b=!0;return M.forEach((M=>{e[M].valid||(b=!1)})),b},isFieldValid:function(M){return e[M].valid},resetFields:function(M=!1,b=!1){Object.keys(e).forEach((z=>{if(!e[z].field.current?.hasOwnProperty("reset"))throw new Error(`ITD Reference Error: You must declare the 'reset' function on the field "${z}"`);e[z].field.current?.reset(M,b)})),o&&o()},removeFields:function(){O({})},formId:t,updated:r}}const qA=p.forwardRef((({initialValues:M,children:b,onUpdate:o,onReset:c,onFinish:e,onFinishFailed:O,onFieldUpdate:t,onValidated:n,useQueryString:A,className:a,name:r},i)=>{const d=p.useRef(null);p.useEffect((()=>()=>{d.current=null}),[]),d.current=dA({name:r,onUpdate:o,onReset:c,onFieldUpdate:t,useQueryString:A}),p.useImperativeHandle(i,(()=>d.current));return z.jsx(AA.Provider,{value:d.current,children:z.jsx(iA,{initialValues:M,useQueryString:A,onUpdate:o,onFinish:e,onFinishFailed:O,onValidated:n,name:r,className:(()=>{let M="itd-form";return r&&(M+=" "+r),a&&(M+=" "+a),M})(),children:b})})}));qA.Item=aA,qA.Group=function({gap:M=15,horizontal:b=!1,className:p,children:o}){const c=()=>{let M="itd-form-group";return p&&(M+=" "+p),M};return z.jsx(In,{className:c(),$gap:M,$horizontal:b,children:o})},qA.Control=function({position:M="end",className:b,children:p}){const o=()=>{let M="itd-form-control";return b&&(M+=" "+b),M};return z.jsx($n,{className:o(),$position:M,children:p})},qA.useForm=()=>p.useContext(AA),qA.useFormAPI=()=>{const M=p.useContext(AA);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const sA=n.div`
2409
2409
 
2410
2410
  &.itd-accordion-menu-sub-menu {
2411
2411
 
package/dist/index.esm.js CHANGED
@@ -2405,7 +2405,7 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
2405
2405
  margin-top: 10px;
2406
2406
  gap: 5px;
2407
2407
 
2408
- `;const ba=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),za=new RegExp(/^[a-zA-Z0-9_.-]+$/),pa=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),oa=new RegExp(/^[a-z0-9._-]+$/),Oa=new RegExp(/^[a-zA-Z0-9]+$/),ca=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const ea=M=>pa.test(M),ta=M=>ba.test(M),na=M=>za.test(M),Aa=(M,b)=>M.length>=b,aa=(M,b)=>M.length<=b,ia=(M,b)=>M===b,ra=(M,b)=>M!==b,da=(M,b)=>M.length===b,qa=M=>oa.test(M),sa=M=>Oa.test(M),la=M=>ca.test(M),Wa=M=>function(M){var b,z=0,p=0,o=0;if(11!=M.length)return!1;if(!/^-?\d+$/.test(M))return!1;if(0==Number(M[0]))return!1;if(z=parseInt(M[0])+parseInt(M[2])+parseInt(M[4])+parseInt(M[6])+parseInt(M[8]),b=parseInt(M[1])+parseInt(M[3])+parseInt(M[5])+parseInt(M[7]),z*=7,Math.abs(z-b)%10!=Number(M[9]))return!1;for(o=0;o<10;o++)p+=parseInt(M[o]);return p%10==Number(M[10])}(M),ua=M=>{if(Array.isArray(M)){if(0===M.length)return!1}else{if("object"==typeof M){let b=!0;return Object.keys(M).forEach((z=>{""===M[z]&&(b=!1)})),b}if("string"==typeof M){if(""===M)return!1}else if("boolean"==typeof M&&!1===M)return!1}return!0},fa=q({});fa.displayName="ITDFormContext";const ha=W((({name:M="",label:z="",placeholder:p="",error:o="",rules:O=[],mask:c=null,locked:e=!1,dependency:i="",reset:r=[],query:q="",children:s=null},l)=>{const{t:W}=b("itd"),f=A(null),h=A(""),{register:R,unregister:L,hasField:m,updateField:g,setFieldError:N,getFieldValue:B,getFieldInstance:v,formId:X}=a(fa),[y,x]=t(!1);n((()=>(R({name:M,field:f,valid:T(f.current?.getValue(),!1),query:q,reset:r,error:o}),x(!0),h.current=JSON.stringify(O),()=>{x(!1),L(M)})),[]),n((()=>{const b=JSON.stringify(O);if(y&&f.current&&h.current!==b){const z=f.current.getValue(),p=T(z);m(M)&&g(M,z,!1,p),h.current=b}}),[O,y]),u(l,(()=>f.current));const w=(b,z=!0,p=!0)=>{y&&m(M)&&(g(M,b,z,T(b,p)),_())},T=(b,z=!0)=>{const p=function(M,b,z,p){let o=[];return M.forEach((M=>{M.hasOwnProperty(I.REQUIRED)&&!ua(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(I.TYPE)&&(M.type===$.MIN_LENGTH&&(Aa(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===$.MAX_LENGTH&&(aa(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===$.EXACT_LENGTH&&(da(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===$.SAME&&(ia(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeTheSame",{fields:M.field}))),M.type===$.NOT_SAME&&(ra(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeDifferent",{fields:M.field}))),M.type===$.TC_IDENTITY&&(Wa(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===$.PASSWORD&&(ea(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===$.EMAIL&&(ta(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===$.USERNAME&&(na(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===$.SITE_USERNAME&&(qa(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===$.ADMIN_USERNAME&&(sa(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===$.URL&&(la(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(O,b,B,W);return p.length>0?(z&&N(M,p[0],z),!1):(z&&N(M,""),!0)},_=()=>{if(""===i)return;if(""===B(i))return;const M=v(i);M&&M.forceUpdate&&M.forceUpdate()};return(()=>{if(!s)return null;let b=s.props;const o={id:b.id?b.id:X+"_"+M,label:z,placeholder:p,className:b.className?b.className+" itd-form-item":"itd-form-item",onUpdate:w,ref:f};return c&&(o.mask=c),e&&(o.locked=e),d(s,{...b,...o})})()})),Ra=W((({name:M="",className:b="",initialValues:z={},useQueryString:o=!1,onUpdate:O,onFinish:c,onFinishFailed:e,onValidated:A,children:i},r)=>{const{updated:d,setInitialValues:q,isFormValid:s,getValues:l,getFields:W,setFieldValueByName:f,resetFields:h}=a(fa),R=AM(),{search:L}=T(),m=aM(),[g,N]=t([]),[B,v]=t(!1),[X,y]=t([]),[x,w]=t(!1),[_,k]=t(!1);n((()=>{i&&$()}),[i]),n((()=>{S(),E()}),[x]),n((()=>{x||0!==Object.keys(W()).length&&0!==X.length&&Object.keys(W()).length===X.length&&w(!0)}),[W(),X]),n((()=>{E()}),[z]),n((()=>{S()}),[L]),n((()=>{_&&x&&o&&Object.keys(d).length>0&&F(d)}),[d]),n((()=>{A&&s()!==B&&A(s()),v(s())}),[s()]);const S=()=>{x&&o&&(I(),_||P())},E=()=>{x&&(o||_||D())},D=()=>{const M=!Object.values(z).some((M=>null!==M&&""!==M));M&&!_&&k(!0),M||_||(q(z,!1),k(!0))},P=()=>{const M=W(),b=!Object.values(M).some((M=>""!==R.get(M.query,"")));if(Object.values(M).some((M=>null===M.query||""===M.query))){let b=[];throw Object.keys(M).forEach((z=>{M[z].hasOwnProperty("query")&&null!==M[z].query&&""!==M[z].query||b.push(z)})),new Error(`ITD Form Initial Fields Error: "useQueryString" is activated but "query" value is not passed to whole form elements! Invalid fields are ${b.toString()}`)}if(b&&!_&&k(!0),!b&&!_){let b={};Object.keys(M).forEach((z=>{b[z]=R.get(M[z].query,"")})),q(b,!0,!0),k(!0)}},F=M=>{let b=[],z=[];const p=W();Object.keys(M).forEach((b=>{z.push(M[b])})),Bc(z,g)||(Object.keys(p).forEach((z=>{b.push({type:p[z].query,value:M[z]})})),m.set(b))},I=()=>{let M=[],b=[];const z=W();if(Object.keys(z).forEach((b=>{let p=String(R.get(z[b].query,""));M.push(p)})),Bc(M,g))return;N(M),Object.keys(z).forEach((M=>{b[M]=R.get(z[M].query,"")})),Object.keys(b).forEach((M=>{f(M,b[M],!1,!1)}));let p={};Object.keys(b).forEach((M=>{p[M]=b[M]})),O&&O(p)},$=()=>{let M=[];C(i,(b=>(b.hasOwnProperty("type")&&b.type===ha&&M.push({[b.props.name]:b}),!0))),y(M)};return u(r,(()=>({fieldUpdate(M){console.log("fieldUpdate"),console.log(M)}}))),p("form",{id:M,onSubmit:M=>{M&&(M.preventDefault(),M.stopPropagation()),s()?c&&c(l()):e&&e(W())},onReset:M=>{M&&(M.preventDefault(),M.stopPropagation());let b=[];Object.keys(W()).map((M=>{b.push({type:M,value:""})})),m.set(b),h(!0,!1)},autoComplete:"off",className:b,noValidate:!0,children:i})}));var La=R(Ra);function ma({name:M="",useQueryString:b=!1,onUpdate:z,onReset:p,onFieldUpdate:o}){const[O,c]=t({}),[e,n]=t(M),[A,a]=t(!1),[i,r]=t({});function d(M){return O.hasOwnProperty(M)&&void 0!==O[M]}function q(){let M={};return Object.keys(O).forEach((b=>{M[b]=u(b)})),M}function l(M,b,z=!0){if(d(M)&&O[M].field.current){if(O[M].valid=!1,O[M].error=b,!O[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);O[M].field.current?.setError(z?b:"")}}function W(){let M=!0;return Object.keys(O).forEach((b=>{O[b].valid||(M=!1)})),a(M),M}function u(M){if(d(M)){if(O[M].field.current?.hasOwnProperty("getValue"))return O[M].field.current?.getValue();throw new Error(`ITD Reference Error: You must declare the 'getValue' function on the field "${M}"`)}console.error(`ITD Form Error [getFieldValueByName]: There is no field registered with this name: ${M}`)}function f(M,b,z,p){if(d(M)){if(!O[M].field.current?.hasOwnProperty("setValue"))throw new Error(`ITD Reference Error: You must declare the 'setValue' function on the field "${M}"`);{let o=u(M),c=!1;c=Array.isArray(o)&&Array.isArray(b)?Bc(o,b):Array.isArray(o)||Array.isArray(b)?o.toString()===b.toString():o===b,c||O[M].field.current?.setValue(b,z,p)}}else console.error(`ITD Form Error [setFieldValueByName]: There is no field registered with this name: ${M}`)}return{register:function(M){O[M.name]={name:M.name,field:M.field,value:M.field.current?.getValue(),valid:M.valid,query:M.query,reset:M.reset,error:M.error}},unregister:function(M){d(M)?delete O[M]:console.error(`ITD Form Error [unregister]: There is no field registered with this name: ${M}`)},checkFormIsValid:W,hasField:d,getValues:q,getFieldValue:function(M){return d(M)?(b=O[M].value)instanceof Object?JSON.stringify(b):b:"";var b},getFieldValueByName:u,getFieldInstance:function(M){return d(M)?O[M].field.current:null},getFields:function(){let M={};return Object.keys(O).forEach((b=>{M[b]=O[b]})),M},getFieldsInstance:function(){let M={};return Object.keys(O).forEach((b=>{M[b]=O[b].field.current})),M},setName:function(M){n(M)},setInitialValues:function(M,p=!0,o=!1){Object.keys(M).forEach((b=>{f(b,M[b],p,o)}));let O={};return Object.keys(M).forEach((b=>{O[b]=M[b]})),p&&(b&&r(O),z&&z(O)),W(),O},setInvalidField:function(M="",b=""){l(M,b),W()},setInvalidFields:function(M=[],b=""){M.forEach((M=>{l(M,b)})),W()},setFieldValue:function(M,b){d(M)?(O[M].valid=!1,O[M].field.current?.setValue(b)):console.error(`ITD Form Error [setFieldValue]: There is no field registered with this name: ${M}`)},setFieldValueByName:f,setFieldError:l,removeFieldError:function(M){if(d(M)){if(O[M].valid=!0,O[M].error="",!O[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);O[M].field.current?.setError("")}else console.error(`ITD Form Error [removeFieldError]: There is no field registered with this name: ${M}`)},updateField:function(M,p,c,e){if(d(M)){if(O[M].value=p,O[M].valid=e,c){o&&o({name:M,value:p,valid:e}),O[M].reset.length>0&&O[M].reset.forEach((M=>{O[M].value="",O[M].valid=!1,O[M].field.current?.reset(!1)}));let c={...q(),[M]:p};O[M].reset.length>0&&O[M].reset.forEach((M=>{c[M]=""})),b&&e&&r(c),z&&z(c)}W()}else console.error(`ITD Form Error [updateField]: There is no field registered with this name: ${M}`)},isFormValid:s((()=>A),[A]),isFieldsValid:function(M){let b=!0;return M.forEach((M=>{O[M].valid||(b=!1)})),b},isFieldValid:function(M){return O[M].valid},resetFields:function(M=!1,b=!1){Object.keys(O).forEach((z=>{if(!O[z].field.current?.hasOwnProperty("reset"))throw new Error(`ITD Reference Error: You must declare the 'reset' function on the field "${z}"`);O[z].field.current?.reset(M,b)})),p&&p()},removeFields:function(){c({})},formId:e,updated:i}}const ga=W((({initialValues:M,children:b,onUpdate:z,onReset:o,onFinish:O,onFinishFailed:c,onFieldUpdate:e,onValidated:t,useQueryString:a,className:i,name:r},d)=>{const q=A(null);n((()=>()=>{q.current=null}),[]),q.current=ma({name:r,onUpdate:z,onReset:o,onFieldUpdate:e,useQueryString:a}),u(d,(()=>q.current));return p(fa.Provider,{value:q.current,children:p(La,{initialValues:M,useQueryString:a,onUpdate:z,onFinish:O,onFinishFailed:c,onValidated:t,name:r,className:(()=>{let M="itd-form";return r&&(M+=" "+r),i&&(M+=" "+i),M})(),children:b})})}));ga.Item=ha,ga.Group=function({gap:M=15,horizontal:b=!1,className:z,children:o}){return p(ZA,{className:(()=>{let M="itd-form-group";return z&&(M+=" "+z),M})(),$gap:M,$horizontal:b,children:o})},ga.Control=function({position:M="end",className:b,children:z}){return p(Ma,{className:(()=>{let M="itd-form-control";return b&&(M+=" "+b),M})(),$position:M,children:z})},ga.useForm=()=>a(fa),ga.useFormAPI=()=>{const M=a(fa);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const Na=k.div`
2408
+ `;const ba=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),za=new RegExp(/^[a-zA-Z0-9_.-]+$/),pa=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),oa=new RegExp(/^[a-z0-9._-]+$/),Oa=new RegExp(/^[a-zA-Z0-9]+$/),ca=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const ea=M=>pa.test(M),ta=M=>ba.test(M),na=M=>za.test(M),Aa=(M,b)=>M.length>=b,aa=(M,b)=>M.length<=b,ia=(M,b)=>M===b,ra=(M,b)=>M!==b,da=(M,b)=>M.length===b,qa=M=>oa.test(M),sa=M=>Oa.test(M),la=M=>ca.test(M),Wa=M=>function(M){var b,z=0,p=0,o=0;if(11!=M.length)return!1;if(!/^-?\d+$/.test(M))return!1;if(0==Number(M[0]))return!1;if(z=parseInt(M[0])+parseInt(M[2])+parseInt(M[4])+parseInt(M[6])+parseInt(M[8]),b=parseInt(M[1])+parseInt(M[3])+parseInt(M[5])+parseInt(M[7]),z*=7,Math.abs(z-b)%10!=Number(M[9]))return!1;for(o=0;o<10;o++)p+=parseInt(M[o]);return p%10==Number(M[10])}(M),ua=M=>{if(Array.isArray(M)){if(0===M.length)return!1}else{if("object"==typeof M){let b=!0;return Object.keys(M).forEach((z=>{""===M[z]&&(b=!1)})),b}if("string"==typeof M){if(""===M)return!1}else if("boolean"==typeof M&&!1===M)return!1}return!0},fa=q({});fa.displayName="ITDFormContext";const ha=W((({name:M="",label:z="",placeholder:p="",error:o="",rules:O=[],mask:c=null,locked:e=!1,dependency:i="",reset:r=[],query:q="",children:s=null},l)=>{const{t:W}=b("itd"),f=A(null),h=A(""),{register:R,unregister:L,hasField:m,updateField:g,setFieldError:N,getFieldValue:B,getFieldInstance:v,formId:X}=a(fa),[y,x]=t(!1);n((()=>(R({name:M,field:f,valid:T(f.current?.getValue(),!1),query:q,reset:r,error:o}),x(!0),h.current=JSON.stringify(O),()=>{x(!1),L(M)})),[]),n((()=>{const b=JSON.stringify(O);y&&f.current&&h.current!==b&&(requestAnimationFrame((()=>{if(f.current&&m(M)){const b=f.current.getValue(),z=T(b);g(M,b,!1,z)}})),h.current=b)}),[O,y]),u(l,(()=>f.current));const w=(b,z=!0,p=!0)=>{y&&m(M)&&(g(M,b,z,T(b,p)),_())},T=(b,z=!0)=>{const p=function(M,b,z,p){let o=[];return M.forEach((M=>{M.hasOwnProperty(I.REQUIRED)&&!ua(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(I.TYPE)&&(M.type===$.MIN_LENGTH&&(Aa(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===$.MAX_LENGTH&&(aa(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===$.EXACT_LENGTH&&(da(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===$.SAME&&(ia(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeTheSame",{fields:M.field}))),M.type===$.NOT_SAME&&(ra(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeDifferent",{fields:M.field}))),M.type===$.TC_IDENTITY&&(Wa(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===$.PASSWORD&&(ea(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===$.EMAIL&&(ta(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===$.USERNAME&&(na(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===$.SITE_USERNAME&&(qa(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===$.ADMIN_USERNAME&&(sa(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===$.URL&&(la(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(O,b,B,W);return p.length>0?(z&&N(M,p[0],z),!1):(z&&N(M,""),!0)},_=()=>{if(""===i)return;if(""===B(i))return;const M=v(i);M&&M.forceUpdate&&M.forceUpdate()};return(()=>{if(!s)return null;let b=s.props;const o={id:b.id?b.id:X+"_"+M,label:z,placeholder:p,className:b.className?b.className+" itd-form-item":"itd-form-item",onUpdate:w,ref:f};return c&&(o.mask=c),e&&(o.locked=e),d(s,{...b,...o})})()})),Ra=W((({name:M="",className:b="",initialValues:z={},useQueryString:o=!1,onUpdate:O,onFinish:c,onFinishFailed:e,onValidated:A,children:i},r)=>{const{updated:d,setInitialValues:q,isFormValid:s,getValues:l,getFields:W,setFieldValueByName:f,resetFields:h}=a(fa),R=AM(),{search:L}=T(),m=aM(),[g,N]=t([]),[B,v]=t(!1),[X,y]=t([]),[x,w]=t(!1),[_,k]=t(!1);n((()=>{i&&$()}),[i]),n((()=>{S(),E()}),[x]),n((()=>{x||0!==Object.keys(W()).length&&0!==X.length&&Object.keys(W()).length===X.length&&w(!0)}),[W(),X]),n((()=>{E()}),[z]),n((()=>{S()}),[L]),n((()=>{_&&x&&o&&Object.keys(d).length>0&&F(d)}),[d]),n((()=>{A&&s()!==B&&A(s()),v(s())}),[s()]);const S=()=>{x&&o&&(I(),_||P())},E=()=>{x&&(o||_||D())},D=()=>{const M=!Object.values(z).some((M=>null!==M&&""!==M));M&&!_&&k(!0),M||_||(q(z,!1),k(!0))},P=()=>{const M=W(),b=!Object.values(M).some((M=>""!==R.get(M.query,"")));if(Object.values(M).some((M=>null===M.query||""===M.query))){let b=[];throw Object.keys(M).forEach((z=>{M[z].hasOwnProperty("query")&&null!==M[z].query&&""!==M[z].query||b.push(z)})),new Error(`ITD Form Initial Fields Error: "useQueryString" is activated but "query" value is not passed to whole form elements! Invalid fields are ${b.toString()}`)}if(b&&!_&&k(!0),!b&&!_){let b={};Object.keys(M).forEach((z=>{b[z]=R.get(M[z].query,"")})),q(b,!0,!0),k(!0)}},F=M=>{let b=[],z=[];const p=W();Object.keys(M).forEach((b=>{z.push(M[b])})),Bc(z,g)||(Object.keys(p).forEach((z=>{b.push({type:p[z].query,value:M[z]})})),m.set(b))},I=()=>{let M=[],b=[];const z=W();if(Object.keys(z).forEach((b=>{let p=String(R.get(z[b].query,""));M.push(p)})),Bc(M,g))return;N(M),Object.keys(z).forEach((M=>{b[M]=R.get(z[M].query,"")})),Object.keys(b).forEach((M=>{f(M,b[M],!1,!1)}));let p={};Object.keys(b).forEach((M=>{p[M]=b[M]})),O&&O(p)},$=()=>{let M=[];C(i,(b=>(b.hasOwnProperty("type")&&b.type===ha&&M.push({[b.props.name]:b}),!0))),y(M)};return u(r,(()=>({fieldUpdate(M){console.log("fieldUpdate"),console.log(M)}}))),p("form",{id:M,onSubmit:M=>{M&&(M.preventDefault(),M.stopPropagation()),s()?c&&c(l()):e&&e(W())},onReset:M=>{M&&(M.preventDefault(),M.stopPropagation());let b=[];Object.keys(W()).map((M=>{b.push({type:M,value:""})})),m.set(b),h(!0,!1)},autoComplete:"off",className:b,noValidate:!0,children:i})}));var La=R(Ra);function ma({name:M="",useQueryString:b=!1,onUpdate:z,onReset:p,onFieldUpdate:o}){const[O,c]=t({}),[e,n]=t(M),[A,a]=t(!1),[i,r]=t({});function d(M){return O.hasOwnProperty(M)&&void 0!==O[M]}function q(){let M={};return Object.keys(O).forEach((b=>{M[b]=u(b)})),M}function l(M,b,z=!0){if(d(M)&&O[M].field.current){if(O[M].valid=!1,O[M].error=b,!O[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);O[M].field.current?.setError(z?b:"")}}function W(){let M=!0;return Object.keys(O).forEach((b=>{O[b].valid||(M=!1)})),a(M),M}function u(M){if(d(M)){if(O[M].field.current?.hasOwnProperty("getValue"))return O[M].field.current?.getValue();throw new Error(`ITD Reference Error: You must declare the 'getValue' function on the field "${M}"`)}console.error(`ITD Form Error [getFieldValueByName]: There is no field registered with this name: ${M}`)}function f(M,b,z,p){if(d(M)){if(!O[M].field.current?.hasOwnProperty("setValue"))throw new Error(`ITD Reference Error: You must declare the 'setValue' function on the field "${M}"`);{let o=u(M),c=!1;c=Array.isArray(o)&&Array.isArray(b)?Bc(o,b):Array.isArray(o)||Array.isArray(b)?o.toString()===b.toString():o===b,c||O[M].field.current?.setValue(b,z,p)}}else console.error(`ITD Form Error [setFieldValueByName]: There is no field registered with this name: ${M}`)}return{register:function(M){O[M.name]={name:M.name,field:M.field,value:M.field.current?.getValue(),valid:M.valid,query:M.query,reset:M.reset,error:M.error}},unregister:function(M){d(M)?delete O[M]:console.error(`ITD Form Error [unregister]: There is no field registered with this name: ${M}`)},checkFormIsValid:W,hasField:d,getValues:q,getFieldValue:function(M){return d(M)?(b=O[M].value)instanceof Object?JSON.stringify(b):b:"";var b},getFieldValueByName:u,getFieldInstance:function(M){return d(M)?O[M].field.current:null},getFields:function(){let M={};return Object.keys(O).forEach((b=>{M[b]=O[b]})),M},getFieldsInstance:function(){let M={};return Object.keys(O).forEach((b=>{M[b]=O[b].field.current})),M},setName:function(M){n(M)},setInitialValues:function(M,p=!0,o=!1){Object.keys(M).forEach((b=>{f(b,M[b],p,o)}));let O={};return Object.keys(M).forEach((b=>{O[b]=M[b]})),p&&(b&&r(O),z&&z(O)),W(),O},setInvalidField:function(M="",b=""){l(M,b),W()},setInvalidFields:function(M=[],b=""){M.forEach((M=>{l(M,b)})),W()},setFieldValue:function(M,b){d(M)?(O[M].valid=!1,O[M].field.current?.setValue(b)):console.error(`ITD Form Error [setFieldValue]: There is no field registered with this name: ${M}`)},setFieldValueByName:f,setFieldError:l,removeFieldError:function(M){if(d(M)){if(O[M].valid=!0,O[M].error="",!O[M].field.current?.hasOwnProperty("setError"))throw new Error(`ITD Reference Error: You must declare the 'setError' function on the field "${M}"`);O[M].field.current?.setError("")}else console.error(`ITD Form Error [removeFieldError]: There is no field registered with this name: ${M}`)},updateField:function(M,p,c,e){if(d(M)){if(O[M].value=p,O[M].valid=e,c){o&&o({name:M,value:p,valid:e}),O[M].reset.length>0&&O[M].reset.forEach((M=>{O[M].value="",O[M].valid=!1,O[M].field.current?.reset(!1)}));let c={...q(),[M]:p};O[M].reset.length>0&&O[M].reset.forEach((M=>{c[M]=""})),b&&e&&r(c),z&&z(c)}W()}else console.error(`ITD Form Error [updateField]: There is no field registered with this name: ${M}`)},isFormValid:s((()=>A),[A]),isFieldsValid:function(M){let b=!0;return M.forEach((M=>{O[M].valid||(b=!1)})),b},isFieldValid:function(M){return O[M].valid},resetFields:function(M=!1,b=!1){Object.keys(O).forEach((z=>{if(!O[z].field.current?.hasOwnProperty("reset"))throw new Error(`ITD Reference Error: You must declare the 'reset' function on the field "${z}"`);O[z].field.current?.reset(M,b)})),p&&p()},removeFields:function(){c({})},formId:e,updated:i}}const ga=W((({initialValues:M,children:b,onUpdate:z,onReset:o,onFinish:O,onFinishFailed:c,onFieldUpdate:e,onValidated:t,useQueryString:a,className:i,name:r},d)=>{const q=A(null);n((()=>()=>{q.current=null}),[]),q.current=ma({name:r,onUpdate:z,onReset:o,onFieldUpdate:e,useQueryString:a}),u(d,(()=>q.current));return p(fa.Provider,{value:q.current,children:p(La,{initialValues:M,useQueryString:a,onUpdate:z,onFinish:O,onFinishFailed:c,onValidated:t,name:r,className:(()=>{let M="itd-form";return r&&(M+=" "+r),i&&(M+=" "+i),M})(),children:b})})}));ga.Item=ha,ga.Group=function({gap:M=15,horizontal:b=!1,className:z,children:o}){return p(ZA,{className:(()=>{let M="itd-form-group";return z&&(M+=" "+z),M})(),$gap:M,$horizontal:b,children:o})},ga.Control=function({position:M="end",className:b,children:z}){return p(Ma,{className:(()=>{let M="itd-form-control";return b&&(M+=" "+b),M})(),$position:M,children:z})},ga.useForm=()=>a(fa),ga.useFormAPI=()=>{const M=a(fa);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const Na=k.div`
2409
2409
 
2410
2410
  &.itd-accordion-menu-sub-menu {
2411
2411
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inntechcorp/it-design",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "description": "All in one Design library for web applications.",
5
5
  "author": "Inn.Tech",
6
6
  "license": "ISC",