dhre-ui-kit 0.0.330 → 0.0.331
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 +32 -5
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +31 -5
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -1
package/lib/index.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { TextInput as TextInput$1 } from 'react-native-paper';
|
|
|
15
15
|
import { Dropdown } from 'react-native-element-dropdown';
|
|
16
16
|
import DocumentPicker from 'react-native-document-picker';
|
|
17
17
|
import RNFS from 'react-native-fs';
|
|
18
|
+
import OTPVerify, { removeListener, startOtpListener } from 'react-native-otp-verify';
|
|
18
19
|
|
|
19
20
|
var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
|
|
20
21
|
ShapeType2["LINE"] = "line";
|
|
@@ -4067,10 +4068,13 @@ const OTPInput = React.forwardRef(
|
|
|
4067
4068
|
const [activeInput, setActiveInput] = useState(null);
|
|
4068
4069
|
const [resendOTPCount, setResendOTPCount] = useState(0);
|
|
4069
4070
|
const [errorMessageMaxReachCount, setErrorMessageMaxReachCount] = useState("");
|
|
4070
|
-
const filteredTheme = Object?.keys(theme)?.reduce(
|
|
4071
|
-
acc
|
|
4072
|
-
|
|
4073
|
-
|
|
4071
|
+
const filteredTheme = Object?.keys(theme)?.reduce(
|
|
4072
|
+
(acc, key) => {
|
|
4073
|
+
acc[key] = theme[key][mode];
|
|
4074
|
+
return acc;
|
|
4075
|
+
},
|
|
4076
|
+
{}
|
|
4077
|
+
);
|
|
4074
4078
|
const { theme: theme$1 } = mode ? { theme: filteredTheme } : useTheme();
|
|
4075
4079
|
const [timeLeft, setTimeLeft] = useState(60);
|
|
4076
4080
|
useEffect(() => {
|
|
@@ -4116,6 +4120,28 @@ const OTPInput = React.forwardRef(
|
|
|
4116
4120
|
setTimeLeft(timerToResend / 1e3);
|
|
4117
4121
|
}, timerToResend);
|
|
4118
4122
|
};
|
|
4123
|
+
useEffect(() => {
|
|
4124
|
+
if (Platform.OS === "android") {
|
|
4125
|
+
onStartListeningOtp();
|
|
4126
|
+
}
|
|
4127
|
+
return () => {
|
|
4128
|
+
if (Platform.OS === "android") {
|
|
4129
|
+
OTPVerify.removeListener();
|
|
4130
|
+
removeListener();
|
|
4131
|
+
}
|
|
4132
|
+
};
|
|
4133
|
+
}, []);
|
|
4134
|
+
const onStartListeningOtp = async () => {
|
|
4135
|
+
await OTPVerify.getOtp();
|
|
4136
|
+
startOtpListener((message) => {
|
|
4137
|
+
const otpRegex = new RegExp(`(\\d{${length}})`, "g");
|
|
4138
|
+
const otp2 = otpRegex.exec(message)?.[1];
|
|
4139
|
+
setOTP(otp2 ?? "");
|
|
4140
|
+
if (otp2) {
|
|
4141
|
+
refs.current[otp2?.length - 1]?.focus();
|
|
4142
|
+
}
|
|
4143
|
+
});
|
|
4144
|
+
};
|
|
4119
4145
|
React.useImperativeHandle(ref, () => ({
|
|
4120
4146
|
reset() {
|
|
4121
4147
|
setOTP("");
|
|
@@ -4187,7 +4213,7 @@ const OTPInput = React.forwardRef(
|
|
|
4187
4213
|
onChangeText: (text) => handleChange(index, text),
|
|
4188
4214
|
value: otp[index] ? "\u25CF" : "",
|
|
4189
4215
|
placeholder: "",
|
|
4190
|
-
keyboardType: "
|
|
4216
|
+
keyboardType: "number-pad",
|
|
4191
4217
|
ref: (el) => refs.current[index] = el,
|
|
4192
4218
|
returnKeyType: otp.length === length ? "done" : "next",
|
|
4193
4219
|
importantForAutofill: "yes",
|