dhre-ui-kit 0.0.232 → 0.0.234

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.d.ts CHANGED
@@ -711,6 +711,7 @@ interface IProps$1 {
711
711
  label?: string;
712
712
  resendText?: string;
713
713
  mode?: 'light' | 'dark';
714
+ disabled?: boolean;
714
715
  }
715
716
  type OTPInputHandle = {
716
717
  reset?: () => void;
package/lib/index.js CHANGED
@@ -4024,11 +4024,14 @@ const OTPInput = React__default["default"].forwardRef(
4024
4024
  resendOtpColor,
4025
4025
  label = "OTP",
4026
4026
  resendText = "Resend OTP",
4027
- mode
4027
+ mode,
4028
+ disabled
4028
4029
  }, ref) => {
4029
4030
  const [otp, setOTP] = React.useState("");
4030
4031
  const [isResendOtpEnable, setIsResendOtpEnable] = React.useState(false);
4031
4032
  const [activeInput, setActiveInput] = React.useState(null);
4033
+ const [resendOTPCount, setResendOTPCount] = React.useState(0);
4034
+ const [errorMessageMaxReachCount, setErrorMessageMaxReachCount] = React.useState("");
4032
4035
  const filteredTheme = Object?.keys(theme)?.reduce(
4033
4036
  (acc, key) => {
4034
4037
  acc[key] = theme[key][mode];
@@ -4043,16 +4046,32 @@ const OTPInput = React__default["default"].forwardRef(
4043
4046
  enableResendOtp();
4044
4047
  }, []);
4045
4048
  const onClickResendOTP = () => {
4046
- setIsResendOtpEnable(false);
4047
- enableResendOtp();
4048
- resendOTP?.();
4049
- setOTP("");
4049
+ if (resendOTPCount >= 3) {
4050
+ setErrorMessageMaxReachCount("You have exceeded the maximum number of attempts.");
4051
+ return;
4052
+ }
4053
+ if (resendOTPCount < 3) {
4054
+ setIsResendOtpEnable(false);
4055
+ setResendOTPCount(resendOTPCount + 1);
4056
+ enableResendOtp();
4057
+ resendOTP?.();
4058
+ setOTP("");
4059
+ }
4050
4060
  };
4051
4061
  const enableResendOtp = () => {
4052
4062
  setTimeout(() => {
4053
4063
  setIsResendOtpEnable(true);
4054
4064
  }, 5e3);
4055
4065
  };
4066
+ const disableResendButton = () => {
4067
+ if (disabled === true && resendOTPCount >= 3) {
4068
+ setIsResendOtpEnable(true);
4069
+ return true;
4070
+ } else {
4071
+ setIsResendOtpEnable(false);
4072
+ return false;
4073
+ }
4074
+ };
4056
4075
  React.useEffect(() => {
4057
4076
  if (reactNative.Platform.OS === "android") {
4058
4077
  onStartListeningOtp();
@@ -4132,7 +4151,7 @@ const OTPInput = React__default["default"].forwardRef(
4132
4151
  style: {
4133
4152
  ...styles$5.textInputStyle,
4134
4153
  color: theme$1.CONTENT_PRIMARY,
4135
- borderColor: errorMessage ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
4154
+ borderColor: errorMessage || errorMessageMaxReachCount ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
4136
4155
  ...textInputStyle
4137
4156
  },
4138
4157
  onFocus: () => setActiveInput(index),
@@ -4154,7 +4173,7 @@ const OTPInput = React__default["default"].forwardRef(
4154
4173
  {
4155
4174
  onPress: onClickResendOTP,
4156
4175
  style: styles$5.resendOTPStyle,
4157
- disabled: !isResendOtpEnable
4176
+ disabled: disableResendButton() || !isResendOtpEnable
4158
4177
  },
4159
4178
  /* @__PURE__ */ React__default["default"].createElement(
4160
4179
  CustomTypography,
@@ -4168,7 +4187,7 @@ const OTPInput = React__default["default"].forwardRef(
4168
4187
  }
4169
4188
  }
4170
4189
  )
4171
- ), /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, errorMessage ? /* @__PURE__ */ React__default["default"].createElement(
4190
+ ), errorMessage ? /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React__default["default"].createElement(
4172
4191
  CustomTypography,
4173
4192
  {
4174
4193
  text: errorMessage,
@@ -4178,7 +4197,17 @@ const OTPInput = React__default["default"].forwardRef(
4178
4197
  color: theme$1.ERROR
4179
4198
  }
4180
4199
  }
4181
- ) : /* @__PURE__ */ React__default["default"].createElement(reactNative.View, null)));
4200
+ )) : null, errorMessageMaxReachCount ? /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React__default["default"].createElement(
4201
+ CustomTypography,
4202
+ {
4203
+ text: errorMessageMaxReachCount,
4204
+ variant: FontStyle.L2_REGULAR,
4205
+ style: {
4206
+ alignSelf: "flex-start",
4207
+ color: theme$1.ERROR
4208
+ }
4209
+ }
4210
+ )) : null);
4182
4211
  }
4183
4212
  );
4184
4213
  var index$4 = withThemeProvider(OTPInput);