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