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 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("");
@@ -3947,12 +3968,14 @@ const OTPInput = React__default["default"].forwardRef(
3947
3968
  if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
3948
3969
  const newOTP = `${otp}${value}`;
3949
3970
  setOTP(newOTP);
3950
- refs.current[index + 1]?.focus();
3971
+ if (index < length - 1) {
3972
+ refs.current[index + 1]?.focus();
3973
+ }
3951
3974
  } else if (value.length === 0 && index > 0) {
3952
3975
  const newOTP = otp.slice(0, -1);
3953
3976
  setOTP(newOTP);
3954
3977
  refs.current[index - 1]?.focus();
3955
- } else if (value?.length === length) {
3978
+ } else if (value.length === length) {
3956
3979
  setOTP(value);
3957
3980
  refs.current[length - 1]?.focus();
3958
3981
  } else {