|
|
@ -15,15 +15,14 @@ const Input = ({ |
|
|
|
bg, |
|
|
|
bg, |
|
|
|
value, |
|
|
|
value, |
|
|
|
max, |
|
|
|
max, |
|
|
|
onFocus |
|
|
|
onFocus, |
|
|
|
|
|
|
|
defaultValue, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if (value !== null && value !== "" && value !== undefined) { |
|
|
|
if(value !== null && value !== '' && value !== undefined){ |
|
|
|
blurHandler2(id ? id : 0); |
|
|
|
blurHandler2(id ? id : 0) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, [value]); |
|
|
|
}, [value]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const focusHandler = (id) => { |
|
|
|
const focusHandler = (id) => { |
|
|
|
let inputs = document.querySelectorAll(".Login-box-form-item"); |
|
|
|
let inputs = document.querySelectorAll(".Login-box-form-item"); |
|
|
@ -32,12 +31,10 @@ const Input = ({ |
|
|
|
|
|
|
|
|
|
|
|
inputs[id].style.borderColor = "#df1452"; |
|
|
|
inputs[id].style.borderColor = "#df1452"; |
|
|
|
inputs[id].style.backgroundColor = "#fff"; |
|
|
|
inputs[id].style.backgroundColor = "#fff"; |
|
|
|
inputs[id].style.color = '#404040'; |
|
|
|
inputs[id].style.color = "#404040"; |
|
|
|
label[id].style.transform = `translate(-10px,-27px)`; |
|
|
|
label[id].style.transform = `translate(-10px,-27px)`; |
|
|
|
label[id].style.color = "#df1452"; |
|
|
|
label[id].style.color = "#df1452"; |
|
|
|
line[id].style.backgroundColor = "#fff"; |
|
|
|
line[id].style.backgroundColor = "#fff"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const blurHandler = (id) => { |
|
|
|
const blurHandler = (id) => { |
|
|
@ -52,7 +49,6 @@ const Input = ({ |
|
|
|
inputs[id].style.backgroundColor = "#fff"; |
|
|
|
inputs[id].style.backgroundColor = "#fff"; |
|
|
|
line[id].style.backgroundColor = "#fff"; |
|
|
|
line[id].style.backgroundColor = "#fff"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
const blurHandler2 = (id) => { |
|
|
|
const blurHandler2 = (id) => { |
|
|
|
let inputsBox = document.querySelectorAll(".Login-box-form-item"); |
|
|
|
let inputsBox = document.querySelectorAll(".Login-box-form-item"); |
|
|
@ -66,32 +62,44 @@ const Input = ({ |
|
|
|
inputs[id].style.backgroundColor = "#fff"; |
|
|
|
inputs[id].style.backgroundColor = "#fff"; |
|
|
|
line[id].style.backgroundColor = "#fff"; |
|
|
|
line[id].style.backgroundColor = "#fff"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div style={style} className={`${className} Login-box-form-item w-full h-12 ${borderType ? borderType : 'rounded-lg'} border border-color7 mt-6 relative flex items-center flex-row-reverse`}> |
|
|
|
<div |
|
|
|
<div className={`Login-box-form-item-line w-${gapSize ? gapSize : '20'} h-px absolute top-[-1px] right-7 `}></div> |
|
|
|
style={style} |
|
|
|
|
|
|
|
className={`${className} Login-box-form-item w-full h-12 ${ |
|
|
|
|
|
|
|
borderType ? borderType : "rounded-lg" |
|
|
|
|
|
|
|
} border border-color7 mt-6 relative flex items-center flex-row-reverse`}
|
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
className={`Login-box-form-item-line w-${ |
|
|
|
|
|
|
|
gapSize ? gapSize : "20" |
|
|
|
|
|
|
|
} h-px absolute top-[-1px] right-7 `}
|
|
|
|
|
|
|
|
></div> |
|
|
|
<div className="Login-box-form-item-label text-sm text-color19 bg-white absolute right-6 transition-all duration-300 pointer-events-none"> |
|
|
|
<div className="Login-box-form-item-label text-sm text-color19 bg-white absolute right-6 transition-all duration-300 pointer-events-none"> |
|
|
|
{title ? title : 'نام کاربری'} |
|
|
|
{title ? title : "نام کاربری"} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<input |
|
|
|
<input |
|
|
|
type={type ? type : 'text'} |
|
|
|
type={type ? type : "text"} |
|
|
|
|
|
|
|
|
|
|
|
name="Login-box-form-item-input-name" |
|
|
|
name="Login-box-form-item-input-name" |
|
|
|
id={`Login-box-form-item-input-name${id}`} |
|
|
|
id={`Login-box-form-item-input-name${id}`} |
|
|
|
className={`Login-box-form-item-input w-full h-full px-4 outline-0 rounded-lg text-gray-700 `} |
|
|
|
className={`Login-box-form-item-input w-full h-full px-4 outline-0 rounded-lg text-gray-700 `} |
|
|
|
style={{ direction: direction ? direction : "ltr", backgroundColor: bg }} |
|
|
|
style={{ |
|
|
|
onFocus={() => {if(onFocus){onFocus();} focusHandler(id ? id : 0)}} |
|
|
|
pointerEvents : defaultValue ? "none" : 'auto',
|
|
|
|
|
|
|
|
direction: direction ? direction : "ltr", |
|
|
|
|
|
|
|
backgroundColor: bg, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
onFocus={() => { |
|
|
|
|
|
|
|
if (onFocus) { |
|
|
|
|
|
|
|
onFocus(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
focusHandler(id ? id : 0); |
|
|
|
|
|
|
|
}} |
|
|
|
onBlur={() => blurHandler(id ? id : 0)} |
|
|
|
onBlur={() => blurHandler(id ? id : 0)} |
|
|
|
onChange={onChange} |
|
|
|
onChange={onChange} |
|
|
|
value={value} |
|
|
|
value={value} |
|
|
|
maxLength={max} |
|
|
|
maxLength={max} |
|
|
|
|
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
}; |
|
|
|
export default Input; |
|
|
|
export default Input; |