dhre-ui-kit 0.0.256 → 0.0.258
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 +19 -23
- package/lib/index.js +195 -186
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +195 -186
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -3950,205 +3950,214 @@ const styles$5 = StyleSheet.create({
|
|
|
3950
3950
|
}
|
|
3951
3951
|
});
|
|
3952
3952
|
|
|
3953
|
-
const
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
}
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3953
|
+
const OTPInputComponent = ({
|
|
3954
|
+
length = 4,
|
|
3955
|
+
onComplete,
|
|
3956
|
+
resendOTP,
|
|
3957
|
+
errorMessage,
|
|
3958
|
+
testId = "",
|
|
3959
|
+
otpContainerStyle,
|
|
3960
|
+
otpHeaderTextStyle,
|
|
3961
|
+
textInputStyle,
|
|
3962
|
+
resendTextStyle,
|
|
3963
|
+
resendOtpColor,
|
|
3964
|
+
label = "OTP",
|
|
3965
|
+
resendText = "Resend OTP",
|
|
3966
|
+
mode,
|
|
3967
|
+
disabled,
|
|
3968
|
+
maxResendCount = 2,
|
|
3969
|
+
timerToResend = 6e4,
|
|
3970
|
+
timerIcon
|
|
3971
|
+
}, ref) => {
|
|
3972
|
+
const [otp, setOTP] = useState("");
|
|
3973
|
+
const [isResendOtpEnable, setIsResendOtpEnable] = useState(false);
|
|
3974
|
+
const [activeInput, setActiveInput] = useState(null);
|
|
3975
|
+
const [resendOTPCount, setResendOTPCount] = useState(0);
|
|
3976
|
+
const [errorMessageMaxReachCount, setErrorMessageMaxReachCount] = useState("");
|
|
3977
|
+
const filteredTheme = mode ? theme[mode] : theme;
|
|
3978
|
+
const { theme: theme$1 } = useTheme() || { theme: filteredTheme };
|
|
3979
|
+
const [timeLeft, setTimeLeft] = useState(60);
|
|
3980
|
+
useEffect(() => {
|
|
3981
|
+
let timer;
|
|
3982
|
+
if (!isResendOtpEnable && timeLeft > 0) {
|
|
3983
|
+
timer = setInterval(() => {
|
|
3984
|
+
setTimeLeft((prevTime) => prevTime - 1);
|
|
3985
|
+
}, 1e3);
|
|
3986
|
+
} else if (timeLeft === 0) {
|
|
3987
|
+
clearInterval(timer);
|
|
3988
|
+
}
|
|
3989
|
+
return () => clearInterval(timer);
|
|
3990
|
+
}, [timeLeft, isResendOtpEnable]);
|
|
3991
|
+
const otpRefs = useRef(Array(length).fill(null));
|
|
3992
|
+
useEffect(() => {
|
|
3993
|
+
enableResendOtp();
|
|
3994
|
+
}, []);
|
|
3995
|
+
const onClickResendOTP = () => {
|
|
3996
|
+
if (resendOTPCount > maxResendCount - 1) {
|
|
3997
|
+
setErrorMessageMaxReachCount(
|
|
3998
|
+
"You have exceeded the maximum number of attempts."
|
|
3999
|
+
);
|
|
4000
|
+
}
|
|
4001
|
+
if (resendOTPCount < maxResendCount) {
|
|
4002
|
+
setIsResendOtpEnable(false);
|
|
4003
|
+
setResendOTPCount(resendOTPCount + 1);
|
|
3992
4004
|
enableResendOtp();
|
|
3993
|
-
|
|
3994
|
-
const onClickResendOTP = () => {
|
|
3995
|
-
if (resendOTPCount > maxResendCount - 1) {
|
|
3996
|
-
setErrorMessageMaxReachCount(
|
|
3997
|
-
"You have exceeded the maximum number of attempts."
|
|
3998
|
-
);
|
|
3999
|
-
}
|
|
4000
|
-
if (resendOTPCount < maxResendCount) {
|
|
4001
|
-
setIsResendOtpEnable(false);
|
|
4002
|
-
setResendOTPCount(resendOTPCount + 1);
|
|
4003
|
-
enableResendOtp();
|
|
4004
|
-
resendOTP?.();
|
|
4005
|
-
setOTP("");
|
|
4006
|
-
}
|
|
4007
|
-
};
|
|
4008
|
-
const disableResendButton = () => {
|
|
4009
|
-
return disabled || resendOTPCount >= maxResendCount;
|
|
4010
|
-
};
|
|
4011
|
-
const enableResendOtp = () => {
|
|
4012
|
-
setTimeout(() => {
|
|
4013
|
-
setIsResendOtpEnable(true);
|
|
4014
|
-
setTimeLeft(timerToResend / 1e3);
|
|
4015
|
-
}, timerToResend);
|
|
4016
|
-
};
|
|
4017
|
-
useEffect(() => {
|
|
4018
|
-
if (Platform.OS === "android") {
|
|
4019
|
-
onStartListeningOtp();
|
|
4020
|
-
}
|
|
4021
|
-
return () => {
|
|
4022
|
-
if (Platform.OS === "android") {
|
|
4023
|
-
OTPVerify.removeListener();
|
|
4024
|
-
removeListener();
|
|
4025
|
-
}
|
|
4026
|
-
};
|
|
4027
|
-
}, []);
|
|
4028
|
-
const onStartListeningOtp = async () => {
|
|
4029
|
-
await OTPVerify.getOtp();
|
|
4030
|
-
startOtpListener((message) => {
|
|
4031
|
-
const otpRegex = new RegExp(`(\\d{${length}})`, "g");
|
|
4032
|
-
const otp2 = otpRegex.exec(message)?.[1];
|
|
4033
|
-
setOTP(otp2 ?? "");
|
|
4034
|
-
if (otp2) {
|
|
4035
|
-
otpRefs.current[otp2?.length - 1]?.focus();
|
|
4036
|
-
}
|
|
4037
|
-
});
|
|
4038
|
-
};
|
|
4039
|
-
const reset = () => {
|
|
4005
|
+
resendOTP?.();
|
|
4040
4006
|
setOTP("");
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
const newOTP = otp.slice(0, -1);
|
|
4061
|
-
setOTP(newOTP);
|
|
4062
|
-
otpRefs.current[index]?.focus();
|
|
4063
|
-
}
|
|
4064
|
-
};
|
|
4065
|
-
const handleKeyPress = (e, index) => {
|
|
4066
|
-
if (e.nativeEvent.key === "Backspace" && index > 0) {
|
|
4067
|
-
otpRefs.current[index - 1]?.focus();
|
|
4007
|
+
}
|
|
4008
|
+
};
|
|
4009
|
+
const disableResendButton = () => {
|
|
4010
|
+
return disabled || resendOTPCount >= maxResendCount;
|
|
4011
|
+
};
|
|
4012
|
+
const enableResendOtp = () => {
|
|
4013
|
+
setTimeout(() => {
|
|
4014
|
+
setIsResendOtpEnable(true);
|
|
4015
|
+
setTimeLeft(timerToResend / 1e3);
|
|
4016
|
+
}, timerToResend);
|
|
4017
|
+
};
|
|
4018
|
+
useEffect(() => {
|
|
4019
|
+
if (Platform.OS === "android") {
|
|
4020
|
+
onStartListeningOtp();
|
|
4021
|
+
}
|
|
4022
|
+
return () => {
|
|
4023
|
+
if (Platform.OS === "android") {
|
|
4024
|
+
OTPVerify.removeListener();
|
|
4025
|
+
removeListener();
|
|
4068
4026
|
}
|
|
4069
4027
|
};
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
{
|
|
4078
|
-
|
|
4079
|
-
variant: FontStyle.B4_REGULAR,
|
|
4080
|
-
style: {
|
|
4081
|
-
textAlign: "left",
|
|
4082
|
-
...otpHeaderTextStyle
|
|
4083
|
-
}
|
|
4084
|
-
}
|
|
4085
|
-
), /* @__PURE__ */ React.createElement(View, { style: { ...styles$5.textInputContainer } }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React.createElement(
|
|
4086
|
-
TextInput,
|
|
4087
|
-
{
|
|
4088
|
-
key: index?.toString(),
|
|
4089
|
-
style: {
|
|
4090
|
-
...styles$5.textInputStyle,
|
|
4091
|
-
...textInputStyle
|
|
4092
|
-
},
|
|
4093
|
-
onFocus: () => setActiveInput(index),
|
|
4094
|
-
onBlur: () => setActiveInput(null),
|
|
4095
|
-
onKeyPress: (e) => handleKeyPress(e, index),
|
|
4096
|
-
onChangeText: (text) => handleChange(index, text),
|
|
4097
|
-
value: otp[index] ? "\u25CF" : "",
|
|
4098
|
-
placeholder: "",
|
|
4099
|
-
keyboardType: "numeric",
|
|
4100
|
-
ref: (el) => otpRefs.current[index] = el,
|
|
4101
|
-
returnKeyType: otp.length === length ? "done" : "next",
|
|
4102
|
-
importantForAutofill: "yes",
|
|
4103
|
-
textContentType: "oneTimeCode",
|
|
4104
|
-
autoComplete: "sms-otp"
|
|
4028
|
+
}, []);
|
|
4029
|
+
const onStartListeningOtp = async () => {
|
|
4030
|
+
await OTPVerify.getOtp();
|
|
4031
|
+
startOtpListener((message) => {
|
|
4032
|
+
const otpRegex = new RegExp(`(\\d{${length}})`, "g");
|
|
4033
|
+
const otp2 = otpRegex.exec(message)?.[1];
|
|
4034
|
+
setOTP(otp2 ?? "");
|
|
4035
|
+
if (otp2) {
|
|
4036
|
+
otpRefs.current[otp2?.length - 1]?.focus();
|
|
4105
4037
|
}
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4038
|
+
});
|
|
4039
|
+
};
|
|
4040
|
+
const reset = () => {
|
|
4041
|
+
setOTP("");
|
|
4042
|
+
otpRefs.current[0]?.focus();
|
|
4043
|
+
};
|
|
4044
|
+
React.useImperativeHandle(ref, () => ({
|
|
4045
|
+
reset
|
|
4046
|
+
}));
|
|
4047
|
+
const handleChange = (index, value) => {
|
|
4048
|
+
const regex = /^\d+$/;
|
|
4049
|
+
if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
|
|
4050
|
+
const newOTP = `${otp}${value}`;
|
|
4051
|
+
setOTP(newOTP);
|
|
4052
|
+
otpRefs.current[index + 1]?.focus();
|
|
4053
|
+
} else if (value.length === 0 && index > 0) {
|
|
4054
|
+
const newOTP = otp.slice(0, -1);
|
|
4055
|
+
setOTP(newOTP);
|
|
4056
|
+
otpRefs.current[index - 1]?.focus();
|
|
4057
|
+
} else if (value?.length === length) {
|
|
4058
|
+
setOTP(value);
|
|
4059
|
+
otpRefs.current[length - 1]?.focus();
|
|
4060
|
+
} else {
|
|
4061
|
+
const newOTP = otp.slice(0, -1);
|
|
4062
|
+
setOTP(newOTP);
|
|
4063
|
+
otpRefs.current[index]?.focus();
|
|
4064
|
+
}
|
|
4065
|
+
};
|
|
4066
|
+
const handleKeyPress = (e, index) => {
|
|
4067
|
+
if (e.nativeEvent.key === "Backspace" && index > 0) {
|
|
4068
|
+
otpRefs.current[index - 1]?.focus();
|
|
4069
|
+
}
|
|
4070
|
+
};
|
|
4071
|
+
useEffect(() => {
|
|
4072
|
+
if (otp.length === length) {
|
|
4073
|
+
onComplete?.(otp);
|
|
4074
|
+
}
|
|
4075
|
+
}, [otp]);
|
|
4076
|
+
return /* @__PURE__ */ React.createElement(View, { style: { ...otpContainerStyle }, "data-testid": testId }, /* @__PURE__ */ React.createElement(
|
|
4077
|
+
CustomTypography,
|
|
4078
|
+
{
|
|
4079
|
+
text: label,
|
|
4080
|
+
variant: FontStyle.B4_REGULAR,
|
|
4081
|
+
style: {
|
|
4082
|
+
color: otp?.length ? theme$1.CONTENT_PRIMARY : theme$1.CONTENT_SECONDRY,
|
|
4083
|
+
textAlign: "left",
|
|
4084
|
+
...otpHeaderTextStyle
|
|
4111
4085
|
}
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4086
|
+
}
|
|
4087
|
+
), /* @__PURE__ */ React.createElement(View, { style: { ...styles$5.textInputContainer } }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React.createElement(
|
|
4088
|
+
TextInput,
|
|
4089
|
+
{
|
|
4090
|
+
key: index?.toString(),
|
|
4091
|
+
style: {
|
|
4092
|
+
...styles$5.textInputStyle,
|
|
4093
|
+
color: theme$1.CONTENT_PRIMARY,
|
|
4094
|
+
borderColor: errorMessage ? theme$1.ERROR : otp.length === length ? theme$1.SUCCESS : activeInput === index ? theme$1.BORDER_INVERTED : theme$1.BORDER_PRIMARY,
|
|
4095
|
+
...textInputStyle
|
|
4118
4096
|
},
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4097
|
+
onFocus: () => setActiveInput(index),
|
|
4098
|
+
onBlur: () => setActiveInput(null),
|
|
4099
|
+
onKeyPress: (e) => handleKeyPress(e, index),
|
|
4100
|
+
onChangeText: (text) => handleChange(index, text),
|
|
4101
|
+
value: otp[index] ? "\u25CF" : "",
|
|
4102
|
+
placeholder: "",
|
|
4103
|
+
keyboardType: "numeric",
|
|
4104
|
+
ref: (el) => otpRefs.current[index] = el,
|
|
4105
|
+
returnKeyType: otp.length === length ? "done" : "next",
|
|
4106
|
+
importantForAutofill: "yes",
|
|
4107
|
+
textContentType: "oneTimeCode",
|
|
4108
|
+
autoComplete: "sms-otp",
|
|
4109
|
+
selectionColor: theme$1.CONTENT_PRIMARY
|
|
4110
|
+
}
|
|
4111
|
+
))), !errorMessageMaxReachCount && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerContainer }, (disableResendButton() || !isResendOtpEnable) && /* @__PURE__ */ React.createElement(View, { style: styles$5.timerIconContainer }, timerIcon, /* @__PURE__ */ React.createElement(
|
|
4112
|
+
CustomTypography,
|
|
4113
|
+
{
|
|
4114
|
+
text: `00:${timeLeft} secs`,
|
|
4115
|
+
variant: FontStyle.L1_REGULAR,
|
|
4116
|
+
style: { color: theme$1.INFO }
|
|
4117
|
+
}
|
|
4118
|
+
)), /* @__PURE__ */ React.createElement(
|
|
4119
|
+
Pressable,
|
|
4120
|
+
{
|
|
4121
|
+
onPress: onClickResendOTP,
|
|
4122
|
+
style: styles$5.resendOTPStyle,
|
|
4123
|
+
disabled: disableResendButton() || !isResendOtpEnable
|
|
4124
|
+
},
|
|
4125
|
+
/* @__PURE__ */ React.createElement(
|
|
4131
4126
|
CustomTypography,
|
|
4132
4127
|
{
|
|
4133
|
-
text:
|
|
4128
|
+
text: resendText,
|
|
4134
4129
|
variant: FontStyle.L2_REGULAR,
|
|
4135
4130
|
style: {
|
|
4136
|
-
|
|
4131
|
+
textDecorationLine: "underline",
|
|
4132
|
+
color: isResendOtpEnable ? resendOtpColor ?? theme$1.CONTENT_PRIMARY : theme$1.CONTENT_DISABLE,
|
|
4133
|
+
...resendTextStyle
|
|
4137
4134
|
}
|
|
4138
4135
|
}
|
|
4139
|
-
)
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4136
|
+
)
|
|
4137
|
+
)), errorMessage ? /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React.createElement(
|
|
4138
|
+
CustomTypography,
|
|
4139
|
+
{
|
|
4140
|
+
text: errorMessage,
|
|
4141
|
+
variant: FontStyle.L2_REGULAR,
|
|
4142
|
+
style: {
|
|
4143
|
+
alignSelf: "flex-start",
|
|
4144
|
+
color: theme$1.ERROR
|
|
4147
4145
|
}
|
|
4148
|
-
|
|
4149
|
-
}
|
|
4150
|
-
|
|
4151
|
-
|
|
4146
|
+
}
|
|
4147
|
+
)) : null, errorMessageMaxReachCount ? /* @__PURE__ */ React.createElement(View, { style: styles$5.resendOtpContainer }, /* @__PURE__ */ React.createElement(
|
|
4148
|
+
CustomTypography,
|
|
4149
|
+
{
|
|
4150
|
+
text: errorMessageMaxReachCount,
|
|
4151
|
+
variant: FontStyle.L2_REGULAR,
|
|
4152
|
+
style: {
|
|
4153
|
+
alignSelf: "flex-start",
|
|
4154
|
+
color: theme$1.ERROR
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
)) : null);
|
|
4158
|
+
};
|
|
4159
|
+
const OTPInput = withThemeProvider(OTPInputComponent);
|
|
4160
|
+
var index$4 = React.forwardRef(OTPInput);
|
|
4152
4161
|
|
|
4153
4162
|
const styles$4 = StyleSheet.create({
|
|
4154
4163
|
stepperContainer: {
|
|
@@ -4888,5 +4897,5 @@ const RadioButtonGroup = ({ data, onSelect, containerStyle, labelStyle, optionCo
|
|
|
4888
4897
|
)));
|
|
4889
4898
|
};
|
|
4890
4899
|
|
|
4891
|
-
export { Accordion$1 as Accordion, index$1 as AppointmentCard, Badge$1 as Badge, BottomDrawer, CustomButton$1 as Button, Cards, category as Category, Checkbox as CheckBox, ContactModel, CountryDropDown as CountryPicker, CustomDocumentPicker$1 as CustomDocumentPicker, CustomDropdown$1 as CustomDropdown, CustomHeader$1 as CustomHeader, CustomIcon, CustomLoader$1 as CustomLoader, CustomProgressBar, CustomSearchBar, index$2 as CustomSlideButton, CustomSwitchBtn, CustomText$1 as CustomText, CustomTextInput, CustomTooltip, CustomTypography, DHRE_COLORS_ALERT, DHRE_COLORS_BG, DHRE_COLORS_PRIMARY, DHRE_COLORS_SECONDARY, DHRE_COLORS_TEXT, DHRE_DEFAULT, DateRangePicker$1 as DateRangePicker, CustomDropdown as DropDown, FONT_STYLES, feedback as FeedbackForm, FileUpload, FontStyle, Line, NotificationBandge, OTPInput, OurOffices as OurOfficesButton, PdfView, PopUp, index as PropertyDetails, RadioButtonGroup, ShapeType, TagSingleSelection as SingleSelectionTags, Star as StarRating, index$3 as Stepper, SwipableList$1 as SwipableList, Tabs$1 as Tabs, Tags, TextDirectType, CommonTextInput as TextInput, Theme, Toast, CustomSwitch as ToggleButton, ToggleButtonType, ToggleTextType, Topic$1 as Topic, copyToClipboard, theme as default, height, horizontalScale, moderateScale, toastService, verticalScale, width };
|
|
4900
|
+
export { Accordion$1 as Accordion, index$1 as AppointmentCard, Badge$1 as Badge, BottomDrawer, CustomButton$1 as Button, Cards, category as Category, Checkbox as CheckBox, ContactModel, CountryDropDown as CountryPicker, CustomDocumentPicker$1 as CustomDocumentPicker, CustomDropdown$1 as CustomDropdown, CustomHeader$1 as CustomHeader, CustomIcon, CustomLoader$1 as CustomLoader, CustomProgressBar, CustomSearchBar, index$2 as CustomSlideButton, CustomSwitchBtn, CustomText$1 as CustomText, CustomTextInput, CustomTooltip, CustomTypography, DHRE_COLORS_ALERT, DHRE_COLORS_BG, DHRE_COLORS_PRIMARY, DHRE_COLORS_SECONDARY, DHRE_COLORS_TEXT, DHRE_DEFAULT, DateRangePicker$1 as DateRangePicker, CustomDropdown as DropDown, FONT_STYLES, feedback as FeedbackForm, FileUpload, FontStyle, Line, NotificationBandge, index$4 as OTPInput, OurOffices as OurOfficesButton, PdfView, PopUp, index as PropertyDetails, RadioButtonGroup, ShapeType, TagSingleSelection as SingleSelectionTags, Star as StarRating, index$3 as Stepper, SwipableList$1 as SwipableList, Tabs$1 as Tabs, Tags, TextDirectType, CommonTextInput as TextInput, Theme, Toast, CustomSwitch as ToggleButton, ToggleButtonType, ToggleTextType, Topic$1 as Topic, copyToClipboard, theme as default, height, horizontalScale, moderateScale, toastService, verticalScale, width };
|
|
4892
4901
|
//# sourceMappingURL=index.mjs.map
|