@rsuci/shared-form-components 1.0.127 → 1.0.128
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.
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Composant ExtraitInput - Saisie d'Extrait de Naissance
|
|
3
3
|
* RSU v2 - Moteur de Rendu des Formulaires d'Enquête
|
|
4
4
|
*
|
|
5
|
-
* Format composé : numéro (
|
|
6
|
-
* Exemple affiché : "
|
|
5
|
+
* Format composé : numéro (1 à 4 chiffres) + date d'établissement + année registre (4 chiffres)
|
|
6
|
+
* Exemple affiché : "1000 du 12/12/2020 du registre 2020"
|
|
7
7
|
* Stockage : JSON { numero, dateEtablissement, anneeRegistre }
|
|
8
8
|
*/
|
|
9
9
|
'use client';
|
|
@@ -71,7 +71,7 @@ const ExtraitInput = ({ variable, value, onChange, onBlur, error, disabled, isCo
|
|
|
71
71
|
onChange(JSON.stringify(newData));
|
|
72
72
|
}, [onChange]);
|
|
73
73
|
const handleNumeroChange = useCallback((e) => {
|
|
74
|
-
const digitsOnly = e.target.value.replace(/\D/g, '').slice(0,
|
|
74
|
+
const digitsOnly = e.target.value.replace(/\D/g, '').slice(0, 4);
|
|
75
75
|
updateValue({ ...data, numero: digitsOnly });
|
|
76
76
|
}, [data, updateValue]);
|
|
77
77
|
const handleDateChange = useCallback((e) => {
|
|
@@ -83,9 +83,6 @@ const ExtraitInput = ({ variable, value, onChange, onBlur, error, disabled, isCo
|
|
|
83
83
|
}, [data, updateValue]);
|
|
84
84
|
const handleBlur = useCallback(() => {
|
|
85
85
|
const errors = [];
|
|
86
|
-
if (data.numero && data.numero.length !== 3) {
|
|
87
|
-
errors.push('Le numéro doit contenir 3 chiffres');
|
|
88
|
-
}
|
|
89
86
|
if (data.anneeRegistre && data.anneeRegistre.length !== 4) {
|
|
90
87
|
errors.push("L'année du registre doit contenir 4 chiffres");
|
|
91
88
|
}
|
|
@@ -110,6 +107,6 @@ const ExtraitInput = ({ variable, value, onChange, onBlur, error, disabled, isCo
|
|
|
110
107
|
};
|
|
111
108
|
const displayError = error || localError;
|
|
112
109
|
const formattedValue = formatDisplayValue(data);
|
|
113
|
-
return (_jsxs("div", { style: containerStyle, className: "space-y-3", children: [_jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Num\u00E9ro" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.numero, onChange: handleNumeroChange, onBlur: handleBlur, placeholder: disabled ? '' : '
|
|
110
|
+
return (_jsxs("div", { style: containerStyle, className: "space-y-3", children: [_jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Num\u00E9ro" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.numero, onChange: handleNumeroChange, onBlur: handleBlur, placeholder: disabled ? '' : '1000', disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full font-mono`, maxLength: 4, autoComplete: "off" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Date d'\u00E9tablissement" }), _jsx("input", { type: "date", value: data.dateEtablissement, onChange: handleDateChange, onBlur: handleBlur, disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full`, max: new Date().toISOString().split('T')[0] })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Ann\u00E9e du registre" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.anneeRegistre, onChange: handleAnneeChange, onBlur: handleBlur, placeholder: disabled ? '' : '2020', disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full font-mono`, maxLength: 4, autoComplete: "off" })] })] }), formattedValue && (_jsx("div", { className: "p-2 bg-blue-50 border border-blue-200 rounded-lg", children: _jsxs("p", { className: "text-sm text-blue-800", children: [_jsx("span", { className: "font-medium", children: "Valeur :" }), " ", formattedValue] }) })), displayError && (_jsx("p", { className: "text-sm text-red-500", children: displayError }))] }));
|
|
114
111
|
};
|
|
115
112
|
export default ExtraitInput;
|
package/package.json
CHANGED