dhre-ui-kit 0.0.233 → 0.0.235

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
@@ -3989,7 +3989,8 @@ const OTPInput = React.forwardRef(
3989
3989
  label = "OTP",
3990
3990
  resendText = "Resend OTP",
3991
3991
  mode,
3992
- disabled
3992
+ disabled,
3993
+ maxResendCount = 4
3993
3994
  }, ref) => {
3994
3995
  const [otp, setOTP] = useState("");
3995
3996
  const [isResendOtpEnable, setIsResendOtpEnable] = useState(false);
@@ -4010,24 +4011,30 @@ const OTPInput = React.forwardRef(
4010
4011
  enableResendOtp();
4011
4012
  }, []);
4012
4013
  const onClickResendOTP = () => {
4013
- if (resendOTPCount >= 3) {
4014
+ if (resendOTPCount >= maxResendCount - 1) {
4014
4015
  setErrorMessageMaxReachCount("You have exceeded the maximum number of attempts.");
4015
4016
  return;
4016
4017
  }
4017
- if (resendOTPCount < 3) {
4018
+ if (resendOTPCount < maxResendCount) {
4019
+ setIsResendOtpEnable(false);
4018
4020
  setResendOTPCount(resendOTPCount + 1);
4019
4021
  enableResendOtp();
4020
4022
  resendOTP?.();
4021
4023
  setOTP("");
4022
4024
  }
4023
4025
  };
4024
- const enableResendOtp = () => {
4025
- if (!disabled && resendOTPCount <= 3) {
4026
- setTimeout(() => {
4027
- setIsResendOtpEnable(true);
4028
- }, 6e4);
4026
+ const disableResendButton = () => {
4027
+ if (disabled === true && resendOTPCount >= maxResendCount) {
4028
+ return true;
4029
+ } else {
4030
+ return false;
4029
4031
  }
4030
4032
  };
4033
+ const enableResendOtp = () => {
4034
+ setTimeout(() => {
4035
+ setIsResendOtpEnable(true);
4036
+ }, 6e4);
4037
+ };
4031
4038
  useEffect(() => {
4032
4039
  if (Platform.OS === "android") {
4033
4040
  onStartListeningOtp();
@@ -4107,7 +4114,7 @@ const OTPInput = React.forwardRef(
4107
4114
  style: {
4108
4115
  ...styles$5.textInputStyle,
4109
4116
  color: theme$1.CONTENT_PRIMARY,
4110
- borderColor: errorMessage || errorMessageMaxReachCount ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
4117
+ borderColor: errorMessage ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
4111
4118
  ...textInputStyle
4112
4119
  },
4113
4120
  onFocus: () => setActiveInput(index),
@@ -4124,12 +4131,12 @@ const OTPInput = React.forwardRef(
4124
4131
  autoComplete: "sms-otp",
4125
4132
  selectionColor: theme$1.CONTENT_PRIMARY
4126
4133
  }
4127
- ))), /* @__PURE__ */ React.createElement(
4134
+ ))), !errorMessageMaxReachCount && /* @__PURE__ */ React.createElement(
4128
4135
  Pressable,
4129
4136
  {
4130
4137
  onPress: onClickResendOTP,
4131
4138
  style: styles$5.resendOTPStyle,
4132
- disabled: !isResendOtpEnable || resendOTPCount >= 3
4139
+ disabled: disableResendButton() || !isResendOtpEnable
4133
4140
  },
4134
4141
  /* @__PURE__ */ React.createElement(
4135
4142
  CustomTypography,