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

Offer public access to the underlying formatter #80

Closed
MattiSG opened this issue Aug 13, 2016 · 3 comments
Closed

Offer public access to the underlying formatter #80

MattiSG opened this issue Aug 13, 2016 · 3 comments

Comments

@MattiSG
Copy link

MattiSG commented Aug 13, 2016

I have this use-case where I create a Cleave (which works no matter what element you give to it), and depending on the element.tagName, I would either use it directly if it's an <input>, or access the underlying formatter through the private .properties.numeralFormatter.
It would be safer for me if this was a public API rather than a private one, which forces me to lock dependencies and double-check on each update.

But really, it seems to me Cleave could keep its ease of setup for <input> while offering an <input>-independent formatting facility, which would bring many other use cases.

A basic implementation could be to offer a formatter getter.
A more complete implementation, to make the constructor more consistent, could make element optional, or maybe passed in as a second function call (attachTo?), after having created a generic Cleave.

Or maybe, if my use-case isn't too specific, natively support formatting on a non-<input> by calling format on the innerText…?

Or maybe this is just out of scope for Cleave, which would be fine. But I would then encourage you to release the formatting library as a separate module 😃

@nosir
Copy link
Owner

nosir commented Aug 13, 2016

@MattiSG, thanks for proposing the detaching and formatting module idea, that can definitely offer more options for handling the data.

However, as you said, I think it's out of scope of cleave. Cleave focuses on user behaviours, to use Cleave with input is a must thing. That is to keep it easy to understand and integrate(for most of the dev case)

So there won't be any public method exposing for formatters :)

Will close this.
Cheers!

@nosir nosir closed this as completed Aug 13, 2016
@MattiSG
Copy link
Author

MattiSG commented Aug 13, 2016 via email

@nosir
Copy link
Owner

nosir commented Nov 25, 2023

Hello @MattiSG, update! 👍
After many years, I finally ditched my originally idea and created a new version of cleave based on your idea.
Here's the update: #723

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