Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: formatted input #1463

Open
2 tasks
amery opened this issue Nov 27, 2024 · 3 comments
Open
2 tasks

[Feature]: formatted input #1463

amery opened this issue Nov 27, 2024 · 3 comments

Comments

@amery
Copy link

amery commented Nov 27, 2024

Describe the feature

Specialized input fields like currency and date are the most common case for "masked" inputs. However, could you consider adding a generic formatted input receiving parse and format functions for custom conversions?

In my case, I need to present and edit feet' inch" but store decimal inches in the variables.

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
@zernonia
Copy link
Member

zernonia commented Dec 6, 2024

Hey @amery .. could you provide more description for this component? Perhaps some example you found online for reference? 😁

@amery
Copy link
Author

amery commented Dec 10, 2024

Hey @amery .. could you provide more description for this component? Perhaps some example you found online for reference? 😁

There are many out there, e.g. https://vueform.com/docs/input-mask, which uses https://imask.js.org/guide.html.

The most straightforward implementation would use a function to convert (format) the value to the presentation form and another to convert (parse) the modified formatted value back to its "raw" form.
There are also 3-form implementations, but I can't find any currently. Those keep the value in its raw form internally but show pretty formatting when the field is inactive and simplified formatting when active (for the human to edit). This way, the pretty representation doesn't need parsing; only the simplified formatting does.

@amery
Copy link
Author

amery commented Dec 10, 2024

https://github.com/mustafacagri/vue-mask-next is a simple implementation of pattern based input masks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants