dhre-ui-kit 0.0.255 → 0.0.257

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