venice-ui 2.3.3 → 2.3.5
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.
|
@@ -33,21 +33,18 @@ const Theme_1 = require("../../Theme");
|
|
|
33
33
|
const lodash_1 = require("lodash");
|
|
34
34
|
const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disabled = false, size = 'medium', handleChange, handleSubmit, width, error = false, errorMsg, placeholder, min, max, step = 0.1, autoFocus, theme = Theme_1.mainTheme, readOnly = false, prefix, }) => {
|
|
35
35
|
const [inputValue, setInputValue] = (0, react_1.useState)(value);
|
|
36
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
setInputValue(value);
|
|
38
|
+
}, [value]);
|
|
37
39
|
const calculateNumberValue = (numberValue) => {
|
|
38
40
|
return isNaN(parseFloat(numberValue))
|
|
39
41
|
? numberValue
|
|
40
42
|
: parseFloat(numberValue);
|
|
41
43
|
};
|
|
42
44
|
const debouncedRef = (0, react_1.useRef)((0, lodash_1.debounce)((n, v) => {
|
|
45
|
+
console.log('checking debounce', n, v);
|
|
43
46
|
handleChange(n, v);
|
|
44
47
|
}, 300));
|
|
45
|
-
(0, react_1.useEffect)(() => {
|
|
46
|
-
return () => {
|
|
47
|
-
debouncedRef.current.flush();
|
|
48
|
-
debouncedRef.current.cancel();
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
48
|
const onChange = (e) => {
|
|
52
49
|
let returnedValue = type === 'number' || type === 'increase'
|
|
53
50
|
? calculateNumberValue(e.target.value)
|
|
@@ -73,9 +70,9 @@ const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disab
|
|
|
73
70
|
handleChange(name, validateValue);
|
|
74
71
|
}
|
|
75
72
|
};
|
|
76
|
-
const onKeyDown = (e) => {
|
|
73
|
+
const onKeyDown = async (e) => {
|
|
77
74
|
if (handleSubmit && e.key === 'Enter') {
|
|
78
|
-
debouncedRef.current.flush();
|
|
75
|
+
await debouncedRef.current.flush();
|
|
79
76
|
handleSubmit();
|
|
80
77
|
}
|
|
81
78
|
};
|
|
@@ -7,21 +7,18 @@ import { mainTheme } from '../../Theme';
|
|
|
7
7
|
import { debounce } from 'lodash';
|
|
8
8
|
export const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disabled = false, size = 'medium', handleChange, handleSubmit, width, error = false, errorMsg, placeholder, min, max, step = 0.1, autoFocus, theme = mainTheme, readOnly = false, prefix, }) => {
|
|
9
9
|
const [inputValue, setInputValue] = useState(value);
|
|
10
|
-
useEffect(() => {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setInputValue(value);
|
|
12
|
+
}, [value]);
|
|
11
13
|
const calculateNumberValue = (numberValue) => {
|
|
12
14
|
return isNaN(parseFloat(numberValue))
|
|
13
15
|
? numberValue
|
|
14
16
|
: parseFloat(numberValue);
|
|
15
17
|
};
|
|
16
18
|
const debouncedRef = useRef(debounce((n, v) => {
|
|
19
|
+
console.log('checking debounce', n, v);
|
|
17
20
|
handleChange(n, v);
|
|
18
21
|
}, 300));
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
return () => {
|
|
21
|
-
debouncedRef.current.flush();
|
|
22
|
-
debouncedRef.current.cancel();
|
|
23
|
-
};
|
|
24
|
-
}, []);
|
|
25
22
|
const onChange = (e) => {
|
|
26
23
|
let returnedValue = type === 'number' || type === 'increase'
|
|
27
24
|
? calculateNumberValue(e.target.value)
|
|
@@ -47,9 +44,9 @@ export const Input = ({ label, labelPosition = 'top', value, type = 'text', name
|
|
|
47
44
|
handleChange(name, validateValue);
|
|
48
45
|
}
|
|
49
46
|
};
|
|
50
|
-
const onKeyDown = (e) => {
|
|
47
|
+
const onKeyDown = async (e) => {
|
|
51
48
|
if (handleSubmit && e.key === 'Enter') {
|
|
52
|
-
debouncedRef.current.flush();
|
|
49
|
+
await debouncedRef.current.flush();
|
|
53
50
|
handleSubmit();
|
|
54
51
|
}
|
|
55
52
|
};
|