@rsuci/shared-form-components 1.0.69 → 1.0.70
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.
|
@@ -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;
|
package/package.json
CHANGED