@rsuci/shared-form-components 1.0.69 → 1.0.71
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.
- package/dist/components/inputs/NumberInput.d.ts.map +1 -1
- package/dist/components/inputs/NumberInput.js +15 -5
- package/dist/components/inputs/RadioInput.js +1 -1
- package/dist/components/inputs/SelectInput.js +2 -2
- package/dist/components/selectors/EnqueteInput.js +2 -2
- package/dist/components/selectors/MenageInput.js +2 -2
- package/dist/components/selectors/RSUInput.js +2 -2
- package/dist/lib/utils/variableValueConverter.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/NumberInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,WAAW,CAAA;KAAE,CAAC;IACzD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/NumberInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,WAAW,CAAA;KAAE,CAAC;IACzD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsF3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { applyComponentStyle } from '../../utils/styleUtils';
|
|
|
8
8
|
import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
|
|
9
9
|
const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeurMin, isConsultationMode = false }) => {
|
|
10
10
|
const props = variable.proprietes;
|
|
11
|
-
const numericValue = value !== null && value !== undefined ? value :
|
|
11
|
+
const numericValue = value !== null && value !== undefined ? value : 0;
|
|
12
12
|
const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
|
|
13
13
|
// Déterminer si le composant est en lecture seule
|
|
14
14
|
const isReadonly = isComponentReadonly(variable, isConsultationMode);
|
|
@@ -26,12 +26,22 @@ const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeu
|
|
|
26
26
|
return;
|
|
27
27
|
const inputValue = e.target.value;
|
|
28
28
|
if (inputValue === '') {
|
|
29
|
-
onChange(
|
|
29
|
+
onChange(0);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const parsedValue = parseFloat(inputValue);
|
|
33
|
+
// NaN -> 0
|
|
34
|
+
if (isNaN(parsedValue)) {
|
|
35
|
+
onChange(0);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Pas de nombre negatif
|
|
39
|
+
if (parsedValue < 0) {
|
|
40
|
+
onChange(0);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
33
43
|
// Vérifier la contrainte de valeur minimale pour la saisie directe
|
|
34
|
-
if (effectiveMin !== undefined &&
|
|
44
|
+
if (effectiveMin !== undefined && parsedValue < effectiveMin) {
|
|
35
45
|
console.log('NumberInput - Valeur saisie inférieure au minimum:', {
|
|
36
46
|
variableCode: variable.code,
|
|
37
47
|
saisie: parsedValue,
|
|
@@ -42,7 +52,7 @@ const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeu
|
|
|
42
52
|
onChange(effectiveMin);
|
|
43
53
|
return;
|
|
44
54
|
}
|
|
45
|
-
onChange(
|
|
55
|
+
onChange(parsedValue);
|
|
46
56
|
};
|
|
47
57
|
// Générer les classes CSS
|
|
48
58
|
const getInputClasses = () => {
|
|
@@ -54,6 +64,6 @@ const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeu
|
|
|
54
64
|
return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
|
|
55
65
|
return `${baseClasses} ${errorClasses} bg-white`;
|
|
56
66
|
};
|
|
57
|
-
return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "number", value: numericValue, onChange: handleChange, onBlur: onBlur, min: effectiveMin, max: props?.max, step: props?.step || 1, disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
|
|
67
|
+
return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "number", value: numericValue, onChange: handleChange, onBlur: onBlur, min: effectiveMin !== undefined ? effectiveMin : 0, max: props?.max, step: props?.step || 1, disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
|
|
58
68
|
};
|
|
59
69
|
export default NumberInput;
|
|
@@ -20,6 +20,6 @@ const RadioInput = ({ variable, value, onChange, onBlur, error, disabled, isCons
|
|
|
20
20
|
const handleChange = (selectedValue) => {
|
|
21
21
|
onChange(selectedValue || null);
|
|
22
22
|
};
|
|
23
|
-
return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx("div", { className: "space-y-2", children: options.map((option) => (_jsxs("label", { className: `flex items-center space-x-3 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}`, children: [_jsx("input", { type: "radio", name: `radio-${variable.code}`, value: option.code, checked: value === option.code, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, disabled: effectiveDisabled, className: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 disabled:opacity-50" }),
|
|
23
|
+
return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx("div", { className: "space-y-2", children: options.map((option) => (_jsxs("label", { className: `flex items-center space-x-3 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}`, children: [_jsx("input", { type: "radio", name: `radio-${variable.code}`, value: option.code, checked: value === option.code, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, disabled: effectiveDisabled, className: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 disabled:opacity-50" }), _jsx("span", { className: `text-sm ${effectiveDisabled ? 'text-gray-400' : 'text-gray-900'}`, style: textStyle, children: option.designation })] }, option.code))) }), options.length === 0 && (_jsx("p", { className: "text-sm text-gray-500", children: "Aucune option disponible" })), error && (_jsx("p", { className: "text-sm text-red-600", children: error }))] }));
|
|
24
24
|
};
|
|
25
25
|
export default RadioInput;
|
|
@@ -40,9 +40,9 @@ const SelectInput = ({ variable, value, onChange, onBlur, error, disabled, isCon
|
|
|
40
40
|
if (onBlur)
|
|
41
41
|
onBlur();
|
|
42
42
|
};
|
|
43
|
-
// Format d'affichage:
|
|
43
|
+
// Format d'affichage: Designation uniquement
|
|
44
44
|
const formatOptionLabel = (option) => {
|
|
45
|
-
return
|
|
45
|
+
return option.designation;
|
|
46
46
|
};
|
|
47
47
|
// Affichage avec SearchableSelect pour beaucoup d'options (>5)
|
|
48
48
|
return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx(SearchableSelect, { options: selectOptions, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner...", searchPlaceholder: "Rechercher...", disabled: effectiveDisabled, required: variable.estObligatoire, error: error, formatOptionLabel: formatOptionLabel, noOptionsMessage: "Aucune option trouv\u00E9e" }), selectedValue && selectedOption && (_jsx("div", { className: "p-2 bg-green-50 border border-green-200 rounded text-sm", children: _jsxs("span", { className: "text-green-800", style: textStyle, children: ["S\u00E9lectionn\u00E9: ", selectedOption.designation] }) }))] }));
|
|
@@ -46,9 +46,9 @@ const EnqueteInput = ({ variable, value, onChange, error, disabled, onFillFormFr
|
|
|
46
46
|
// pour éviter les re-renders et la création d'une nouvelle enquête.
|
|
47
47
|
// Il doit être appelé manuellement si nécessaire (bouton séparé).
|
|
48
48
|
};
|
|
49
|
-
// Format d'affichage:
|
|
49
|
+
// Format d'affichage: Designation uniquement
|
|
50
50
|
const formatOptionLabel = (option) => {
|
|
51
|
-
return
|
|
51
|
+
return option.designation;
|
|
52
52
|
};
|
|
53
53
|
return (_jsx(SearchableSelect, { options: options, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner une enqu\u00EAte...", searchPlaceholder: "Rechercher une enqu\u00EAte...", disabled: disabled, required: variable.estObligatoire, loading: loading, error: loadError || error, formatOptionLabel: formatOptionLabel, noOptionsMessage: loading ? "Chargement..." : "Aucune enquête trouvée" }));
|
|
54
54
|
};
|
|
@@ -46,9 +46,9 @@ const MenageInput = ({ variable, value, onChange, error, disabled, onFillFormFro
|
|
|
46
46
|
// pour éviter les re-renders et la création d'une nouvelle enquête.
|
|
47
47
|
// Il doit être appelé manuellement si nécessaire (bouton séparé).
|
|
48
48
|
};
|
|
49
|
-
// Format d'affichage:
|
|
49
|
+
// Format d'affichage: Designation uniquement
|
|
50
50
|
const formatOptionLabel = (option) => {
|
|
51
|
-
return
|
|
51
|
+
return option.designation;
|
|
52
52
|
};
|
|
53
53
|
return (_jsx(SearchableSelect, { options: options, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner un m\u00E9nage...", searchPlaceholder: "Rechercher un m\u00E9nage...", disabled: disabled, required: variable.estObligatoire, loading: loading, error: loadError || error, formatOptionLabel: formatOptionLabel, noOptionsMessage: loading ? "Chargement..." : "Aucun ménage trouvé" }));
|
|
54
54
|
};
|
|
@@ -43,9 +43,9 @@ const RSUInput = ({ variable, value, onChange, error, disabled, services }) => {
|
|
|
43
43
|
const newStructureId = option?.id;
|
|
44
44
|
onChange(newStructureId?.toString() || null);
|
|
45
45
|
};
|
|
46
|
-
// Format d'affichage:
|
|
46
|
+
// Format d'affichage: Designation uniquement
|
|
47
47
|
const formatOptionLabel = (option) => {
|
|
48
|
-
return
|
|
48
|
+
return option.designation;
|
|
49
49
|
};
|
|
50
50
|
return (_jsx(SearchableSelect, { options: options, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner une structure RSU...", searchPlaceholder: "Rechercher une structure...", disabled: disabled, required: variable.estObligatoire, loading: loading, error: loadError || error, formatOptionLabel: formatOptionLabel, noOptionsMessage: loading ? "Chargement..." : "Aucune structure trouvée" }));
|
|
51
51
|
};
|
|
@@ -407,7 +407,7 @@ export class VariableValueConverter {
|
|
|
407
407
|
static optionsToSelectFormat(options) {
|
|
408
408
|
return options.map(option => ({
|
|
409
409
|
value: option.code,
|
|
410
|
-
label:
|
|
410
|
+
label: option.designation,
|
|
411
411
|
disabled: false
|
|
412
412
|
}));
|
|
413
413
|
}
|
package/package.json
CHANGED