allaw-ui 5.3.1 → 5.3.3
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.
|
@@ -68,28 +68,28 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
68
68
|
}, [propError, title]);
|
|
69
69
|
var validateInput = useCallback(function () {
|
|
70
70
|
var _a;
|
|
71
|
-
|
|
71
|
+
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] validateInput called, propError:"), propError);
|
|
72
72
|
var currentValue = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) || value;
|
|
73
|
-
// console.log(`Input ${title}: Current value: "${currentValue}"`);
|
|
74
73
|
var errorMessage = "";
|
|
75
74
|
if (isRequired && currentValue.trim() === "") {
|
|
76
75
|
errorMessage = "Ce champ est requis";
|
|
77
76
|
}
|
|
78
77
|
else if (validate && currentValue) {
|
|
79
78
|
var regex = typeof validate === "string" ? commonRegex[validate] : validate;
|
|
80
|
-
// console.log(`Input ${title}: Regex used: ${regex}`);
|
|
81
79
|
if (!regex.test(currentValue)) {
|
|
82
80
|
errorMessage = "Veuillez vérifier votre saisie";
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
|
-
|
|
83
|
+
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] validateInput - errorMessage:"), errorMessage, "propError:", propError);
|
|
84
|
+
// Si validation interne échoue, afficher l'erreur interne
|
|
85
|
+
// Sinon, préserver l'erreur RHF du prop propError
|
|
86
|
+
var finalError = errorMessage || propError || "";
|
|
87
|
+
setError(finalError);
|
|
86
88
|
setIsTouched(true);
|
|
87
|
-
// console.log(
|
|
88
|
-
// `Input ${title}: Validation result - ${errorMessage ? "invalid" : "valid"}`
|
|
89
|
-
// );
|
|
90
89
|
onError === null || onError === void 0 ? void 0 : onError(errorMessage);
|
|
90
|
+
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] validateInput APR\u00C8S setError, error state will be:"), finalError);
|
|
91
91
|
return !errorMessage;
|
|
92
|
-
}, [isRequired, value, validate, onError]);
|
|
92
|
+
}, [isRequired, value, validate, onError, propError, title]);
|
|
93
93
|
// Forcer la validation quand forceShowErrors devient true
|
|
94
94
|
useEffect(function () {
|
|
95
95
|
if (forceShowErrors) {
|