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

Option to allow Input Ref contain un-masked value #610

Closed
dpkshrma opened this issue Feb 4, 2022 · 3 comments
Closed

Option to allow Input Ref contain un-masked value #610

dpkshrma opened this issue Feb 4, 2022 · 3 comments

Comments

@dpkshrma
Copy link

dpkshrma commented Feb 4, 2022

What problem you are trying to solve?
The app I am working on uses refs to handle form data. I am able to use this mask component on currency input but ref.current contains the masked value.

Current Example usage:

<IMaskInput
  inputRef={el => {
    if (typeof ref === 'function') {
      ref(el as HTMLInputElement);
    } else if (ref) {
      // @ts-ignore
      ref.current = el;
    }
  }}
  name={name}
  disabled={disabled}
  className={inputClasses}
  defaultValue={value || defaultValue}
  mask={maskOpts.mask}
  blocks={maskOpts.blocks}
  unmask
/>

Describe the solution you'd like
It would allow pre-existing large projects to use this mask if there is an option to have input ref return unmasked value.
For Example, having a boolean prop like unmaskedInputRef

@uNmAnNeR
Copy link
Owner

uNmAnNeR commented Feb 6, 2022

thanks for reporting.
in latest version you can pass ref to the IMaskInput, extract mask ref and then get any value you want. Like this:
<IMaskInput ref={<YOUR REF>} />
get unmasked value:
ref.current.maskRef.unmaskedValue
Can you check on v6.4.1-alpha.0?

@smblee
Copy link

smblee commented Aug 25, 2022

@uNmAnNeR sorry for bumping a closed thread, but is there an easy way to access this ref in svelte library too?

@uNmAnNeR
Copy link
Owner

uNmAnNeR commented Sep 2, 2022

@smblee if we talk about svelte-imask/action you can create imask instance and pass it to the action like use:imask={INSTANCE}

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

3 participants