How to use the imask.HTMLMaskElement function in imask

To help you get started, we’ve selected a few imask examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stone-payments / emerald-web-framework / packages / emd-basic-field / src / helpers / maskMaker.js View on Github external
import iMask from 'imask';

// This monkey patch fixes the way iMask detects if an input is currently
// active since, in our case, we must look for the shadowRoot.activeElement
// and not the document.activeElement.

Object.defineProperty(iMask.HTMLMaskElement.prototype, 'isActive', {
  get () {
    const rootElement = this.input.getRootNode
      ? this.input.getRootNode() || document
      : document;

    return this.input === rootElement.activeElement;
  }
});

export const maskMaker = config => domEl => iMask(domEl, config);

imask

vanilla javascript input mask

MIT
Latest version published 17 days ago

Package Health Score

88 / 100
Full package analysis