You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 😃
The text was updated successfully, but these errors were encountered:
@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 :)
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
I have this use-case where I create a
Cleave
(which works no matter whatelement
you give to it), and depending on theelement.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 genericCleave
.Or maybe, if my use-case isn't too specific, natively support formatting on a non-
<input>
by callingformat
on theinnerText
…?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 😃
The text was updated successfully, but these errors were encountered: