colibri-ui 0.8.12 → 0.8.14
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/Counter/index.js +12 -9
- package/esm/Counter/index.js +13 -10
- package/package.json +1 -1
package/Counter/index.js
CHANGED
|
@@ -26,9 +26,14 @@ var Counter = function Counter(_a) {
|
|
|
26
26
|
onChange = _a.onChange,
|
|
27
27
|
disabled = _a.disabled,
|
|
28
28
|
className = _a.className;
|
|
29
|
-
var lastNumValue = React.useRef(value);
|
|
30
29
|
var minusDisabled = disabled || value <= min;
|
|
31
30
|
var plusDisabled = disabled || value >= max;
|
|
31
|
+
var handleChange = function handleChange(delta) {
|
|
32
|
+
if (disabled) return;
|
|
33
|
+
var newValue = value + delta;
|
|
34
|
+
if (newValue < min || newValue > max) return;
|
|
35
|
+
onChange(newValue);
|
|
36
|
+
};
|
|
32
37
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
33
38
|
className: clx(styles__default.default.root, {
|
|
34
39
|
root_fullWidth: fullWidth ? 1 : 0
|
|
@@ -44,10 +49,9 @@ var Counter = function Counter(_a) {
|
|
|
44
49
|
}),
|
|
45
50
|
disabled: minusDisabled,
|
|
46
51
|
type: "button",
|
|
47
|
-
onClick: function onClick(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
lastNumValue.current = value - 1;
|
|
52
|
+
onClick: function onClick(event) {
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
handleChange(-1);
|
|
51
55
|
},
|
|
52
56
|
"aria-label": "decrease"
|
|
53
57
|
}), /*#__PURE__*/React__default.default.createElement("div", {
|
|
@@ -59,10 +63,9 @@ var Counter = function Counter(_a) {
|
|
|
59
63
|
}),
|
|
60
64
|
disabled: plusDisabled,
|
|
61
65
|
type: "button",
|
|
62
|
-
onClick: function onClick(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
lastNumValue.current = value + 1;
|
|
66
|
+
onClick: function onClick(event) {
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
handleChange(1);
|
|
66
69
|
},
|
|
67
70
|
"aria-label": "increase"
|
|
68
71
|
})));
|
package/esm/Counter/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import classNames from 'classnames/bind';
|
|
3
3
|
import Button from '../Button/index.js';
|
|
4
4
|
import MinusIcon from '../Icons/Minus.js';
|
|
@@ -16,9 +16,14 @@ var Counter = function Counter(_a) {
|
|
|
16
16
|
onChange = _a.onChange,
|
|
17
17
|
disabled = _a.disabled,
|
|
18
18
|
className = _a.className;
|
|
19
|
-
var lastNumValue = useRef(value);
|
|
20
19
|
var minusDisabled = disabled || value <= min;
|
|
21
20
|
var plusDisabled = disabled || value >= max;
|
|
21
|
+
var handleChange = function handleChange(delta) {
|
|
22
|
+
if (disabled) return;
|
|
23
|
+
var newValue = value + delta;
|
|
24
|
+
if (newValue < min || newValue > max) return;
|
|
25
|
+
onChange(newValue);
|
|
26
|
+
};
|
|
22
27
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
23
28
|
className: clx(styles.root, {
|
|
24
29
|
root_fullWidth: fullWidth ? 1 : 0
|
|
@@ -34,10 +39,9 @@ var Counter = function Counter(_a) {
|
|
|
34
39
|
}),
|
|
35
40
|
disabled: minusDisabled,
|
|
36
41
|
type: "button",
|
|
37
|
-
onClick: function onClick(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
lastNumValue.current = value - 1;
|
|
42
|
+
onClick: function onClick(event) {
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
handleChange(-1);
|
|
41
45
|
},
|
|
42
46
|
"aria-label": "decrease"
|
|
43
47
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -49,10 +53,9 @@ var Counter = function Counter(_a) {
|
|
|
49
53
|
}),
|
|
50
54
|
disabled: plusDisabled,
|
|
51
55
|
type: "button",
|
|
52
|
-
onClick: function onClick(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
lastNumValue.current = value + 1;
|
|
56
|
+
onClick: function onClick(event) {
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
handleChange(1);
|
|
56
59
|
},
|
|
57
60
|
"aria-label": "increase"
|
|
58
61
|
})));
|