dhre-ui-kit 0.0.202 → 0.0.204
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.js +24 -8
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +23 -8
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { TextInput as TextInput$1 } from 'react-native-paper';
|
|
|
12
12
|
import { Dropdown } from 'react-native-element-dropdown';
|
|
13
13
|
import DocumentPicker from 'react-native-document-picker';
|
|
14
14
|
import RNFS from 'react-native-fs';
|
|
15
|
+
import OTPVerify, { removeListener, startOtpListener } from 'react-native-otp-verify';
|
|
15
16
|
import Clipboard from '@react-native-clipboard/clipboard';
|
|
16
17
|
|
|
17
18
|
var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
|
|
@@ -3899,6 +3900,25 @@ const OTPInput = React.forwardRef(
|
|
|
3899
3900
|
setIsResendOtpEnable(true);
|
|
3900
3901
|
}, 5e3);
|
|
3901
3902
|
};
|
|
3903
|
+
useEffect(() => {
|
|
3904
|
+
if (Platform.OS === "android") {
|
|
3905
|
+
onStartListeningOtp();
|
|
3906
|
+
}
|
|
3907
|
+
return () => {
|
|
3908
|
+
if (Platform.OS === "android") {
|
|
3909
|
+
OTPVerify.removeListener();
|
|
3910
|
+
removeListener();
|
|
3911
|
+
}
|
|
3912
|
+
};
|
|
3913
|
+
}, []);
|
|
3914
|
+
const onStartListeningOtp = async () => {
|
|
3915
|
+
await OTPVerify.getOtp();
|
|
3916
|
+
startOtpListener((message) => {
|
|
3917
|
+
const otpRegex = new RegExp(`(\\d{${length}})`, "g");
|
|
3918
|
+
const otp2 = otpRegex.exec(message)?.[1];
|
|
3919
|
+
setOTP(otp2 ?? "");
|
|
3920
|
+
});
|
|
3921
|
+
};
|
|
3902
3922
|
React.useImperativeHandle(ref, () => ({
|
|
3903
3923
|
reset() {
|
|
3904
3924
|
setOTP("");
|
|
@@ -3911,19 +3931,14 @@ const OTPInput = React.forwardRef(
|
|
|
3911
3931
|
}));
|
|
3912
3932
|
const handleChange = (index, value) => {
|
|
3913
3933
|
const regex = /^\d+$/;
|
|
3914
|
-
if (value.length === 1 &&
|
|
3915
|
-
regex.test(value) && index >= 0 && index < length) {
|
|
3934
|
+
if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
|
|
3916
3935
|
const newOTP = `${otp}${value}`;
|
|
3917
3936
|
setOTP(newOTP);
|
|
3918
|
-
|
|
3919
|
-
refs.current[index + 1]?.focus();
|
|
3920
|
-
}
|
|
3937
|
+
refs.current[index + 1]?.focus();
|
|
3921
3938
|
} else if (value.length === 0 && index > 0) {
|
|
3922
3939
|
const newOTP = otp.slice(0, -1);
|
|
3923
3940
|
setOTP(newOTP);
|
|
3924
|
-
|
|
3925
|
-
refs.current[index - 1]?.focus();
|
|
3926
|
-
}
|
|
3941
|
+
refs.current[index - 1]?.focus();
|
|
3927
3942
|
} else if (value?.length === length) {
|
|
3928
3943
|
setOTP(value);
|
|
3929
3944
|
refs.current[length - 1]?.focus();
|