@openmrs/esm-form-engine-lib 3.1.3-pre.1754 → 3.1.3-pre.1757
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/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useCallback, useMemo
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
2
2
|
import { Layer, NumberInput } from '@carbon/react';
|
3
3
|
import classNames from 'classnames';
|
4
4
|
import { isTrue } from '../../../utils/boolean-utils';
|
@@ -13,7 +13,6 @@ import { isEmpty } from '../../../validators/form-validator';
|
|
13
13
|
|
14
14
|
const NumberField: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings, setFieldValue }) => {
|
15
15
|
const { t } = useTranslation();
|
16
|
-
const [lastBlurredValue, setLastBlurredValue] = useState(value);
|
17
16
|
const { layoutType, sessionMode, workspaceLayout } = useFormProviderContext();
|
18
17
|
|
19
18
|
const numberValue = useMemo(() => {
|
@@ -23,16 +22,9 @@ const NumberField: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
|
|
23
22
|
return value ?? '';
|
24
23
|
}, [value]);
|
25
24
|
|
26
|
-
const onBlur = (event) => {
|
27
|
-
event.preventDefault();
|
28
|
-
if (lastBlurredValue != value) {
|
29
|
-
setLastBlurredValue(value);
|
30
|
-
}
|
31
|
-
};
|
32
|
-
|
33
25
|
const handleChange = useCallback(
|
34
|
-
(event) => {
|
35
|
-
const parsedValue = isEmpty(
|
26
|
+
(event, { value }) => {
|
27
|
+
const parsedValue = isEmpty(value) ? undefined : Number(value);
|
36
28
|
setFieldValue(isNaN(parsedValue) ? undefined : parsedValue);
|
37
29
|
},
|
38
30
|
[setFieldValue],
|
@@ -67,11 +59,9 @@ const NumberField: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
|
|
67
59
|
name={field.id}
|
68
60
|
value={numberValue}
|
69
61
|
onChange={handleChange}
|
70
|
-
onBlur={onBlur}
|
71
62
|
allowEmpty={true}
|
72
63
|
size="lg"
|
73
64
|
hideSteppers={field.hideSteppers ?? false}
|
74
|
-
onWheel={(e) => e.target.blur()}
|
75
65
|
disabled={field.isDisabled}
|
76
66
|
readOnly={isTrue(field.readonly)}
|
77
67
|
className={classNames(styles.controlWidthConstrained, styles.boldedLabel)}
|