@momo-kits/stepper 0.0.18-beta-2 → 0.0.18-beta-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.
- package/Stepper.js +18 -22
- package/package.json +1 -1
package/Stepper.js
CHANGED
|
@@ -150,26 +150,22 @@ export default class Quantity extends Component {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
setValue = (newValue = 0, type) => {
|
|
153
|
-
const {
|
|
154
|
-
|
|
155
|
-
this.setState(
|
|
156
|
-
{
|
|
157
|
-
value: newValue,
|
|
158
|
-
ownUpdate: true,
|
|
159
|
-
},
|
|
160
|
-
() => {
|
|
161
|
-
this.onChangeValue(newValue, type);
|
|
162
|
-
},
|
|
163
|
-
);
|
|
164
|
-
};
|
|
153
|
+
const {isIncreaseValue, max, min} = this.props;
|
|
154
|
+
let tempValue = newValue;
|
|
165
155
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
156
|
+
tempValue = newValue < min ? min : tempValue;
|
|
157
|
+
tempValue = newValue > max ? max : tempValue;
|
|
158
|
+
if (newValue === '') tempValue = '';
|
|
159
|
+
|
|
160
|
+
this.setState(
|
|
161
|
+
{
|
|
162
|
+
value: tempValue,
|
|
163
|
+
ownUpdate: true,
|
|
164
|
+
},
|
|
165
|
+
() => {
|
|
166
|
+
this.onChangeValue(newValue, type);
|
|
167
|
+
},
|
|
168
|
+
);
|
|
173
169
|
};
|
|
174
170
|
|
|
175
171
|
onPress =
|
|
@@ -178,10 +174,10 @@ export default class Quantity extends Component {
|
|
|
178
174
|
const {isChangeValue, onConditionCheck} = this.props;
|
|
179
175
|
const {value} = this.state;
|
|
180
176
|
const type = isIncrease ? 'increase' : 'decrease';
|
|
181
|
-
if (isChangeValue) {
|
|
177
|
+
if (isChangeValue && value !== '') {
|
|
182
178
|
const newValue = isIncrease
|
|
183
|
-
? value + this.getValue('increase', step)
|
|
184
|
-
: value - this.getValue('decrease', step);
|
|
179
|
+
? parseInt(value) + this.getValue('increase', step)
|
|
180
|
+
: parseInt(value) - this.getValue('decrease', step);
|
|
185
181
|
if (typeof onConditionCheck === 'function') {
|
|
186
182
|
const passCondition = onConditionCheck(newValue, type);
|
|
187
183
|
if (passCondition) {
|