allaw-ui 5.2.7 → 5.2.8
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.
|
@@ -27,6 +27,18 @@ export interface InputProps {
|
|
|
27
27
|
}
|
|
28
28
|
export interface InputRef {
|
|
29
29
|
validate: () => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Force l'état isTouched du composant.
|
|
32
|
+
* Utile pour synchroniser avec des systèmes de validation externes (ex: React Hook Form).
|
|
33
|
+
* @param isTouched - true pour marquer le champ comme touché, false sinon
|
|
34
|
+
*/
|
|
35
|
+
setTouched: (isTouched: boolean) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Force l'affichage d'une erreur spécifique et marque le champ comme touché.
|
|
38
|
+
* Utile pour afficher des erreurs de validation externe (ex: React Hook Form).
|
|
39
|
+
* @param message - Le message d'erreur à afficher. Passer une chaîne vide pour effacer l'erreur.
|
|
40
|
+
*/
|
|
41
|
+
showError: (message: string) => void;
|
|
30
42
|
}
|
|
31
43
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
|
|
32
44
|
export default Input;
|
|
@@ -52,9 +52,18 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
52
52
|
// );
|
|
53
53
|
onError === null || onError === void 0 ? void 0 : onError(errorMessage);
|
|
54
54
|
return !errorMessage;
|
|
55
|
-
}, [isRequired, value, validate, onError
|
|
55
|
+
}, [isRequired, value, validate, onError]);
|
|
56
56
|
useImperativeHandle(ref, function () { return ({
|
|
57
57
|
validate: validateInput,
|
|
58
|
+
setTouched: function (touched) {
|
|
59
|
+
console.log("[Input] setTouched(".concat(touched, ")"));
|
|
60
|
+
setIsTouched(touched);
|
|
61
|
+
},
|
|
62
|
+
showError: function (message) {
|
|
63
|
+
console.log("[Input] showError(\"".concat(message, "\")"));
|
|
64
|
+
setError(message);
|
|
65
|
+
setIsTouched(true);
|
|
66
|
+
},
|
|
58
67
|
}); });
|
|
59
68
|
var handleChange = function (e) {
|
|
60
69
|
var newValue = e.target.value;
|