dhre-ui-kit 0.0.244 → 0.0.246

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
@@ -612,7 +612,6 @@ interface CommonTextInputProps extends TextInputProps$1 {
612
612
  handlePress?: () => void;
613
613
  rightIcon?: () => React$1.ReactElement;
614
614
  onRightIconPress?: () => void;
615
- onlyErrorBorderLabel?: boolean;
616
615
  }
617
616
  declare const CommonTextInput: (props: CommonTextInputProps) => React$1.JSX.Element;
618
617
 
@@ -716,6 +715,7 @@ interface IProps$1 {
716
715
  disabled?: boolean;
717
716
  maxResendCount?: number;
718
717
  timerToResend?: number;
718
+ timerIcon?: React.ReactElement;
719
719
  }
720
720
  type OTPInputHandle = {
721
721
  reset?: () => void;
package/lib/index.js CHANGED
@@ -3439,8 +3439,7 @@ const CommonTextInput = (props) => {
3439
3439
  multiline = false,
3440
3440
  // Default multiline to false
3441
3441
  rightIcon,
3442
- onRightIconPress,
3443
- onlyErrorBorderLabel
3442
+ onRightIconPress
3444
3443
  } = props;
3445
3444
  return /* @__PURE__ */ React__default["default"].createElement(reactNative.Pressable, { onPress: handlePress, style: styles$9.container }, /* @__PURE__ */ React__default["default"].createElement(
3446
3445
  reactNativePaper.TextInput,
@@ -3452,7 +3451,7 @@ const CommonTextInput = (props) => {
3452
3451
  autoCorrect: false,
3453
3452
  outlineStyle: {
3454
3453
  ...styles$9.outlineStyle,
3455
- borderColor: errorMessage?.length || onlyErrorBorderLabel ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : value?.length ? activeBorderColor : inactiveBorderColor
3454
+ borderColor: errorMessage?.length ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : value?.length ? activeBorderColor : inactiveBorderColor
3456
3455
  },
3457
3456
  label,
3458
3457
  value,
@@ -3462,12 +3461,12 @@ const CommonTextInput = (props) => {
3462
3461
  theme: {
3463
3462
  colors: {
3464
3463
  onSurfaceVariant: value?.length ? activeBorderColor : inactiveBorderColor,
3465
- error: errorMessage?.length || onlyErrorBorderLabel ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : DHRE_COLORS_TEXT.DH_BLACK,
3464
+ error: errorMessage?.length ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : DHRE_COLORS_TEXT.DH_BLACK,
3466
3465
  primary: labelColor ? errorMessage?.length ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : labelColor : DHRE_COLORS_TEXT.DH_BLACK
3467
3466
  }
3468
3467
  },
3469
3468
  style: [
3470
- errorMessage || onlyErrorBorderLabel ? styles$9.errorInput : styles$9.input,
3469
+ errorMessage ? styles$9.errorInput : styles$9.input,
3471
3470
  inputStyle,
3472
3471
  multiline && styles$9.multilineInput
3473
3472
  // Apply multiline style if true
@@ -3477,7 +3476,7 @@ const CommonTextInput = (props) => {
3477
3476
  placeholder: placeholderText,
3478
3477
  editable,
3479
3478
  pointerEvents,
3480
- error: errorMessage?.length || onlyErrorBorderLabel ? true : false,
3479
+ error: errorMessage?.length ? true : false,
3481
3480
  multiline,
3482
3481
  numberOfLines: multiline ? 4 : 1,
3483
3482
  right: rightIcon ? /* @__PURE__ */ React__default["default"].createElement(
@@ -4013,7 +4012,13 @@ const styles$5 = reactNative.StyleSheet.create({
4013
4012
  resendOTPStyle: {
4014
4013
  alignSelf: "flex-end",
4015
4014
  marginTop: verticalScale(8)
4016
- }
4015
+ },
4016
+ timerContainer: {
4017
+ flexDirection: "row",
4018
+ justifyContent: "space-between",
4019
+ marginTop: verticalScale(8)
4020
+ },
4021
+ timerIconContainer: { flexDirection: "row", gap: horizontalScale(8) }
4017
4022
  });
4018
4023
 
4019
4024
  const OTPInput = React__default["default"].forwardRef(
@@ -4033,7 +4038,8 @@ const OTPInput = React__default["default"].forwardRef(
4033
4038
  mode,
4034
4039
  disabled,
4035
4040
  maxResendCount = 2,
4036
- timerToResend = 6e4
4041
+ timerToResend = 6e4,
4042
+ timerIcon
4037
4043
  }, ref) => {
4038
4044
  const [otp, setOTP] = React.useState("");
4039
4045
  const [isResendOtpEnable, setIsResendOtpEnable] = React.useState(false);
@@ -4048,6 +4054,18 @@ const OTPInput = React__default["default"].forwardRef(
4048
4054
  {}
4049
4055
  );
4050
4056
  const { theme: theme$1 } = mode ? { theme: filteredTheme } : useTheme();
4057
+ const [timeLeft, setTimeLeft] = React.useState(60);
4058
+ React.useEffect(() => {
4059
+ let timer;
4060
+ if (!isResendOtpEnable && timeLeft > 0) {
4061
+ timer = setInterval(() => {
4062
+ setTimeLeft((prevTime) => prevTime - 1);
4063
+ }, 1e3);
4064
+ } else if (timeLeft === 0) {
4065
+ clearInterval(timer);
4066
+ }
4067
+ return () => clearInterval(timer);
4068
+ }, [timeLeft, isResendOtpEnable]);
4051
4069
  const refs = React.useRef([]);
4052
4070
  refs.current = Array(length).fill(0).map((_, index) => refs.current[index] || null);
4053
4071
  React.useEffect(() => {
@@ -4055,7 +4073,9 @@ const OTPInput = React__default["default"].forwardRef(
4055
4073
  }, []);
4056
4074
  const onClickResendOTP = () => {
4057
4075
  if (resendOTPCount > maxResendCount - 1) {
4058
- setErrorMessageMaxReachCount("You have exceeded the maximum number of attempts.");
4076
+ setErrorMessageMaxReachCount(
4077
+ "You have exceeded the maximum number of attempts."
4078
+ );
4059
4079
  }
4060
4080
  if (resendOTPCount < maxResendCount) {
4061
4081
  setIsResendOtpEnable(false);
@@ -4075,6 +4095,7 @@ const OTPInput = React__default["default"].forwardRef(
4075
4095
  const enableResendOtp = () => {
4076
4096
  setTimeout(() => {
4077
4097
  setIsResendOtpEnable(true);
4098
+ setTimeLeft(timerToResend / 1e3);
4078
4099
  }, timerToResend);
4079
4100
  };
4080
4101
  React.useEffect(() => {
@@ -4173,7 +4194,14 @@ const OTPInput = React__default["default"].forwardRef(
4173
4194
  autoComplete: "sms-otp",
4174
4195
  selectionColor: theme$1.CONTENT_PRIMARY
4175
4196
  }
4176
- ))), !errorMessageMaxReachCount && /* @__PURE__ */ React__default["default"].createElement(
4197
+ ))), !errorMessageMaxReachCount && /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.timerContainer }, timeLeft !== 0 && /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$5.timerIconContainer }, timerIcon, /* @__PURE__ */ React__default["default"].createElement(
4198
+ CustomTypography,
4199
+ {
4200
+ text: `${timeLeft} sec`,
4201
+ variant: FontStyle.L2_REGULAR,
4202
+ style: { color: theme$1.CONTENT_PRIMARY }
4203
+ }
4204
+ )), /* @__PURE__ */ React__default["default"].createElement(
4177
4205
  reactNative.Pressable,
4178
4206
  {
4179
4207
  onPress: onClickResendOTP,
@@ -4192,7 +4220,7 @@ const OTPInput = React__default["default"].forwardRef(
4192
4220
  }
4193
4221
  }
4194
4222
  )
4195
- ), 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(
4196
4224
  CustomTypography,
4197
4225
  {
4198
4226
  text: errorMessage,