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.js
CHANGED
|
@@ -16,6 +16,7 @@ var reactNativePaper = require('react-native-paper');
|
|
|
16
16
|
var reactNativeElementDropdown = require('react-native-element-dropdown');
|
|
17
17
|
var DocumentPicker = require('react-native-document-picker');
|
|
18
18
|
var RNFS = require('react-native-fs');
|
|
19
|
+
var OTPVerify = require('react-native-otp-verify');
|
|
19
20
|
var Clipboard = require('@react-native-clipboard/clipboard');
|
|
20
21
|
|
|
21
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -45,6 +46,7 @@ var Progress__namespace = /*#__PURE__*/_interopNamespace(Progress);
|
|
|
45
46
|
var CountryPicker__default = /*#__PURE__*/_interopDefaultLegacy(CountryPicker);
|
|
46
47
|
var DocumentPicker__default = /*#__PURE__*/_interopDefaultLegacy(DocumentPicker);
|
|
47
48
|
var RNFS__default = /*#__PURE__*/_interopDefaultLegacy(RNFS);
|
|
49
|
+
var OTPVerify__default = /*#__PURE__*/_interopDefaultLegacy(OTPVerify);
|
|
48
50
|
var Clipboard__default = /*#__PURE__*/_interopDefaultLegacy(Clipboard);
|
|
49
51
|
|
|
50
52
|
var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
|
|
@@ -3932,6 +3934,25 @@ const OTPInput = React__default["default"].forwardRef(
|
|
|
3932
3934
|
setIsResendOtpEnable(true);
|
|
3933
3935
|
}, 5e3);
|
|
3934
3936
|
};
|
|
3937
|
+
React.useEffect(() => {
|
|
3938
|
+
if (reactNative.Platform.OS === "android") {
|
|
3939
|
+
onStartListeningOtp();
|
|
3940
|
+
}
|
|
3941
|
+
return () => {
|
|
3942
|
+
if (reactNative.Platform.OS === "android") {
|
|
3943
|
+
OTPVerify__default["default"].removeListener();
|
|
3944
|
+
OTPVerify.removeListener();
|
|
3945
|
+
}
|
|
3946
|
+
};
|
|
3947
|
+
}, []);
|
|
3948
|
+
const onStartListeningOtp = async () => {
|
|
3949
|
+
await OTPVerify__default["default"].getOtp();
|
|
3950
|
+
OTPVerify.startOtpListener((message) => {
|
|
3951
|
+
const otpRegex = new RegExp(`(\\d{${length}})`, "g");
|
|
3952
|
+
const otp2 = otpRegex.exec(message)?.[1];
|
|
3953
|
+
setOTP(otp2 ?? "");
|
|
3954
|
+
});
|
|
3955
|
+
};
|
|
3935
3956
|
React__default["default"].useImperativeHandle(ref, () => ({
|
|
3936
3957
|
reset() {
|
|
3937
3958
|
setOTP("");
|
|
@@ -3944,19 +3965,14 @@ const OTPInput = React__default["default"].forwardRef(
|
|
|
3944
3965
|
}));
|
|
3945
3966
|
const handleChange = (index, value) => {
|
|
3946
3967
|
const regex = /^\d+$/;
|
|
3947
|
-
if (value.length === 1 &&
|
|
3948
|
-
regex.test(value) && index >= 0 && index < length) {
|
|
3968
|
+
if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
|
|
3949
3969
|
const newOTP = `${otp}${value}`;
|
|
3950
3970
|
setOTP(newOTP);
|
|
3951
|
-
|
|
3952
|
-
refs.current[index + 1]?.focus();
|
|
3953
|
-
}
|
|
3971
|
+
refs.current[index + 1]?.focus();
|
|
3954
3972
|
} else if (value.length === 0 && index > 0) {
|
|
3955
3973
|
const newOTP = otp.slice(0, -1);
|
|
3956
3974
|
setOTP(newOTP);
|
|
3957
|
-
|
|
3958
|
-
refs.current[index - 1]?.focus();
|
|
3959
|
-
}
|
|
3975
|
+
refs.current[index - 1]?.focus();
|
|
3960
3976
|
} else if (value?.length === length) {
|
|
3961
3977
|
setOTP(value);
|
|
3962
3978
|
refs.current[length - 1]?.focus();
|