dhre-ui-kit 0.0.203 → 0.0.205
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 +25 -2
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +24 -2
- 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("");
|
|
@@ -3914,12 +3934,14 @@ const OTPInput = React.forwardRef(
|
|
|
3914
3934
|
if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
|
|
3915
3935
|
const newOTP = `${otp}${value}`;
|
|
3916
3936
|
setOTP(newOTP);
|
|
3917
|
-
|
|
3937
|
+
if (index < length - 1) {
|
|
3938
|
+
refs.current[index + 1]?.focus();
|
|
3939
|
+
}
|
|
3918
3940
|
} else if (value.length === 0 && index > 0) {
|
|
3919
3941
|
const newOTP = otp.slice(0, -1);
|
|
3920
3942
|
setOTP(newOTP);
|
|
3921
3943
|
refs.current[index - 1]?.focus();
|
|
3922
|
-
} else if (value
|
|
3944
|
+
} else if (value.length === length) {
|
|
3923
3945
|
setOTP(value);
|
|
3924
3946
|
refs.current[length - 1]?.focus();
|
|
3925
3947
|
} else {
|