mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	💅 Implement 'step' feature for InputNumber component
This commit is contained in:
		
							parent
							
								
									7c77cb985f
								
							
						
					
					
						commit
						5fa45859c9
					
				@ -29,6 +29,7 @@ function InputNumber(props) {
 | 
				
			|||||||
          onFocus={props.onFocus}
 | 
					          onFocus={props.onFocus}
 | 
				
			||||||
          placeholder={message}
 | 
					          placeholder={message}
 | 
				
			||||||
          ref={props.inputRef}
 | 
					          ref={props.inputRef}
 | 
				
			||||||
 | 
					          step={!Number.isNaN(Number(props.step)) ? Number(props.step) : 1}
 | 
				
			||||||
          style={props.style}
 | 
					          style={props.style}
 | 
				
			||||||
          tabIndex={props.tabIndex}
 | 
					          tabIndex={props.tabIndex}
 | 
				
			||||||
          type="number"
 | 
					          type="number"
 | 
				
			||||||
@ -49,6 +50,7 @@ InputNumber.defaultProps = {
 | 
				
			|||||||
  onBlur: () => {},
 | 
					  onBlur: () => {},
 | 
				
			||||||
  onFocus: () => {},
 | 
					  onFocus: () => {},
 | 
				
			||||||
  placeholder: 'app.utils.placeholder.defaultMessage',
 | 
					  placeholder: 'app.utils.placeholder.defaultMessage',
 | 
				
			||||||
 | 
					  step: 1,
 | 
				
			||||||
  style: {},
 | 
					  style: {},
 | 
				
			||||||
  tabIndex: '0',
 | 
					  tabIndex: '0',
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -65,6 +67,7 @@ InputNumber.propTypes = {
 | 
				
			|||||||
  onChange: PropTypes.func.isRequired,
 | 
					  onChange: PropTypes.func.isRequired,
 | 
				
			||||||
  onFocus: PropTypes.func,
 | 
					  onFocus: PropTypes.func,
 | 
				
			||||||
  placeholder: PropTypes.string,
 | 
					  placeholder: PropTypes.string,
 | 
				
			||||||
 | 
					  step: PropTypes.number,
 | 
				
			||||||
  style: PropTypes.object,
 | 
					  style: PropTypes.object,
 | 
				
			||||||
  tabIndex: PropTypes.string,
 | 
					  tabIndex: PropTypes.string,
 | 
				
			||||||
  value: PropTypes.oneOfType([
 | 
					  value: PropTypes.oneOfType([
 | 
				
			||||||
 | 
				
			|||||||
@ -83,6 +83,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
 | 
				
			|||||||
      placeholder,
 | 
					      placeholder,
 | 
				
			||||||
      style,
 | 
					      style,
 | 
				
			||||||
      tabIndex,
 | 
					      tabIndex,
 | 
				
			||||||
 | 
					      step,
 | 
				
			||||||
      value,
 | 
					      value,
 | 
				
			||||||
    } = this.props;
 | 
					    } = this.props;
 | 
				
			||||||
    const handleBlur = isFunction(onBlur) ? onBlur : this.handleBlur;
 | 
					    const handleBlur = isFunction(onBlur) ? onBlur : this.handleBlur;
 | 
				
			||||||
@ -121,6 +122,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
 | 
				
			|||||||
          placeholder={placeholder}
 | 
					          placeholder={placeholder}
 | 
				
			||||||
          style={inputStyle}
 | 
					          style={inputStyle}
 | 
				
			||||||
          tabIndex={tabIndex}
 | 
					          tabIndex={tabIndex}
 | 
				
			||||||
 | 
					          step={step}
 | 
				
			||||||
          value={value}
 | 
					          value={value}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
        <InputDescription
 | 
					        <InputDescription
 | 
				
			||||||
@ -162,6 +164,7 @@ InputNumberWithErrors.defaultProps = {
 | 
				
			|||||||
  labelStyle: {},
 | 
					  labelStyle: {},
 | 
				
			||||||
  noErrorsDescription: false,
 | 
					  noErrorsDescription: false,
 | 
				
			||||||
  placeholder: 'app.utils.placeholder.defaultMessage',
 | 
					  placeholder: 'app.utils.placeholder.defaultMessage',
 | 
				
			||||||
 | 
					  step: 1,
 | 
				
			||||||
  style: {},
 | 
					  style: {},
 | 
				
			||||||
  tabIndex: '0',
 | 
					  tabIndex: '0',
 | 
				
			||||||
  validations: {},
 | 
					  validations: {},
 | 
				
			||||||
@ -209,6 +212,7 @@ InputNumberWithErrors.propTypes = {
 | 
				
			|||||||
  onChange: PropTypes.func.isRequired,
 | 
					  onChange: PropTypes.func.isRequired,
 | 
				
			||||||
  onFocus: PropTypes.func,
 | 
					  onFocus: PropTypes.func,
 | 
				
			||||||
  placeholder: PropTypes.string,
 | 
					  placeholder: PropTypes.string,
 | 
				
			||||||
 | 
					  step: PropTypes.number,
 | 
				
			||||||
  style: PropTypes.object,
 | 
					  style: PropTypes.object,
 | 
				
			||||||
  tabIndex: PropTypes.string,
 | 
					  tabIndex: PropTypes.string,
 | 
				
			||||||
  validations: PropTypes.object,
 | 
					  validations: PropTypes.object,
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,7 @@ class EditForm extends React.Component  {
 | 
				
			|||||||
            name="sizeLimit"
 | 
					            name="sizeLimit"
 | 
				
			||||||
            onChange={this.props.onChange}
 | 
					            onChange={this.props.onChange}
 | 
				
			||||||
            type="number"
 | 
					            type="number"
 | 
				
			||||||
            step="0.01"
 | 
					            step={0.01}
 | 
				
			||||||
            value={get(this.props.modifiedData, 'sizeLimit', 1) / 1000}
 | 
					            value={get(this.props.modifiedData, 'sizeLimit', 1) / 1000}
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user