@inntechcorp/it-design 2.2.11 → 2.2.13
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 +55 -22
- package/dist/index.esm.js +55 -22
- package/dist/stories/Switch.d.ts +2 -0
- package/dist/stories/Switch.stories.d.ts +23 -0
- package/dist/utils/GetSizeBySizeSlug.d.ts +1 -1
- package/package.json +1 -1
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);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)),requestAnimationFrame((()=>{l()})),c},setInvalidField:function(M="",b=""){s(M,b),requestAnimationFrame((()=>{l()}))},setInvalidFields:function(M=[],b=""){M.forEach((M=>{s(M,b)})),requestAnimationFrame((()=>{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)}requestAnimationFrame((()=>{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);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}}),[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],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=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
|
|
|
@@ -3651,22 +3651,20 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
|
|
|
3651
3651
|
position: absolute;
|
|
3652
3652
|
top: 3px;
|
|
3653
3653
|
left: 3px;
|
|
3654
|
-
width:
|
|
3655
|
-
height:
|
|
3654
|
+
width: 14px;
|
|
3655
|
+
height: 14px;
|
|
3656
3656
|
background: #fff;
|
|
3657
3657
|
border-radius: 50px;
|
|
3658
3658
|
transition: 0.3s;
|
|
3659
3659
|
|
|
3660
3660
|
.itd-spin-spinner {
|
|
3661
3661
|
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
width: 12px!important;
|
|
3665
|
-
height: 12px!important;
|
|
3662
|
+
width: 12px;
|
|
3663
|
+
height: 12px;
|
|
3666
3664
|
|
|
3667
3665
|
>div>div {
|
|
3668
3666
|
border-color: #071437 transparent transparent;
|
|
3669
|
-
border-width:
|
|
3667
|
+
border-width: 2px;
|
|
3670
3668
|
}
|
|
3671
3669
|
|
|
3672
3670
|
}
|
|
@@ -3675,18 +3673,19 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
|
|
|
3675
3673
|
|
|
3676
3674
|
cursor: pointer;
|
|
3677
3675
|
text-indent: -9999px;
|
|
3678
|
-
|
|
3679
|
-
|
|
3676
|
+
height: 20px;
|
|
3677
|
+
width: 34px;
|
|
3680
3678
|
background: #1D2649;
|
|
3681
3679
|
display: block;
|
|
3682
3680
|
border-radius: 28px;
|
|
3683
3681
|
position: relative;
|
|
3684
|
-
box-shadow: inset 0px 0px 20px rgba(0,0,0,0.4);
|
|
3682
|
+
//box-shadow: inset 0px 0px 20px rgba(0,0,0,0.4);
|
|
3685
3683
|
|
|
3686
3684
|
`,Va=n.div`
|
|
3687
3685
|
|
|
3688
3686
|
display: flex;
|
|
3689
|
-
flex-direction:
|
|
3687
|
+
flex-direction: row;
|
|
3688
|
+
align-items: center;
|
|
3690
3689
|
position: relative;
|
|
3691
3690
|
|
|
3692
3691
|
button {
|
|
@@ -3699,7 +3698,48 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
|
|
|
3699
3698
|
${Ha} {
|
|
3700
3699
|
left: calc(100% - 3px);
|
|
3701
3700
|
transform: translateX(-100%);
|
|
3702
|
-
background:
|
|
3701
|
+
background:rgb(255, 255, 255);
|
|
3702
|
+
}
|
|
3703
|
+
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
&[data-state="unchecked"] {
|
|
3707
|
+
|
|
3708
|
+
${Ha} {
|
|
3709
|
+
.itd-spin-spinner >div>div {
|
|
3710
|
+
border-color: #e4e4e7 transparent transparent;
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
.itd-switch-body {
|
|
3715
|
+
background: #e4e4e7;
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
}
|
|
3719
|
+
|
|
3720
|
+
// Disabled durumları - daha spesifik selector'lar
|
|
3721
|
+
&[data-disabled="true"][data-state="checked"] {
|
|
3722
|
+
|
|
3723
|
+
${Ha} {
|
|
3724
|
+
background: #ffffff;
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3727
|
+
.itd-switch-body {
|
|
3728
|
+
background-color: #18181b7f;
|
|
3729
|
+
cursor: not-allowed;
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
&[data-disabled="true"][data-state="unchecked"] {
|
|
3735
|
+
|
|
3736
|
+
${Ha} {
|
|
3737
|
+
background: #ffffff;
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
.itd-switch-body {
|
|
3741
|
+
background-color: #18181b7f;
|
|
3742
|
+
cursor: not-allowed;
|
|
3703
3743
|
}
|
|
3704
3744
|
|
|
3705
3745
|
}
|
|
@@ -3708,7 +3748,7 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
|
|
|
3708
3748
|
|
|
3709
3749
|
label {
|
|
3710
3750
|
font-size: 14px;
|
|
3711
|
-
font-weight:
|
|
3751
|
+
font-weight: 500;
|
|
3712
3752
|
margin-left: 5px;
|
|
3713
3753
|
}
|
|
3714
3754
|
|
|
@@ -3716,13 +3756,6 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
|
|
|
3716
3756
|
cursor: progress;
|
|
3717
3757
|
}
|
|
3718
3758
|
|
|
3719
|
-
&.itd-switch-disabled .itd-switch-body {
|
|
3720
|
-
|
|
3721
|
-
cursor: not-allowed;
|
|
3722
|
-
background-color: #18181b7f;
|
|
3723
|
-
|
|
3724
|
-
}
|
|
3725
|
-
|
|
3726
3759
|
`,Ga=n.span`
|
|
3727
3760
|
|
|
3728
3761
|
position: absolute;
|
|
@@ -3759,7 +3792,7 @@ function(b,z){M.exports?M.exports=z(Fo()):z(b.moment)}(Vo,(function(M){void 0===
|
|
|
3759
3792
|
|
|
3760
3793
|
}
|
|
3761
3794
|
|
|
3762
|
-
`,Ya=p.forwardRef((({id:M="",label:b="",checked:o
|
|
3795
|
+
`,Ya=p.forwardRef((({id:M="",label:b="",checked:o,defaultChecked:c=!1,loading:e=!1,disabled:O=!1,onChange:t=null,onUpdate:n=null},A)=>{const[a,r]=p.useState(c||!1),[i,d]=p.useState(""),[q,s]=p.useState(M||`itd-switch-${nM()}`);p.useEffect((()=>{M&&M!==q&&s(M)}),[M]);const l=p.useCallback(((M,b=!0,z=!0)=>{n&&("development"===process.env.NODE_ENV?requestAnimationFrame((()=>n(M,b,z))):n(M,b,z))}),[n]);p.useEffect((()=>{void 0!==o&&o!==a&&(r(o),l(o))}),[o,l]);const W=p.useMemo((()=>({reset(M=!0,b=!0){const z=c||!1;r(z),l(z,M,b)},setValue(M,b=!0,z=!0){r(M),l(M,b,z)},getValue:()=>a,setError(M=""){d(M)},clear(){r(!1)}})),[a,c,l]);p.useImperativeHandle(A,(()=>W),[W]);const u=p.useCallback((M=>{if(e||O)return M.preventDefault(),void M.stopPropagation();const b=!a;r(b),l(b),t&&t(b)}),[e,O,a,l,t]),f=p.useMemo((()=>{let M="itd-switch";return a&&(M+=" itd-switch-checked"),O&&(M+=" itd-switch-disabled"),e&&(M+=" itd-switch-loading"),M}),[a,O,e]);return z.jsxs(Va,{className:f,children:[z.jsx("button",{id:q,type:"button",role:"switch",value:a?"on":"off","data-state":a?"checked":"unchecked","aria-checked":a,"data-disabled":O?"true":"false","data-loading":e&&!O?"true":"false",disabled:O,onClick:u,children:z.jsx(Ua,{className:"itd-switch-body","data-disabled":O,children:z.jsx(Ha,{className:"itd-switch-thumb",children:z.jsx(I,{size:12,updating:e&&!O})})})}),b&&z.jsx("label",{htmlFor:q,children:b}),i&&z.jsx(Ga,{className:"itd-switch-error-tooltip itd-error-tooltip",children:i})]})}));Ya.displayName="ITD-Switch";const Ka=n.div`
|
|
3763
3796
|
|
|
3764
3797
|
position : relative;
|
|
3765
3798
|
width : ${M=>M.$fluid?"100%":"max-content"};
|
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);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)),requestAnimationFrame((()=>{W()})),O},setInvalidField:function(M="",b=""){l(M,b),requestAnimationFrame((()=>{W()}))},setInvalidFields:function(M=[],b=""){M.forEach((M=>{l(M,b)})),requestAnimationFrame((()=>{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)}requestAnimationFrame((()=>{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);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)&&!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],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 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
|
|
|
@@ -3651,22 +3651,20 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
|
|
|
3651
3651
|
position: absolute;
|
|
3652
3652
|
top: 3px;
|
|
3653
3653
|
left: 3px;
|
|
3654
|
-
width:
|
|
3655
|
-
height:
|
|
3654
|
+
width: 14px;
|
|
3655
|
+
height: 14px;
|
|
3656
3656
|
background: #fff;
|
|
3657
3657
|
border-radius: 50px;
|
|
3658
3658
|
transition: 0.3s;
|
|
3659
3659
|
|
|
3660
3660
|
.itd-spin-spinner {
|
|
3661
3661
|
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
width: 12px!important;
|
|
3665
|
-
height: 12px!important;
|
|
3662
|
+
width: 12px;
|
|
3663
|
+
height: 12px;
|
|
3666
3664
|
|
|
3667
3665
|
>div>div {
|
|
3668
3666
|
border-color: #071437 transparent transparent;
|
|
3669
|
-
border-width:
|
|
3667
|
+
border-width: 2px;
|
|
3670
3668
|
}
|
|
3671
3669
|
|
|
3672
3670
|
}
|
|
@@ -3675,18 +3673,19 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
|
|
|
3675
3673
|
|
|
3676
3674
|
cursor: pointer;
|
|
3677
3675
|
text-indent: -9999px;
|
|
3678
|
-
|
|
3679
|
-
|
|
3676
|
+
height: 20px;
|
|
3677
|
+
width: 34px;
|
|
3680
3678
|
background: #1D2649;
|
|
3681
3679
|
display: block;
|
|
3682
3680
|
border-radius: 28px;
|
|
3683
3681
|
position: relative;
|
|
3684
|
-
box-shadow: inset 0px 0px 20px rgba(0,0,0,0.4);
|
|
3682
|
+
//box-shadow: inset 0px 0px 20px rgba(0,0,0,0.4);
|
|
3685
3683
|
|
|
3686
3684
|
`,pr=k.div`
|
|
3687
3685
|
|
|
3688
3686
|
display: flex;
|
|
3689
|
-
flex-direction:
|
|
3687
|
+
flex-direction: row;
|
|
3688
|
+
align-items: center;
|
|
3690
3689
|
position: relative;
|
|
3691
3690
|
|
|
3692
3691
|
button {
|
|
@@ -3699,7 +3698,48 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
|
|
|
3699
3698
|
${br} {
|
|
3700
3699
|
left: calc(100% - 3px);
|
|
3701
3700
|
transform: translateX(-100%);
|
|
3702
|
-
background:
|
|
3701
|
+
background:rgb(255, 255, 255);
|
|
3702
|
+
}
|
|
3703
|
+
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
&[data-state="unchecked"] {
|
|
3707
|
+
|
|
3708
|
+
${br} {
|
|
3709
|
+
.itd-spin-spinner >div>div {
|
|
3710
|
+
border-color: #e4e4e7 transparent transparent;
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
.itd-switch-body {
|
|
3715
|
+
background: #e4e4e7;
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
}
|
|
3719
|
+
|
|
3720
|
+
// Disabled durumları - daha spesifik selector'lar
|
|
3721
|
+
&[data-disabled="true"][data-state="checked"] {
|
|
3722
|
+
|
|
3723
|
+
${br} {
|
|
3724
|
+
background: #ffffff;
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3727
|
+
.itd-switch-body {
|
|
3728
|
+
background-color: #18181b7f;
|
|
3729
|
+
cursor: not-allowed;
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
&[data-disabled="true"][data-state="unchecked"] {
|
|
3735
|
+
|
|
3736
|
+
${br} {
|
|
3737
|
+
background: #ffffff;
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
.itd-switch-body {
|
|
3741
|
+
background-color: #18181b7f;
|
|
3742
|
+
cursor: not-allowed;
|
|
3703
3743
|
}
|
|
3704
3744
|
|
|
3705
3745
|
}
|
|
@@ -3708,7 +3748,7 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
|
|
|
3708
3748
|
|
|
3709
3749
|
label {
|
|
3710
3750
|
font-size: 14px;
|
|
3711
|
-
font-weight:
|
|
3751
|
+
font-weight: 500;
|
|
3712
3752
|
margin-left: 5px;
|
|
3713
3753
|
}
|
|
3714
3754
|
|
|
@@ -3716,13 +3756,6 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
|
|
|
3716
3756
|
cursor: progress;
|
|
3717
3757
|
}
|
|
3718
3758
|
|
|
3719
|
-
&.itd-switch-disabled .itd-switch-body {
|
|
3720
|
-
|
|
3721
|
-
cursor: not-allowed;
|
|
3722
|
-
background-color: #18181b7f;
|
|
3723
|
-
|
|
3724
|
-
}
|
|
3725
|
-
|
|
3726
3759
|
`,or=k.span`
|
|
3727
3760
|
|
|
3728
3761
|
position: absolute;
|
|
@@ -3759,7 +3792,7 @@ function(b,z){M.exports?M.exports=z(FO()):z(b.moment)}(jO,(function(M){void 0===
|
|
|
3759
3792
|
|
|
3760
3793
|
}
|
|
3761
3794
|
|
|
3762
|
-
`,Or=W((({id:M="",label:b="",checked:z
|
|
3795
|
+
`,Or=W((({id:M="",label:b="",checked:z,defaultChecked:o=!1,loading:c=!1,disabled:e=!1,onChange:A=null,onUpdate:a=null},r)=>{const[d,q]=t(o||!1),[l,W]=t(""),[f,h]=t(M||`itd-switch-${HM()}`);n((()=>{M&&M!==f&&h(M)}),[M]);const R=s(((M,b=!0,z=!0)=>{a&&("development"===process.env.NODE_ENV?requestAnimationFrame((()=>a(M,b,z))):a(M,b,z))}),[a]);n((()=>{void 0!==z&&z!==d&&(q(z),R(z))}),[z,R]);const L=i((()=>({reset(M=!0,b=!0){const z=o||!1;q(z),R(z,M,b)},setValue(M,b=!0,z=!0){q(M),R(M,b,z)},getValue:()=>d,setError(M=""){W(M)},clear(){q(!1)}})),[d,o,R]);u(r,(()=>L),[L]);const m=s((M=>{if(c||e)return M.preventDefault(),void M.stopPropagation();const b=!d;q(b),R(b),A&&A(b)}),[c,e,d,R,A]),g=i((()=>{let M="itd-switch";return d&&(M+=" itd-switch-checked"),e&&(M+=" itd-switch-disabled"),c&&(M+=" itd-switch-loading"),M}),[d,e,c]);return O(pr,{className:g,children:[p("button",{id:f,type:"button",role:"switch",value:d?"on":"off","data-state":d?"checked":"unchecked","aria-checked":d,"data-disabled":e?"true":"false","data-loading":c&&!e?"true":"false",disabled:e,onClick:m,children:p(zr,{className:"itd-switch-body","data-disabled":e,children:p(br,{className:"itd-switch-thumb",children:p(mM,{size:12,updating:c&&!e})})})}),b&&p("label",{htmlFor:f,children:b}),l&&p(or,{className:"itd-switch-error-tooltip itd-error-tooltip",children:l})]})}));Or.displayName="ITD-Switch";const cr=k.div`
|
|
3763
3796
|
|
|
3764
3797
|
position : relative;
|
|
3765
3798
|
width : ${M=>M.$fluid?"100%":"max-content"};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<import("./index").SwitchProps & import("react").RefAttributes<import("./index").ITDImperativeFuncProps>>;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
tags: string[];
|
|
9
|
+
argTypes: {};
|
|
10
|
+
args: {
|
|
11
|
+
onChange: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
12
|
+
onUpdate: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
export declare const Default: Story;
|
|
18
|
+
export declare const WithoutLabel: Story;
|
|
19
|
+
export declare const DefaultChecked: Story;
|
|
20
|
+
export declare const Disabled: Story;
|
|
21
|
+
export declare const DisabledChecked: Story;
|
|
22
|
+
export declare const Loading: Story;
|
|
23
|
+
export declare const LoadingChecked: Story;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ITDSizeSlug } from "../index";
|
|
2
|
-
export default function GetSizeBySizeSlug(size: ITDSizeSlug): "
|
|
2
|
+
export default function GetSizeBySizeSlug(size: ITDSizeSlug): "small" | "medium" | "large" | "x-small" | "default" | "x-large" | "df";
|