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.js CHANGED
@@ -4012,6 +4012,11 @@ const styles$5 = reactNative.StyleSheet.create({
4012
4012
  resendOTPStyle: {
4013
4013
  alignSelf: "flex-end",
4014
4014
  marginTop: verticalScale(8)
4015
+ },
4016
+ timerContainer: {
4017
+ flexDirection: "row",
4018
+ justifyContent: "space-between",
4019
+ marginTop: verticalScale(8)
4015
4020
  }
4016
4021
  });
4017
4022
 
@@ -4047,6 +4052,18 @@ const OTPInput = React__default["default"].forwardRef(
4047
4052
  {}
4048
4053
  );
4049
4054
  const { theme: theme$1 } = mode ? { theme: filteredTheme } : useTheme();
4055
+ const [timeLeft, setTimeLeft] = React.useState(60);
4056
+ React.useEffect(() => {
4057
+ let timer;
4058
+ if (!isResendOtpEnable && timeLeft > 0) {
4059
+ timer = setInterval(() => {
4060
+ setTimeLeft((prevTime) => prevTime - 1);
4061
+ }, 1e3);
4062
+ } else if (timeLeft === 0) {
4063
+ clearInterval(timer);
4064
+ }
4065
+ return () => clearInterval(timer);
4066
+ }, [timeLeft, isResendOtpEnable]);
4050
4067
  const refs = React.useRef([]);
4051
4068
  refs.current = Array(length).fill(0).map((_, index) => refs.current[index] || null);
4052
4069
  React.useEffect(() => {
@@ -4054,7 +4071,9 @@ const OTPInput = React__default["default"].forwardRef(
4054
4071
  }, []);
4055
4072
  const onClickResendOTP = () => {
4056
4073
  if (resendOTPCount > maxResendCount - 1) {
4057
- setErrorMessageMaxReachCount("You have exceeded the maximum number of attempts.");
4074
+ setErrorMessageMaxReachCount(
4075
+ "You have exceeded the maximum number of attempts."
4076
+ );
4058
4077
  }
4059
4078
  if (resendOTPCount < maxResendCount) {
4060
4079
  setIsResendOtpEnable(false);
@@ -4074,6 +4093,7 @@ const OTPInput = React__default["default"].forwardRef(
4074
4093
  const enableResendOtp = () => {
4075
4094
  setTimeout(() => {
4076
4095
  setIsResendOtpEnable(true);
4096
+ setTimeLeft(timerToResend / 1e3);
4077
4097
  }, timerToResend);
4078
4098
  };
4079
4099
  React.useEffect(() => {
@@ -4172,7 +4192,16 @@ const OTPInput = React__default["default"].forwardRef(
4172
4192
  autoComplete: "sms-otp",
4173
4193
  selectionColor: theme$1.CONTENT_PRIMARY
4174
4194
  }
4175
- ))), !errorMessageMaxReachCount && /* @__PURE__ */ React__default["default"].createElement(
4195
+ ))), !errorMessageMaxReachCount && /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.timerContainer }, /* @__PURE__ */ React__default["default"].createElement(
4196
+ CustomTypography,
4197
+ {
4198
+ text: `${timeLeft} sec`,
4199
+ variant: FontStyle.L2_REGULAR,
4200
+ style: {
4201
+ ...resendTextStyle
4202
+ }
4203
+ }
4204
+ ), /* @__PURE__ */ React__default["default"].createElement(
4176
4205
  reactNative.Pressable,
4177
4206
  {
4178
4207
  onPress: onClickResendOTP,
@@ -4191,7 +4220,7 @@ const OTPInput = React__default["default"].forwardRef(
4191
4220
  }
4192
4221
  }
4193
4222
  )
4194
- ), errorMessage ? /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React__default["default"].createElement(
4223
+ )), errorMessage ? /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React__default["default"].createElement(
4195
4224
  CustomTypography,
4196
4225
  {
4197
4226
  text: errorMessage,