dhre-ui-kit 0.0.251 → 0.0.253
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.d.ts +1 -0
- package/lib/index.js +20 -27
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +20 -27
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -612,6 +612,7 @@ interface CommonTextInputProps extends TextInputProps$1 {
|
|
|
612
612
|
handlePress?: () => void;
|
|
613
613
|
rightIcon?: () => React$1.ReactElement;
|
|
614
614
|
onRightIconPress?: () => void;
|
|
615
|
+
onlyErrorBorderLabel?: boolean;
|
|
615
616
|
}
|
|
616
617
|
declare const CommonTextInput: (props: CommonTextInputProps) => React$1.JSX.Element;
|
|
617
618
|
|
package/lib/index.js
CHANGED
|
@@ -3400,7 +3400,8 @@ const CommonTextInput = (props) => {
|
|
|
3400
3400
|
multiline = false,
|
|
3401
3401
|
// Default multiline to false
|
|
3402
3402
|
rightIcon,
|
|
3403
|
-
onRightIconPress
|
|
3403
|
+
onRightIconPress,
|
|
3404
|
+
onlyErrorBorderLabel
|
|
3404
3405
|
} = props;
|
|
3405
3406
|
return /* @__PURE__ */ React__default["default"].createElement(reactNative.Pressable, { onPress: handlePress, style: styles$9.container }, /* @__PURE__ */ React__default["default"].createElement(
|
|
3406
3407
|
reactNativePaper.TextInput,
|
|
@@ -3412,7 +3413,7 @@ const CommonTextInput = (props) => {
|
|
|
3412
3413
|
autoCorrect: false,
|
|
3413
3414
|
outlineStyle: {
|
|
3414
3415
|
...styles$9.outlineStyle,
|
|
3415
|
-
borderColor: errorMessage?.length ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : value?.length ? activeBorderColor : inactiveBorderColor
|
|
3416
|
+
borderColor: errorMessage?.length || onlyErrorBorderLabel ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : value?.length ? activeBorderColor : inactiveBorderColor
|
|
3416
3417
|
},
|
|
3417
3418
|
label,
|
|
3418
3419
|
value,
|
|
@@ -3422,12 +3423,12 @@ const CommonTextInput = (props) => {
|
|
|
3422
3423
|
theme: {
|
|
3423
3424
|
colors: {
|
|
3424
3425
|
onSurfaceVariant: value?.length ? activeBorderColor : inactiveBorderColor,
|
|
3425
|
-
error: errorMessage?.length ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : DHRE_COLORS_TEXT.DH_BLACK,
|
|
3426
|
+
error: errorMessage?.length || onlyErrorBorderLabel ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : DHRE_COLORS_TEXT.DH_BLACK,
|
|
3426
3427
|
primary: labelColor ? errorMessage?.length ? DHRE_DEFAULT.DH_SEMENTIC_ERROR : labelColor : DHRE_COLORS_TEXT.DH_BLACK
|
|
3427
3428
|
}
|
|
3428
3429
|
},
|
|
3429
3430
|
style: [
|
|
3430
|
-
errorMessage ? styles$9.errorInput : styles$9.input,
|
|
3431
|
+
errorMessage || onlyErrorBorderLabel ? styles$9.errorInput : styles$9.input,
|
|
3431
3432
|
inputStyle,
|
|
3432
3433
|
multiline && styles$9.multilineInput
|
|
3433
3434
|
// Apply multiline style if true
|
|
@@ -3437,7 +3438,7 @@ const CommonTextInput = (props) => {
|
|
|
3437
3438
|
placeholder: placeholderText,
|
|
3438
3439
|
editable,
|
|
3439
3440
|
pointerEvents,
|
|
3440
|
-
error: errorMessage?.length ? true : false,
|
|
3441
|
+
error: errorMessage?.length || onlyErrorBorderLabel ? true : false,
|
|
3441
3442
|
multiline,
|
|
3442
3443
|
numberOfLines: multiline ? 4 : 1,
|
|
3443
3444
|
right: rightIcon ? /* @__PURE__ */ React__default["default"].createElement(
|
|
@@ -4030,8 +4031,7 @@ const OTPInput = React__default["default"].forwardRef(
|
|
|
4030
4031
|
}
|
|
4031
4032
|
return () => clearInterval(timer);
|
|
4032
4033
|
}, [timeLeft, isResendOtpEnable]);
|
|
4033
|
-
const
|
|
4034
|
-
refs.current = Array(length).fill(0).map((_, index) => refs.current[index] || null);
|
|
4034
|
+
const otpRefs = React.useRef(Array(length).fill(null));
|
|
4035
4035
|
React.useEffect(() => {
|
|
4036
4036
|
enableResendOtp();
|
|
4037
4037
|
}, []);
|
|
@@ -4050,11 +4050,7 @@ const OTPInput = React__default["default"].forwardRef(
|
|
|
4050
4050
|
}
|
|
4051
4051
|
};
|
|
4052
4052
|
const disableResendButton = () => {
|
|
4053
|
-
|
|
4054
|
-
return true;
|
|
4055
|
-
} else {
|
|
4056
|
-
return false;
|
|
4057
|
-
}
|
|
4053
|
+
return disabled || resendOTPCount >= maxResendCount;
|
|
4058
4054
|
};
|
|
4059
4055
|
const enableResendOtp = () => {
|
|
4060
4056
|
setTimeout(() => {
|
|
@@ -4080,42 +4076,39 @@ const OTPInput = React__default["default"].forwardRef(
|
|
|
4080
4076
|
const otp2 = otpRegex.exec(message)?.[1];
|
|
4081
4077
|
setOTP(otp2 ?? "");
|
|
4082
4078
|
if (otp2) {
|
|
4083
|
-
|
|
4079
|
+
otpRefs.current[otp2?.length - 1]?.focus();
|
|
4084
4080
|
}
|
|
4085
4081
|
});
|
|
4086
4082
|
};
|
|
4083
|
+
const reset = () => {
|
|
4084
|
+
setOTP("");
|
|
4085
|
+
otpRefs.current[0]?.focus();
|
|
4086
|
+
};
|
|
4087
4087
|
React__default["default"].useImperativeHandle(ref, () => ({
|
|
4088
|
-
reset
|
|
4089
|
-
setOTP("");
|
|
4090
|
-
refs.current[0]?.focus();
|
|
4091
|
-
},
|
|
4092
|
-
set(newOtp) {
|
|
4093
|
-
setOTP(newOtp);
|
|
4094
|
-
refs.current[newOtp?.length - 1]?.focus();
|
|
4095
|
-
}
|
|
4088
|
+
reset
|
|
4096
4089
|
}));
|
|
4097
4090
|
const handleChange = (index, value) => {
|
|
4098
4091
|
const regex = /^\d+$/;
|
|
4099
4092
|
if (value.length === 1 && regex.test(value) && index >= 0 && index < length) {
|
|
4100
4093
|
const newOTP = `${otp}${value}`;
|
|
4101
4094
|
setOTP(newOTP);
|
|
4102
|
-
|
|
4095
|
+
otpRefs.current[index + 1]?.focus();
|
|
4103
4096
|
} else if (value.length === 0 && index > 0) {
|
|
4104
4097
|
const newOTP = otp.slice(0, -1);
|
|
4105
4098
|
setOTP(newOTP);
|
|
4106
|
-
|
|
4099
|
+
otpRefs.current[index - 1]?.focus();
|
|
4107
4100
|
} else if (value?.length === length) {
|
|
4108
4101
|
setOTP(value);
|
|
4109
|
-
|
|
4102
|
+
otpRefs.current[length - 1]?.focus();
|
|
4110
4103
|
} else {
|
|
4111
4104
|
const newOTP = otp.slice(0, -1);
|
|
4112
4105
|
setOTP(newOTP);
|
|
4113
|
-
|
|
4106
|
+
otpRefs.current[index]?.focus();
|
|
4114
4107
|
}
|
|
4115
4108
|
};
|
|
4116
4109
|
const handleKeyPress = (e, index) => {
|
|
4117
4110
|
if (e.nativeEvent.key === "Backspace" && index > 0) {
|
|
4118
|
-
|
|
4111
|
+
otpRefs.current[index - 1]?.focus();
|
|
4119
4112
|
}
|
|
4120
4113
|
};
|
|
4121
4114
|
React.useEffect(() => {
|
|
@@ -4151,7 +4144,7 @@ const OTPInput = React__default["default"].forwardRef(
|
|
|
4151
4144
|
value: otp[index] ? "\u25CF" : "",
|
|
4152
4145
|
placeholder: "",
|
|
4153
4146
|
keyboardType: "numeric",
|
|
4154
|
-
ref: (el) =>
|
|
4147
|
+
ref: (el) => otpRefs.current[index] = el,
|
|
4155
4148
|
returnKeyType: otp.length === length ? "done" : "next",
|
|
4156
4149
|
importantForAutofill: "yes",
|
|
4157
4150
|
textContentType: "oneTimeCode",
|