react-component / input-number

React Input Number
https://input-number.vercel.app/
MIT License
312 stars 173 forks source link

Progressive steps #186

Open krzywiecki opened 5 years ago

krzywiecki commented 5 years ago

Hello guys. I'm using your component and at the moment I have a task where I have to implement different steps depending on value. For example: When the value is in a rage of 1-100 one arrow click should increase/decrease the value by 1. When the value of the input is in range 100-1000 one arrow click should increase/decrease the value by 5. And so on.

Please let me know what you think about implementing it in the component. If you think it makes sense I'll raise a PR soon. I was thinking that step property can take either string/number as it is now or array of objects. Something like:

<RCInputNumber
    step={[
        { min: -100, max: 100, value: 1 },
        { min: -1000, max: 1000, value: 5 },
        { min: -10000, max: 10000, value: 10 }
    ]}
/>
bnau commented 2 years ago

Hello guys I'm really interested about this feature. My use case is to have a step depending on the number of decimal. For example, when the value is 1.23, I want a step of 0.01 and when the value is 1.234, I want a step of 0.001. A really flexible solution could be allowing the onStep prop to return a custom updated value. What do you think about it?