@dartech/arsenal-ui 1.3.52 → 1.3.54
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/index.js +5 -3
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1847,7 +1847,7 @@ const ControlNumberInput = _a => {
|
|
1847
1847
|
hideErrorMessage = false,
|
1848
1848
|
onChange: customOnChange,
|
1849
1849
|
decimal = false,
|
1850
|
-
valueAsNumber
|
1850
|
+
valueAsNumber = true
|
1851
1851
|
} = _a,
|
1852
1852
|
textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "decimal", "valueAsNumber"]);
|
1853
1853
|
const {
|
@@ -1866,7 +1866,7 @@ const ControlNumberInput = _a => {
|
|
1866
1866
|
required: required && 'Please, fill this field',
|
1867
1867
|
validate: val => {
|
1868
1868
|
if (val === null) return true;
|
1869
|
-
if (decimal && !floatsOnly.test(val)) {
|
1869
|
+
if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
|
1870
1870
|
return 'Not valid number';
|
1871
1871
|
} else if (!decimal && !digitsOnly.test(val)) {
|
1872
1872
|
return 'Not valid integer';
|
@@ -1893,12 +1893,14 @@ const ControlNumberInput = _a => {
|
|
1893
1893
|
onChange(0);
|
1894
1894
|
} else if (decimal) {
|
1895
1895
|
const dec = event.target.value.split('.')[1];
|
1896
|
-
onChange(!floatsOnly.test(event.target.value) || /^0+$/.test(dec) ? event.target.value : +parseFloat(event.target.value).toFixed((_a = dec === null || dec === void 0 ? void 0 : dec.length) !== null && _a !== void 0 ? _a : 0));
|
1896
|
+
onChange(!floatsOnly.test(event.target.value) || /^0+$/.test(dec) || /^-*0+$/.test(event.target.value) ? event.target.value : +parseFloat(event.target.value).toFixed((_a = dec === null || dec === void 0 ? void 0 : dec.length) !== null && _a !== void 0 ? _a : 0));
|
1897
1897
|
} else {
|
1898
1898
|
onChange(Number.isNaN(+event.target.value) ? event.target.value : +event.target.value);
|
1899
1899
|
}
|
1900
1900
|
}
|
1901
1901
|
}
|
1902
|
+
} else {
|
1903
|
+
onChange(event.target.value);
|
1902
1904
|
}
|
1903
1905
|
};
|
1904
1906
|
return jsx(TextField, Object.assign({
|