allaw-ui 5.3.0 → 5.3.2
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,25 @@ 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
|
+
setError(errorMessage); // ← C'EST ICI! Tu écrase propError!
|
|
86
85
|
setIsTouched(true);
|
|
87
|
-
// console.log(
|
|
88
|
-
// `Input ${title}: Validation result - ${errorMessage ? "invalid" : "valid"}`
|
|
89
|
-
// );
|
|
90
86
|
onError === null || onError === void 0 ? void 0 : onError(errorMessage);
|
|
87
|
+
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] validateInput APR\u00C8S setError, error state will be:"), errorMessage);
|
|
91
88
|
return !errorMessage;
|
|
92
|
-
}, [isRequired, value, validate, onError]);
|
|
89
|
+
}, [isRequired, value, validate, onError, propError, title]);
|
|
93
90
|
// Forcer la validation quand forceShowErrors devient true
|
|
94
91
|
useEffect(function () {
|
|
95
92
|
if (forceShowErrors) {
|
|
@@ -127,11 +124,14 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
127
124
|
// Valider en interne d'abord
|
|
128
125
|
validateInput();
|
|
129
126
|
if (!onBlur) return [3 /*break*/, 2];
|
|
130
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "]
|
|
127
|
+
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] Calling onBlur callback"));
|
|
131
128
|
return [4 /*yield*/, onBlur()];
|
|
132
129
|
case 1:
|
|
133
130
|
_a.sent();
|
|
134
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] onBlur callback completed"));
|
|
131
|
+
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] onBlur callback completed, re-validating to display error"));
|
|
132
|
+
// RE-VALIDER après que onBlur ait mis à jour le prop error
|
|
133
|
+
// Cela force le re-render avec l'erreur RHF visible
|
|
134
|
+
validateInput();
|
|
135
135
|
_a.label = 2;
|
|
136
136
|
case 2: return [2 /*return*/];
|
|
137
137
|
}
|