@inntechcorp/it-design 2.2.20 → 2.2.22

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
@@ -2399,7 +2399,7 @@ function(b,z){M.exports?M.exports=z(Eo()):z(b.moment)}(Fo,(function(M){void 0===
2399
2399
  margin-top: 10px;
2400
2400
  gap: 5px;
2401
2401
 
2402
- `;const jn=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),Pn=new RegExp(/^[a-zA-Z0-9_.-]+$/),Fn=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),In=new RegExp(/^[a-z0-9._-]+$/),$n=new RegExp(/^[a-zA-Z0-9]+$/),Hn=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const Un=M=>Fn.test(M),Vn=M=>jn.test(M),Gn=M=>Pn.test(M),Yn=(M,b)=>M.length>=b,Kn=(M,b)=>M.length<=b,Qn=(M,b)=>M===b,Jn=(M,b)=>M!==b,Zn=(M,b)=>M.length===b,MA=M=>In.test(M),bA=M=>$n.test(M),zA=M=>Hn.test(M),pA=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),oA=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},cA=p.createContext({});cA.displayName="ITDFormContext";const OA=p.forwardRef((({name:M="",label:z="",placeholder:o="",error:c="",rules:O=[],mask:e=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(cA),[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(O),()=>{B(!1),u(M)})),[]),p.useEffect((()=>{const b=JSON.stringify(O);if(N&&s.current&&l.current!==b){const z=()=>{const b=s.current.getValue(),z=x(b);f(M)&&h(M,b,!1,z)};"development"===process.env.NODE_ENV?requestAnimationFrame(z):z(),l.current=b}}),[O,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)&&!oA(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(q.TYPE)&&(M.type===exports.FormValidationTypes.MIN_LENGTH&&(Yn(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.MAX_LENGTH&&(Kn(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.EXACT_LENGTH&&(Zn(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.SAME&&(Qn(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&&(Jn(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&&(pA(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===exports.FormValidationTypes.PASSWORD&&(Un(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===exports.FormValidationTypes.EMAIL&&(Vn(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===exports.FormValidationTypes.USERNAME&&(Gn(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===exports.FormValidationTypes.SITE_USERNAME&&(MA(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===exports.FormValidationTypes.ADMIN_USERNAME&&(bA(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===exports.FormValidationTypes.URL&&(zA(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(O,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 e&&(c.mask=e),t&&(c.locked=t),p.cloneElement(r,{...b,...c})})()})),eA=p.forwardRef((({name:M="",className:b="",initialValues:o={},useQueryString:c=!1,onUpdate:O,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(cA),h=S(),{search:R}=e.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&&j(d)}),[d]),p.useEffect((()=>{a&&s()!==N&&a(s()),B(s())}),[s()]);const _=()=>{X&&c&&(P(),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)}},j=M=>{let b=[],z=[];const p=W();Object.keys(M).forEach((b=>{z.push(M[b])})),rc(z,m)||(Object.keys(p).forEach((z=>{b.push({type:p[z].query,value:M[z]})})),L.set(b))},P=()=>{let M=[],b=[];const z=W();if(Object.keys(z).forEach((b=>{let p=String(h.get(z[b].query,""));M.push(p)})),rc(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]})),O&&O(p)},F=()=>{let M=[];A.getChildrenDeep(r,(b=>(b.hasOwnProperty("type")&&b.type===OA&&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 tA=p.memo(eA);function nA({name:M="",useQueryString:b=!1,onUpdate:z,onReset:o,onFieldUpdate:c}){const[O,e]=p.useState({}),[t,n]=p.useState(M),[A,a]=p.useState(!1),[r,i]=p.useState({});function d(M){return O.hasOwnProperty(M)&&void 0!==O[M]}function q(){let M={};return Object.keys(O).forEach((b=>{M[b]=W(b)})),M}function s(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 l(){let M=!0;return Object.keys(O).forEach((b=>{O[b].valid||(M=!1)})),a(M),M}function W(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 u(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=W(M),c=!1;c=Array.isArray(o)&&Array.isArray(b)?rc(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],l()):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=O[M].value)instanceof Object?JSON.stringify(b):b:"";var b},getFieldValueByName:W,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=>{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)?(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:u,setFieldError:s,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,o,e){if(d(M)){if(O[M].value=p,O[M].valid=e,o){c&&c({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 o={...q(),[M]:p};O[M].reset.length>0&&O[M].reset.forEach((M=>{o[M]=""})),b&&e&&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=>{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)})),o&&o()},removeFields:function(){e({})},formId:t,updated:r}}const AA=p.forwardRef((({initialValues:M,children:b,onUpdate:o,onReset:c,onFinish:O,onFinishFailed:e,onFieldUpdate:t,onValidated:n,useQueryString:A,className:a,name:r},i)=>{const d=p.useRef(null);p.useEffect((()=>()=>{d.current=null}),[]),d.current=nA({name:r,onUpdate:o,onReset:c,onFieldUpdate:t,useQueryString:A}),p.useImperativeHandle(i,(()=>d.current));return z.jsx(cA.Provider,{value:d.current,children:z.jsx(tA,{initialValues:M,useQueryString:A,onUpdate:o,onFinish:O,onFinishFailed:e,onValidated:n,name:r,className:(()=>{let M="itd-form";return r&&(M+=" "+r),a&&(M+=" "+a),M})(),children:b})})}));AA.Item=OA,AA.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(Cn,{className:c(),$gap:M,$horizontal:b,children:o})},AA.Control=function({position:M="end",className:b,children:p}){const o=()=>{let M="itd-form-control";return b&&(M+=" "+b),M};return z.jsx(Dn,{className:o(),$position:M,children:p})},AA.useForm=()=>p.useContext(cA),AA.useFormAPI=()=>{const M=p.useContext(cA);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const aA=n.div`
2402
+ `;const jn=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),Pn=new RegExp(/^[a-zA-Z0-9_.-]+$/),Fn=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),In=new RegExp(/^[a-z0-9._-]+$/),$n=new RegExp(/^[a-zA-Z0-9]+$/),Hn=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const Un=M=>Fn.test(M),Vn=M=>jn.test(M),Gn=M=>Pn.test(M),Yn=(M,b)=>M.length>=b,Kn=(M,b)=>M.length<=b,Qn=(M,b)=>M===b,Jn=(M,b)=>M!==b,Zn=(M,b)=>M.length===b,MA=M=>In.test(M),bA=M=>$n.test(M),zA=M=>Hn.test(M),pA=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),oA=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},cA=p.createContext({});cA.displayName="ITDFormContext";const OA=p.forwardRef((({name:M="",label:z="",placeholder:o="",error:c="",rules:O=[],mask:e=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(cA),[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(O),()=>{B(!1),u(M)})),[]),p.useEffect((()=>{const b=JSON.stringify(O);if(N&&s.current&&l.current!==b){const z=()=>{const b=s.current.getValue(),z=x(b,!1);f(M)&&h(M,b,!1,z)};"development"===process.env.NODE_ENV?requestAnimationFrame(z):z(),l.current=b}}),[O,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)&&!oA(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(q.TYPE)&&(M.type===exports.FormValidationTypes.MIN_LENGTH&&(Yn(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.MAX_LENGTH&&(Kn(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.EXACT_LENGTH&&(Zn(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===exports.FormValidationTypes.SAME&&(Qn(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&&(Jn(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&&(pA(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===exports.FormValidationTypes.PASSWORD&&(Un(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===exports.FormValidationTypes.EMAIL&&(Vn(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===exports.FormValidationTypes.USERNAME&&(Gn(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===exports.FormValidationTypes.SITE_USERNAME&&(MA(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===exports.FormValidationTypes.ADMIN_USERNAME&&(bA(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===exports.FormValidationTypes.URL&&(zA(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(O,b,L,d);return p.length>0?!!(z||""!==b&&null!=b)&&(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 e&&(c.mask=e),t&&(c.locked=t),p.cloneElement(r,{...b,...c})})()})),eA=p.forwardRef((({name:M="",className:b="",initialValues:o={},useQueryString:c=!1,onUpdate:O,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(cA),h=S(),{search:R}=e.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&&j(d)}),[d]),p.useEffect((()=>{a&&s()!==N&&a(s()),B(s())}),[s()]);const _=()=>{X&&c&&(P(),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)}},j=M=>{let b=[],z=[];const p=W();Object.keys(M).forEach((b=>{z.push(M[b])})),rc(z,m)||(Object.keys(p).forEach((z=>{b.push({type:p[z].query,value:M[z]})})),L.set(b))},P=()=>{let M=[],b=[];const z=W();if(Object.keys(z).forEach((b=>{let p=String(h.get(z[b].query,""));M.push(p)})),rc(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]})),O&&O(p)},F=()=>{let M=[];A.getChildrenDeep(r,(b=>(b.hasOwnProperty("type")&&b.type===OA&&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 tA=p.memo(eA);function nA({name:M="",useQueryString:b=!1,onUpdate:z,onReset:o,onFieldUpdate:c}){const[O,e]=p.useState({}),[t,n]=p.useState(M),[A,a]=p.useState(!1),[r,i]=p.useState({});function d(M){return O.hasOwnProperty(M)&&void 0!==O[M]}function q(){let M={};return Object.keys(O).forEach((b=>{M[b]=W(b)})),M}function s(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 l(){let M=!0;return Object.keys(O).forEach((b=>{O[b].valid||(M=!1)})),a(M),M}function W(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 u(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=W(M),c=!1;c=Array.isArray(o)&&Array.isArray(b)?rc(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],l()):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=O[M].value)instanceof Object?JSON.stringify(b):b:"";var b},getFieldValueByName:W,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=>{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)?(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:u,setFieldError:s,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,o,e){if(d(M)){if(O[M].value=p,O[M].valid=e,o){c&&c({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 o={...q(),[M]:p};O[M].reset.length>0&&O[M].reset.forEach((M=>{o[M]=""})),b&&e&&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=>{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)})),o&&o()},removeFields:function(){e({})},formId:t,updated:r}}const AA=p.forwardRef((({initialValues:M,children:b,onUpdate:o,onReset:c,onFinish:O,onFinishFailed:e,onFieldUpdate:t,onValidated:n,useQueryString:A,className:a,name:r},i)=>{const d=p.useRef(null);p.useEffect((()=>()=>{d.current=null}),[]),d.current=nA({name:r,onUpdate:o,onReset:c,onFieldUpdate:t,useQueryString:A}),p.useImperativeHandle(i,(()=>d.current));return z.jsx(cA.Provider,{value:d.current,children:z.jsx(tA,{initialValues:M,useQueryString:A,onUpdate:o,onFinish:O,onFinishFailed:e,onValidated:n,name:r,className:(()=>{let M="itd-form";return r&&(M+=" "+r),a&&(M+=" "+a),M})(),children:b})})}));AA.Item=OA,AA.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(Cn,{className:c(),$gap:M,$horizontal:b,children:o})},AA.Control=function({position:M="end",className:b,children:p}){const o=()=>{let M="itd-form-control";return b&&(M+=" "+b),M};return z.jsx(Dn,{className:o(),$position:M,children:p})},AA.useForm=()=>p.useContext(cA),AA.useFormAPI=()=>{const M=p.useContext(cA);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const aA=n.div`
2403
2403
 
2404
2404
  &.itd-accordion-menu-sub-menu {
2405
2405
 
@@ -5302,10 +5302,6 @@ function(b,z){M.exports?M.exports=z(Eo()):z(b.moment)}(Fo,(function(M){void 0===
5302
5302
 
5303
5303
  display : flex;
5304
5304
 
5305
- >div {
5306
- width: 100%;
5307
- }
5308
-
5309
5305
  ${M=>{if(M.$stretch&&!0===M.$stretch)return M.$vertical&&!0===M.$vertical?n.css`
5310
5306
  height : 100%;
5311
5307
  `:n.css`
package/dist/index.esm.js CHANGED
@@ -2399,7 +2399,7 @@ function(b,z){M.exports?M.exports=z(SO()):z(b.moment)}(FO,(function(M){void 0===
2399
2399
  margin-top: 10px;
2400
2400
  gap: 5px;
2401
2401
 
2402
- `;const KA=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),JA=new RegExp(/^[a-zA-Z0-9_.-]+$/),QA=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),ZA=new RegExp(/^[a-z0-9._-]+$/),Ma=new RegExp(/^[a-zA-Z0-9]+$/),ba=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const za=M=>QA.test(M),pa=M=>KA.test(M),oa=M=>JA.test(M),Oa=(M,b)=>M.length>=b,ca=(M,b)=>M.length<=b,ea=(M,b)=>M===b,ta=(M,b)=>M!==b,na=(M,b)=>M.length===b,Aa=M=>ZA.test(M),aa=M=>Ma.test(M),ia=M=>ba.test(M),ra=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),da=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},qa=q({});qa.displayName="ITDFormContext";const sa=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(qa),[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=()=>{const b=f.current.getValue(),z=T(b);m(M)&&g(M,b,!1,z)};"development"===process.env.NODE_ENV?requestAnimationFrame(z):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)&&!da(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(I.TYPE)&&(M.type===$.MIN_LENGTH&&(Oa(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===$.MAX_LENGTH&&(ca(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===$.EXACT_LENGTH&&(na(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===$.SAME&&(ea(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeTheSame",{fields:M.field}))),M.type===$.NOT_SAME&&(ta(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeDifferent",{fields:M.field}))),M.type===$.TC_IDENTITY&&(ra(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===$.PASSWORD&&(za(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===$.EMAIL&&(pa(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===$.USERNAME&&(oa(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===$.SITE_USERNAME&&(Aa(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===$.ADMIN_USERNAME&&(aa(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===$.URL&&(ia(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})})()})),la=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(qa),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])})),Rc(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)})),Rc(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===sa&&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 Wa=R(la);function ua({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)?Rc(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],W()):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 fa=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=ua({name:r,onUpdate:z,onReset:o,onFieldUpdate:e,useQueryString:a}),u(d,(()=>q.current));return p(qa.Provider,{value:q.current,children:p(Wa,{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})})}));fa.Item=sa,fa.Group=function({gap:M=15,horizontal:b=!1,className:z,children:o}){return p(YA,{className:(()=>{let M="itd-form-group";return z&&(M+=" "+z),M})(),$gap:M,$horizontal:b,children:o})},fa.Control=function({position:M="end",className:b,children:z}){return p(GA,{className:(()=>{let M="itd-form-control";return b&&(M+=" "+b),M})(),$position:M,children:z})},fa.useForm=()=>a(qa),fa.useFormAPI=()=>{const M=a(qa);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const ha=k.div`
2402
+ `;const KA=new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+([.])[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/),JA=new RegExp(/^[a-zA-Z0-9_.-]+$/),QA=new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+={};:<>|./?,"'\[\]\\`~\-])[a-zA-Z\d$begin:math:display$$end:math:display$\\`~!@#$%^&*()_+={};:<>|.\/?,"'-]{8,60}$/),ZA=new RegExp(/^[a-z0-9._-]+$/),Ma=new RegExp(/^[a-zA-Z0-9]+$/),ba=new RegExp(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/);const za=M=>QA.test(M),pa=M=>KA.test(M),oa=M=>JA.test(M),Oa=(M,b)=>M.length>=b,ca=(M,b)=>M.length<=b,ea=(M,b)=>M===b,ta=(M,b)=>M!==b,na=(M,b)=>M.length===b,Aa=M=>ZA.test(M),aa=M=>Ma.test(M),ia=M=>ba.test(M),ra=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),da=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},qa=q({});qa.displayName="ITDFormContext";const sa=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(qa),[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=()=>{const b=f.current.getValue(),z=T(b,!1);m(M)&&g(M,b,!1,z)};"development"===process.env.NODE_ENV?requestAnimationFrame(z):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)&&!da(b)&&M.required&&o.push(M.message?M.message:p("errors.required")),M.hasOwnProperty(I.TYPE)&&(M.type===$.MIN_LENGTH&&(Oa(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.minLength",{length:Number(M.value)}))),M.type===$.MAX_LENGTH&&(ca(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.maxLength",{length:Number(M.value)}))),M.type===$.EXACT_LENGTH&&(na(String(b),Number(M.value))||o.push(M.message?M.message:p("errors.exactLength",{length:Number(M.value)}))),M.type===$.SAME&&(ea(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeTheSame",{fields:M.field}))),M.type===$.NOT_SAME&&(ta(String(b),String(z(String(M.field))))||o.push(M.message?M.message:p("errors.fieldMustBeDifferent",{fields:M.field}))),M.type===$.TC_IDENTITY&&(ra(String(b))||o.push(M.message?M.message:p("errors.wrongTCIdentity"))),M.type===$.PASSWORD&&(za(String(b))||o.push(M.message?M.message:p("errors.passwordRule"))),M.type===$.EMAIL&&(pa(String(b))||o.push(M.message?M.message:p("errors.invalidEmailAddress"))),M.type===$.USERNAME&&(oa(String(b))||o.push(M.message?M.message:p("errors.usernameRule"))),M.type===$.SITE_USERNAME&&(Aa(String(b))||o.push(M.message?M.message:p("errors.siteUsernameRule"))),M.type===$.ADMIN_USERNAME&&(aa(String(b))||o.push(M.message?M.message:p("errors.adminUsernameRule"))),M.type===$.URL&&(ia(String(b))||o.push(M.message?M.message:p("errors.invalidURL"))))})),o}(O,b,B,W);return p.length>0?!!(z||""!==b&&null!=b)&&(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})})()})),la=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(qa),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])})),Rc(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)})),Rc(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===sa&&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 Wa=R(la);function ua({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)?Rc(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],W()):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 fa=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=ua({name:r,onUpdate:z,onReset:o,onFieldUpdate:e,useQueryString:a}),u(d,(()=>q.current));return p(qa.Provider,{value:q.current,children:p(Wa,{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})})}));fa.Item=sa,fa.Group=function({gap:M=15,horizontal:b=!1,className:z,children:o}){return p(YA,{className:(()=>{let M="itd-form-group";return z&&(M+=" "+z),M})(),$gap:M,$horizontal:b,children:o})},fa.Control=function({position:M="end",className:b,children:z}){return p(GA,{className:(()=>{let M="itd-form-control";return b&&(M+=" "+b),M})(),$position:M,children:z})},fa.useForm=()=>a(qa),fa.useFormAPI=()=>{const M=a(qa);if(!M)throw new Error("useFormAPI must be used within a FormContext.Provider");return M};const ha=k.div`
2403
2403
 
2404
2404
  &.itd-accordion-menu-sub-menu {
2405
2405
 
@@ -5302,10 +5302,6 @@ function(b,z){M.exports?M.exports=z(SO()):z(b.moment)}(FO,(function(M){void 0===
5302
5302
 
5303
5303
  display : flex;
5304
5304
 
5305
- >div {
5306
- width: 100%;
5307
- }
5308
-
5309
5305
  ${M=>{if(M.$stretch&&!0===M.$stretch)return M.$vertical&&!0===M.$vertical?E`
5310
5306
  height : 100%;
5311
5307
  `:E`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inntechcorp/it-design",
3
- "version": "2.2.20",
3
+ "version": "2.2.22",
4
4
  "description": "All in one Design library for web applications.",
5
5
  "author": "Inn.Tech",
6
6
  "license": "ISC",