thaw-ui / thaw

An easy to use leptos component library
https://thawui.vercel.app
MIT License
206 stars 21 forks source link

Feat/input parser and formatter #208

Closed mmannes closed 1 week ago

mmannes commented 2 weeks ago

This PR resolves issue #129 by adding optional callbacks to Input and InputNumber components. The parser callback converts user input to the desired signal format, while the formatter callback presents the signal value to the user. You can check it working in the Docs.

luoxiaozero commented 2 weeks ago

Should we consider putting parsing and formatting into the onchange event, as this will avoid cursor confusion?

mmannes commented 1 week ago

Should we consider putting parsing and formatting into the onchange event, as this will avoid cursor confusion?

I like real-time formatting so much, specially when typing only numbers without having to go for the "." or "," key. But I think you are correct, the cursor confusion makes it impossible to fix a typo without rewriting everything.

I will do the changes you proposed and open another PR.

Thank you very much!