|
|
@ -9,7 +9,7 @@ function parseValue(props, value) {
|
|
|
|
max
|
|
|
|
max
|
|
|
|
} = props;
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
|
|
if (value == null) {
|
|
|
|
if (value == null || value === '') {
|
|
|
|
return min;
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -33,14 +33,18 @@ class NumberInput extends Component {
|
|
|
|
super(props, context);
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
this.state = {
|
|
|
|
value: props.value.toString(),
|
|
|
|
value: props.value == null ? '' : props.value.toString(),
|
|
|
|
isFocused: false
|
|
|
|
isFocused: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
if (this.props.value !== prevProps.value && !this.state.isFocused) {
|
|
|
|
const { value } = this.props;
|
|
|
|
this.setState({ value: this.props.value.toString() });
|
|
|
|
|
|
|
|
|
|
|
|
if (value !== prevProps.value && !this.state.isFocused) {
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
value: value == null ? '' : value.toString()
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -69,19 +73,20 @@ class NumberInput extends Component {
|
|
|
|
|
|
|
|
|
|
|
|
const { value } = this.state;
|
|
|
|
const { value } = this.state;
|
|
|
|
const parsedValue = parseValue(this.props, value);
|
|
|
|
const parsedValue = parseValue(this.props, value);
|
|
|
|
|
|
|
|
const stringValue = parsedValue == null ? '' : parsedValue.toString();
|
|
|
|
|
|
|
|
|
|
|
|
if (parsedValue.toString() === value) {
|
|
|
|
if (stringValue === value) {
|
|
|
|
this.setState({ isFocused: false });
|
|
|
|
this.setState({ isFocused: false });
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
value: parsedValue.toString(),
|
|
|
|
value: stringValue,
|
|
|
|
isFocused: false
|
|
|
|
isFocused: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onChange({
|
|
|
|
onChange({
|
|
|
|
name,
|
|
|
|
name,
|
|
|
|
value: parseValue(this.props, this.state.value)
|
|
|
|
value: parsedValue
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|