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 CHANGED
@@ -19,6 +19,7 @@ var reactNativePaper = require('react-native-paper');
19
19
  var reactNativeElementDropdown = require('react-native-element-dropdown');
20
20
  var DocumentPicker = require('react-native-document-picker');
21
21
  var RNFS = require('react-native-fs');
22
+ var OTPVerify = require('react-native-otp-verify');
22
23
 
23
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
25
 
@@ -51,6 +52,7 @@ var DeviceInfo__default = /*#__PURE__*/_interopDefaultLegacy(DeviceInfo);
51
52
  var CountryPicker__default = /*#__PURE__*/_interopDefaultLegacy(CountryPicker);
52
53
  var DocumentPicker__default = /*#__PURE__*/_interopDefaultLegacy(DocumentPicker);
53
54
  var RNFS__default = /*#__PURE__*/_interopDefaultLegacy(RNFS);
55
+ var OTPVerify__default = /*#__PURE__*/_interopDefaultLegacy(OTPVerify);
54
56
 
55
57
  var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
56
58
  ShapeType2["LINE"] = "line";
@@ -4103,10 +4105,13 @@ const OTPInput = React__default["default"].forwardRef(
4103
4105
  const [activeInput, setActiveInput] = React.useState(null);
4104
4106
  const [resendOTPCount, setResendOTPCount] = React.useState(0);
4105
4107
  const [errorMessageMaxReachCount, setErrorMessageMaxReachCount] = React.useState("");
4106
- const filteredTheme = Object?.keys(theme)?.reduce((acc, key) => {
4107
- acc[key] = theme[key][mode];
4108
- return acc;
4109
- }, {});
4108
+ const filteredTheme = Object?.keys(theme)?.reduce(
4109
+ (acc, key) => {
4110
+ acc[key] = theme[key][mode];
4111
+ return acc;
4112
+ },
4113
+ {}
4114
+ );
4110
4115
  const { theme: theme$1 } = mode ? { theme: filteredTheme } : useTheme();
4111
4116
  const [timeLeft, setTimeLeft] = React.useState(60);
4112
4117
  React.useEffect(() => {
@@ -4152,6 +4157,28 @@ const OTPInput = React__default["default"].forwardRef(
4152
4157
  setTimeLeft(timerToResend / 1e3);
4153
4158
  }, timerToResend);
4154
4159
  };
4160
+ React.useEffect(() => {
4161
+ if (reactNative.Platform.OS === "android") {
4162
+ onStartListeningOtp();
4163
+ }
4164
+ return () => {
4165
+ if (reactNative.Platform.OS === "android") {
4166
+ OTPVerify__default["default"].removeListener();
4167
+ OTPVerify.removeListener();
4168
+ }
4169
+ };
4170
+ }, []);
4171
+ const onStartListeningOtp = async () => {
4172
+ await OTPVerify__default["default"].getOtp();
4173
+ OTPVerify.startOtpListener((message) => {
4174
+ const otpRegex = new RegExp(`(\\d{${length}})`, "g");
4175
+ const otp2 = otpRegex.exec(message)?.[1];
4176
+ setOTP(otp2 ?? "");
4177
+ if (otp2) {
4178
+ refs.current[otp2?.length - 1]?.focus();
4179
+ }
4180
+ });
4181
+ };
4155
4182
  React__default["default"].useImperativeHandle(ref, () => ({
4156
4183
  reset() {
4157
4184
  setOTP("");
@@ -4223,7 +4250,7 @@ const OTPInput = React__default["default"].forwardRef(
4223
4250
  onChangeText: (text) => handleChange(index, text),
4224
4251
  value: otp[index] ? "\u25CF" : "",
4225
4252
  placeholder: "",
4226
- keyboardType: "numeric",
4253
+ keyboardType: "number-pad",
4227
4254
  ref: (el) => refs.current[index] = el,
4228
4255
  returnKeyType: otp.length === length ? "done" : "next",
4229
4256
  importantForAutofill: "yes",