venice-ui 2.3.4 → 2.3.6

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,20 +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)(() => { setInputValue(value); }, [value]);
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
- };
49
- }, []);
50
48
  const onChange = (e) => {
51
49
  let returnedValue = type === 'number' || type === 'increase'
52
50
  ? calculateNumberValue(e.target.value)
@@ -72,9 +70,13 @@ const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disab
72
70
  handleChange(name, validateValue);
73
71
  }
74
72
  };
75
- const onKeyDown = (e) => {
73
+ const onKeyDown = async (e) => {
76
74
  if (handleSubmit && e.key === 'Enter') {
77
- debouncedRef.current.flush();
75
+ debouncedRef.current.cancel();
76
+ const currentValue = type === 'number' || type === 'increase'
77
+ ? calculateNumberValue(e.currentTarget.value)
78
+ : e.currentTarget.value.toString();
79
+ handleChange(name, currentValue);
78
80
  handleSubmit();
79
81
  }
80
82
  };
@@ -7,20 +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(() => { setInputValue(value); }, [value]);
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
- };
23
- }, []);
24
22
  const onChange = (e) => {
25
23
  let returnedValue = type === 'number' || type === 'increase'
26
24
  ? calculateNumberValue(e.target.value)
@@ -46,9 +44,13 @@ export const Input = ({ label, labelPosition = 'top', value, type = 'text', name
46
44
  handleChange(name, validateValue);
47
45
  }
48
46
  };
49
- const onKeyDown = (e) => {
47
+ const onKeyDown = async (e) => {
50
48
  if (handleSubmit && e.key === 'Enter') {
51
- debouncedRef.current.flush();
49
+ debouncedRef.current.cancel();
50
+ const currentValue = type === 'number' || type === 'increase'
51
+ ? calculateNumberValue(e.currentTarget.value)
52
+ : e.currentTarget.value.toString();
53
+ handleChange(name, currentValue);
52
54
  handleSubmit();
53
55
  }
54
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venice-ui",
3
- "version": "2.3.4",
3
+ "version": "2.3.6",
4
4
  "description": "Component library",
5
5
  "main": "index.js",
6
6
  "module": "./dist/esm/index.js",