allaw-ui 5.3.2 → 5.3.4
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.
|
@@ -63,12 +63,10 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
63
63
|
setValue(propValue || "");
|
|
64
64
|
}, [propValue]);
|
|
65
65
|
useEffect(function () {
|
|
66
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] error prop received:"), propError || "");
|
|
67
66
|
setError(propError || "");
|
|
68
67
|
}, [propError, title]);
|
|
69
68
|
var validateInput = useCallback(function () {
|
|
70
69
|
var _a;
|
|
71
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] validateInput called, propError:"), propError);
|
|
72
70
|
var currentValue = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) || value;
|
|
73
71
|
var errorMessage = "";
|
|
74
72
|
if (isRequired && currentValue.trim() === "") {
|
|
@@ -80,13 +78,14 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
80
78
|
errorMessage = "Veuillez vérifier votre saisie";
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
// Si validation interne échoue, afficher l'erreur interne
|
|
82
|
+
// Sinon, préserver l'erreur RHF du prop propError
|
|
83
|
+
var finalError = errorMessage || propError || "";
|
|
84
|
+
setError(finalError);
|
|
85
85
|
setIsTouched(true);
|
|
86
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);
|
|
88
87
|
return !errorMessage;
|
|
89
|
-
}, [isRequired, value, validate, onError, propError
|
|
88
|
+
}, [isRequired, value, validate, onError, propError]);
|
|
90
89
|
// Forcer la validation quand forceShowErrors devient true
|
|
91
90
|
useEffect(function () {
|
|
92
91
|
if (forceShowErrors) {
|
|
@@ -96,11 +95,9 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
96
95
|
useImperativeHandle(ref, function () { return ({
|
|
97
96
|
validate: validateInput,
|
|
98
97
|
setTouched: function (touched) {
|
|
99
|
-
console.log("[Input] setTouched(".concat(touched, ")"));
|
|
100
98
|
setIsTouched(touched);
|
|
101
99
|
},
|
|
102
100
|
showError: function (message) {
|
|
103
|
-
console.log("[Input] showError(\"".concat(message, "\")"));
|
|
104
101
|
setError(message);
|
|
105
102
|
setIsTouched(true);
|
|
106
103
|
},
|
|
@@ -118,17 +115,14 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
118
115
|
return __generator(this, function (_a) {
|
|
119
116
|
switch (_a.label) {
|
|
120
117
|
case 0:
|
|
121
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] blur event detected"));
|
|
122
118
|
// Marquer le champ comme touché
|
|
123
119
|
setIsTouched(true);
|
|
124
120
|
// Valider en interne d'abord
|
|
125
121
|
validateInput();
|
|
126
122
|
if (!onBlur) return [3 /*break*/, 2];
|
|
127
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] Calling onBlur callback"));
|
|
128
123
|
return [4 /*yield*/, onBlur()];
|
|
129
124
|
case 1:
|
|
130
125
|
_a.sent();
|
|
131
|
-
console.log("[Input".concat(title ? " \"".concat(title, "\"") : "", "] onBlur callback completed, re-validating to display error"));
|
|
132
126
|
// RE-VALIDER après que onBlur ait mis à jour le prop error
|
|
133
127
|
// Cela force le re-render avec l'erreur RHF visible
|
|
134
128
|
validateInput();
|