dhre-ui-kit 0.0.231 → 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 +1 -0
- package/lib/index.js +34 -13
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +34 -13
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -3988,11 +3988,14 @@ const OTPInput = React.forwardRef(
|
|
|
3988
3988
|
resendOtpColor,
|
|
3989
3989
|
label = "OTP",
|
|
3990
3990
|
resendText = "Resend OTP",
|
|
3991
|
-
mode
|
|
3991
|
+
mode,
|
|
3992
|
+
disabled
|
|
3992
3993
|
}, ref) => {
|
|
3993
3994
|
const [otp, setOTP] = useState("");
|
|
3994
3995
|
const [isResendOtpEnable, setIsResendOtpEnable] = useState(false);
|
|
3995
3996
|
const [activeInput, setActiveInput] = useState(null);
|
|
3997
|
+
const [resendOTPCount, setResendOTPCount] = useState(0);
|
|
3998
|
+
const [errorMessageMaxReachCount, setErrorMessageMaxReachCount] = useState("");
|
|
3996
3999
|
const filteredTheme = Object?.keys(theme)?.reduce(
|
|
3997
4000
|
(acc, key) => {
|
|
3998
4001
|
acc[key] = theme[key][mode];
|
|
@@ -4007,15 +4010,23 @@ const OTPInput = React.forwardRef(
|
|
|
4007
4010
|
enableResendOtp();
|
|
4008
4011
|
}, []);
|
|
4009
4012
|
const onClickResendOTP = () => {
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4013
|
+
if (resendOTPCount >= 3) {
|
|
4014
|
+
setErrorMessageMaxReachCount("You have exceeded the maximum number of attempts.");
|
|
4015
|
+
return;
|
|
4016
|
+
}
|
|
4017
|
+
if (resendOTPCount < 3) {
|
|
4018
|
+
setResendOTPCount(resendOTPCount + 1);
|
|
4019
|
+
enableResendOtp();
|
|
4020
|
+
resendOTP?.();
|
|
4021
|
+
setOTP("");
|
|
4022
|
+
}
|
|
4014
4023
|
};
|
|
4015
4024
|
const enableResendOtp = () => {
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4025
|
+
if (!disabled && resendOTPCount <= 3) {
|
|
4026
|
+
setTimeout(() => {
|
|
4027
|
+
setIsResendOtpEnable(true);
|
|
4028
|
+
}, 6e4);
|
|
4029
|
+
}
|
|
4019
4030
|
};
|
|
4020
4031
|
useEffect(() => {
|
|
4021
4032
|
if (Platform.OS === "android") {
|
|
@@ -4096,7 +4107,7 @@ const OTPInput = React.forwardRef(
|
|
|
4096
4107
|
style: {
|
|
4097
4108
|
...styles$5.textInputStyle,
|
|
4098
4109
|
color: theme$1.CONTENT_PRIMARY,
|
|
4099
|
-
borderColor: errorMessage ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
|
|
4110
|
+
borderColor: errorMessage || errorMessageMaxReachCount ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
|
|
4100
4111
|
...textInputStyle
|
|
4101
4112
|
},
|
|
4102
4113
|
onFocus: () => setActiveInput(index),
|
|
@@ -4118,7 +4129,7 @@ const OTPInput = React.forwardRef(
|
|
|
4118
4129
|
{
|
|
4119
4130
|
onPress: onClickResendOTP,
|
|
4120
4131
|
style: styles$5.resendOTPStyle,
|
|
4121
|
-
disabled: !isResendOtpEnable
|
|
4132
|
+
disabled: !isResendOtpEnable || resendOTPCount >= 3
|
|
4122
4133
|
},
|
|
4123
4134
|
/* @__PURE__ */ React.createElement(
|
|
4124
4135
|
CustomTypography,
|
|
@@ -4132,7 +4143,7 @@ const OTPInput = React.forwardRef(
|
|
|
4132
4143
|
}
|
|
4133
4144
|
}
|
|
4134
4145
|
)
|
|
4135
|
-
), /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer },
|
|
4146
|
+
), errorMessage ? /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React.createElement(
|
|
4136
4147
|
CustomTypography,
|
|
4137
4148
|
{
|
|
4138
4149
|
text: errorMessage,
|
|
@@ -4142,7 +4153,17 @@ const OTPInput = React.forwardRef(
|
|
|
4142
4153
|
color: theme$1.ERROR
|
|
4143
4154
|
}
|
|
4144
4155
|
}
|
|
4145
|
-
) : /* @__PURE__ */ React.createElement(View,
|
|
4156
|
+
)) : null, errorMessageMaxReachCount ? /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React.createElement(
|
|
4157
|
+
CustomTypography,
|
|
4158
|
+
{
|
|
4159
|
+
text: errorMessageMaxReachCount,
|
|
4160
|
+
variant: FontStyle.L2_REGULAR,
|
|
4161
|
+
style: {
|
|
4162
|
+
alignSelf: "flex-start",
|
|
4163
|
+
color: theme$1.ERROR
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
)) : null);
|
|
4146
4167
|
}
|
|
4147
4168
|
);
|
|
4148
4169
|
var index$4 = withThemeProvider(OTPInput);
|
|
@@ -4397,7 +4418,7 @@ const CustomSlideButton = React.forwardRef(
|
|
|
4397
4418
|
});
|
|
4398
4419
|
},
|
|
4399
4420
|
onPanResponderRelease: (e, gestureState) => {
|
|
4400
|
-
if (gestureState.dx >= value.current * 0.
|
|
4421
|
+
if (gestureState.dx >= value.current * 0.8) {
|
|
4401
4422
|
onComplete?.();
|
|
4402
4423
|
Animated.timing(translateX, {
|
|
4403
4424
|
toValue: value.current - BUTTON_WIDTH,
|