grevlingui 0.1.29 → 0.1.32
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.
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
.numberSelect {
|
|
4
4
|
position: relative;
|
|
5
|
+
z-index: 2;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.numberSelect_editing {
|
|
8
|
-
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.numberSelect_doneClosing {
|
|
12
|
+
z-index: 1;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
.numberSelect_value {
|
|
@@ -19,7 +23,8 @@
|
|
|
19
23
|
|
|
20
24
|
.numberSelect_input {
|
|
21
25
|
opacity: 1;
|
|
22
|
-
|
|
26
|
+
z-index: 1;
|
|
27
|
+
transition: opacity 200ms linear;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
.numberSelect_input-hidden {
|
|
@@ -30,10 +35,26 @@
|
|
|
30
35
|
.numberSelect_increment {
|
|
31
36
|
border-radius: 100%;
|
|
32
37
|
position: absolute;
|
|
33
|
-
z-index:
|
|
38
|
+
z-index: 2;
|
|
39
|
+
transition: top 200ms linear, bottom 200ms linear;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
.numberSelect_blur {
|
|
37
43
|
position: absolute;
|
|
44
|
+
pointer-events: none;
|
|
38
45
|
z-index: 1;
|
|
39
|
-
|
|
46
|
+
opacity: 1;
|
|
47
|
+
transition: opacity 200ms linear;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.numberSelect_input-hidden .numberSelect_blur {
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.numberSelect_add svg path {
|
|
55
|
+
translate: 0 -2rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.numberSelect_subtract svg path {
|
|
59
|
+
translate: 0 2rem;
|
|
60
|
+
}
|
|
@@ -36,7 +36,9 @@ const NumberSelect = _ref => {
|
|
|
36
36
|
closed
|
|
37
37
|
} = _ref;
|
|
38
38
|
const [editing, setEditing] = (0, _react.useState)(false);
|
|
39
|
+
const [doneClosing, setDoneClosing] = (0, _react.useState)(true);
|
|
39
40
|
const [closeTimeout, setCloseTimeout] = (0, _react.useState)();
|
|
41
|
+
const [doneClosingTimeout, setDoneClosingTimeout] = (0, _react.useState)();
|
|
40
42
|
(0, _react.useEffect)(() => {
|
|
41
43
|
if (closed) close();
|
|
42
44
|
}, [closed]);
|
|
@@ -45,14 +47,23 @@ const NumberSelect = _ref => {
|
|
|
45
47
|
clearTimeout(closeTimeout);
|
|
46
48
|
setEditing(false);
|
|
47
49
|
setCloseTimeout(undefined);
|
|
50
|
+
startDoneClosingTimeout();
|
|
48
51
|
};
|
|
49
52
|
|
|
50
|
-
const
|
|
53
|
+
const startCloseTimeout = () => {
|
|
51
54
|
if (!timeout) return;
|
|
52
55
|
clearTimeout(closeTimeout);
|
|
53
56
|
setCloseTimeout(setTimeout(close, timeout));
|
|
54
57
|
};
|
|
55
58
|
|
|
59
|
+
const startDoneClosingTimeout = () => {
|
|
60
|
+
clearTimeout(doneClosingTimeout);
|
|
61
|
+
setDoneClosingTimeout(setTimeout(() => {
|
|
62
|
+
setDoneClosing(true);
|
|
63
|
+
setDoneClosingTimeout(undefined);
|
|
64
|
+
}, 200));
|
|
65
|
+
};
|
|
66
|
+
|
|
56
67
|
const fullSize = "".concat(size, "rem");
|
|
57
68
|
const incrementorSize = "".concat(size * .8, "rem");
|
|
58
69
|
const incrementorVerticalOffset = "-".concat(size * .9, "rem");
|
|
@@ -67,11 +78,11 @@ const NumberSelect = _ref => {
|
|
|
67
78
|
};
|
|
68
79
|
|
|
69
80
|
const addStyle = _objectSpread(_objectSpread({}, incrementorStyle), {}, {
|
|
70
|
-
top: incrementorVerticalOffset
|
|
81
|
+
top: editing ? incrementorVerticalOffset : 0
|
|
71
82
|
});
|
|
72
83
|
|
|
73
84
|
const subtractStyle = _objectSpread(_objectSpread({}, incrementorStyle), {}, {
|
|
74
|
-
bottom: incrementorVerticalOffset
|
|
85
|
+
bottom: editing ? incrementorVerticalOffset : 0
|
|
75
86
|
});
|
|
76
87
|
|
|
77
88
|
const blurStyle = {
|
|
@@ -93,7 +104,7 @@ const NumberSelect = _ref => {
|
|
|
93
104
|
}));
|
|
94
105
|
|
|
95
106
|
const increment = change => () => {
|
|
96
|
-
|
|
107
|
+
startCloseTimeout();
|
|
97
108
|
const nv = change + value;
|
|
98
109
|
if (nv > max || nv < min) return;
|
|
99
110
|
setValue(nv);
|
|
@@ -102,7 +113,7 @@ const NumberSelect = _ref => {
|
|
|
102
113
|
const renderInputs = () => /*#__PURE__*/_react.default.createElement("div", {
|
|
103
114
|
className: "numberSelect_input ".concat(editing ? '' : 'numberSelect_input-hidden')
|
|
104
115
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
105
|
-
className:
|
|
116
|
+
className: 'numberSelect_increment numberSelect_add',
|
|
106
117
|
style: addStyle,
|
|
107
118
|
onClick: increment(1)
|
|
108
119
|
}, icon(true)), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -115,16 +126,18 @@ const NumberSelect = _ref => {
|
|
|
115
126
|
}, icon()));
|
|
116
127
|
|
|
117
128
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
-
className: "numberSelect"
|
|
129
|
+
className: "numberSelect ".concat(editing ? 'numberSelect_editing' : '', " ").concat(doneClosing ? 'numberSelect_doneClosing' : '')
|
|
119
130
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
120
131
|
className: "numberSelect_value",
|
|
121
132
|
onClick: () => {
|
|
122
133
|
if (!editing) {
|
|
123
|
-
|
|
134
|
+
startCloseTimeout();
|
|
124
135
|
onOpenInput === null || onOpenInput === void 0 ? void 0 : onOpenInput();
|
|
136
|
+
setDoneClosing(false);
|
|
137
|
+
setEditing(true);
|
|
138
|
+
} else {
|
|
139
|
+
close();
|
|
125
140
|
}
|
|
126
|
-
|
|
127
|
-
setEditing(!editing);
|
|
128
141
|
},
|
|
129
142
|
style: {
|
|
130
143
|
height: fullSize,
|