💅 Implement 'step' feature for InputNumber component

This commit is contained in:
REDDY PRASAD 2019-02-28 16:28:06 +05:30
parent 7c77cb985f
commit 5fa45859c9
3 changed files with 8 additions and 1 deletions

View File

@ -29,6 +29,7 @@ function InputNumber(props) {
onFocus={props.onFocus}
placeholder={message}
ref={props.inputRef}
step={!Number.isNaN(Number(props.step)) ? Number(props.step) : 1}
style={props.style}
tabIndex={props.tabIndex}
type="number"
@ -49,6 +50,7 @@ InputNumber.defaultProps = {
onBlur: () => {},
onFocus: () => {},
placeholder: 'app.utils.placeholder.defaultMessage',
step: 1,
style: {},
tabIndex: '0',
};
@ -65,6 +67,7 @@ InputNumber.propTypes = {
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,
placeholder: PropTypes.string,
step: PropTypes.number,
style: PropTypes.object,
tabIndex: PropTypes.string,
value: PropTypes.oneOfType([

View File

@ -83,6 +83,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
placeholder,
style,
tabIndex,
step,
value,
} = this.props;
const handleBlur = isFunction(onBlur) ? onBlur : this.handleBlur;
@ -121,6 +122,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
placeholder={placeholder}
style={inputStyle}
tabIndex={tabIndex}
step={step}
value={value}
/>
<InputDescription
@ -162,6 +164,7 @@ InputNumberWithErrors.defaultProps = {
labelStyle: {},
noErrorsDescription: false,
placeholder: 'app.utils.placeholder.defaultMessage',
step: 1,
style: {},
tabIndex: '0',
validations: {},
@ -209,6 +212,7 @@ InputNumberWithErrors.propTypes = {
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,
placeholder: PropTypes.string,
step: PropTypes.number,
style: PropTypes.object,
tabIndex: PropTypes.string,
validations: PropTypes.object,

View File

@ -72,7 +72,7 @@ class EditForm extends React.Component {
name="sizeLimit"
onChange={this.props.onChange}
type="number"
step="0.01"
step={0.01}
value={get(this.props.modifiedData, 'sizeLimit', 1) / 1000}
/>
</div>