dhre-ui-kit 0.0.232 → 0.0.233

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,15 +4046,23 @@ 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
+ setResendOTPCount(resendOTPCount + 1);
4055
+ enableResendOtp();
4056
+ resendOTP?.();
4057
+ setOTP("");
4058
+ }
4050
4059
  };
4051
4060
  const enableResendOtp = () => {
4052
- setTimeout(() => {
4053
- setIsResendOtpEnable(true);
4054
- }, 5e3);
4061
+ if (!disabled && resendOTPCount <= 3) {
4062
+ setTimeout(() => {
4063
+ setIsResendOtpEnable(true);
4064
+ }, 6e4);
4065
+ }
4055
4066
  };
4056
4067
  React.useEffect(() => {
4057
4068
  if (reactNative.Platform.OS === "android") {
@@ -4132,7 +4143,7 @@ const OTPInput = React__default["default"].forwardRef(
4132
4143
  style: {
4133
4144
  ...styles$5.textInputStyle,
4134
4145
  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,
4146
+ borderColor: errorMessage || errorMessageMaxReachCount ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
4136
4147
  ...textInputStyle
4137
4148
  },
4138
4149
  onFocus: () => setActiveInput(index),
@@ -4154,7 +4165,7 @@ const OTPInput = React__default["default"].forwardRef(
4154
4165
  {
4155
4166
  onPress: onClickResendOTP,
4156
4167
  style: styles$5.resendOTPStyle,
4157
- disabled: !isResendOtpEnable
4168
+ disabled: !isResendOtpEnable || resendOTPCount >= 3
4158
4169
  },
4159
4170
  /* @__PURE__ */ React__default["default"].createElement(
4160
4171
  CustomTypography,
@@ -4168,7 +4179,7 @@ const OTPInput = React__default["default"].forwardRef(
4168
4179
  }
4169
4180
  }
4170
4181
  )
4171
- ), /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, errorMessage ? /* @__PURE__ */ React__default["default"].createElement(
4182
+ ), errorMessage ? /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React__default["default"].createElement(
4172
4183
  CustomTypography,
4173
4184
  {
4174
4185
  text: errorMessage,
@@ -4178,7 +4189,17 @@ const OTPInput = React__default["default"].forwardRef(
4178
4189
  color: theme$1.ERROR
4179
4190
  }
4180
4191
  }
4181
- ) : /* @__PURE__ */ React__default["default"].createElement(reactNative.View, null)));
4192
+ )) : null, errorMessageMaxReachCount ? /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React__default["default"].createElement(
4193
+ CustomTypography,
4194
+ {
4195
+ text: errorMessageMaxReachCount,
4196
+ variant: FontStyle.L2_REGULAR,
4197
+ style: {
4198
+ alignSelf: "flex-start",
4199
+ color: theme$1.ERROR
4200
+ }
4201
+ }
4202
+ )) : null);
4182
4203
  }
4183
4204
  );
4184
4205
  var index$4 = withThemeProvider(OTPInput);