@inntechcorp/it-design 2.2.22 → 2.2.24

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.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,!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`
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=O.find((M=>M.hasOwnProperty("required")));if(!z||z.required||""!==b&&null!=b){const z=T(b,!1);m(M)&&g(M,b,!1,z)}else N(M,"",!0),m(M)&&g(M,b,!1,!0)};"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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inntechcorp/it-design",
3
- "version": "2.2.22",
3
+ "version": "2.2.24",
4
4
  "description": "All in one Design library for web applications.",
5
5
  "author": "Inn.Tech",
6
6
  "license": "ISC",