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