dhre-ui-kit 0.0.243 → 0.0.245

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/lib/index.mjs CHANGED
@@ -3976,6 +3976,11 @@ const styles$5 = StyleSheet.create({
3976
3976
  resendOTPStyle: {
3977
3977
  alignSelf: "flex-end",
3978
3978
  marginTop: verticalScale(8)
3979
+ },
3980
+ timerContainer: {
3981
+ flexDirection: "row",
3982
+ justifyContent: "space-between",
3983
+ marginTop: verticalScale(8)
3979
3984
  }
3980
3985
  });
3981
3986
 
@@ -4011,6 +4016,18 @@ const OTPInput = React.forwardRef(
4011
4016
  {}
4012
4017
  );
4013
4018
  const { theme: theme$1 } = mode ? { theme: filteredTheme } : useTheme();
4019
+ const [timeLeft, setTimeLeft] = useState(60);
4020
+ useEffect(() => {
4021
+ let timer;
4022
+ if (!isResendOtpEnable && timeLeft > 0) {
4023
+ timer = setInterval(() => {
4024
+ setTimeLeft((prevTime) => prevTime - 1);
4025
+ }, 1e3);
4026
+ } else if (timeLeft === 0) {
4027
+ clearInterval(timer);
4028
+ }
4029
+ return () => clearInterval(timer);
4030
+ }, [timeLeft, isResendOtpEnable]);
4014
4031
  const refs = useRef([]);
4015
4032
  refs.current = Array(length).fill(0).map((_, index) => refs.current[index] || null);
4016
4033
  useEffect(() => {
@@ -4018,7 +4035,9 @@ const OTPInput = React.forwardRef(
4018
4035
  }, []);
4019
4036
  const onClickResendOTP = () => {
4020
4037
  if (resendOTPCount > maxResendCount - 1) {
4021
- setErrorMessageMaxReachCount("You have exceeded the maximum number of attempts.");
4038
+ setErrorMessageMaxReachCount(
4039
+ "You have exceeded the maximum number of attempts."
4040
+ );
4022
4041
  }
4023
4042
  if (resendOTPCount < maxResendCount) {
4024
4043
  setIsResendOtpEnable(false);
@@ -4038,6 +4057,7 @@ const OTPInput = React.forwardRef(
4038
4057
  const enableResendOtp = () => {
4039
4058
  setTimeout(() => {
4040
4059
  setIsResendOtpEnable(true);
4060
+ setTimeLeft(timerToResend / 1e3);
4041
4061
  }, timerToResend);
4042
4062
  };
4043
4063
  useEffect(() => {
@@ -4136,7 +4156,16 @@ const OTPInput = React.forwardRef(
4136
4156
  autoComplete: "sms-otp",
4137
4157
  selectionColor: theme$1.CONTENT_PRIMARY
4138
4158
  }
4139
- ))), !errorMessageMaxReachCount && /* @__PURE__ */ React.createElement(
4159
+ ))), !errorMessageMaxReachCount && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerContainer }, /* @__PURE__ */ React.createElement(
4160
+ CustomTypography,
4161
+ {
4162
+ text: `${timeLeft} sec`,
4163
+ variant: FontStyle.L2_REGULAR,
4164
+ style: {
4165
+ ...resendTextStyle
4166
+ }
4167
+ }
4168
+ ), /* @__PURE__ */ React.createElement(
4140
4169
  Pressable,
4141
4170
  {
4142
4171
  onPress: onClickResendOTP,
@@ -4155,7 +4184,7 @@ const OTPInput = React.forwardRef(
4155
4184
  }
4156
4185
  }
4157
4186
  )
4158
- ), errorMessage ? /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React.createElement(
4187
+ )), errorMessage ? /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React.createElement(
4159
4188
  CustomTypography,
4160
4189
  {
4161
4190
  text: errorMessage,