How to use the imask.createMask 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 / sling-web-component-input / src / component / Input.js View on Github external
formatType(type = '') {
    if (type) {
      switch (type) {
        case 'cnpj': {
          this.mask = imask.createMask({
            mask: '00.000.000/0000-00',
          });
          this.maxlength = 18;
          break;
        }
        case 'cpf': {
          this.mask = imask.createMask({
            mask: '000.000.000-00',
          });
          this.maxlength = 14;
          break;
        }
        case 'phone': {
          this.mask = imask.createMask({
            mask: [{
              mask: '(00) 0000-0000',
            }, {
              mask: '(00) 00000-0000',
            }],
            dispatch(appended, dynamicMasked) {
              if ((dynamicMasked.value + appended).length < 15) {
                return dynamicMasked.compiledMasks[0];
              }
github stone-payments / emerald-web-framework / packages / sling-web-component-table / src / component / Table.js View on Github external
}
        case 'installment': {
          cell = `
            <span>${fieldItem.toString().concat('x')}</span>
          `;
          break;
        }
        case 'cpf': {
          const cpfMask = imask.createMask({
            mask: '000.000.000-00',
          });
          cell = cpfMask.resolve(fieldItem);
          break;
        }
        case 'cnpj': {
          const cnpjMask = imask.createMask({
            mask: '00.000.000/0000-00',
          });
          cell = cnpjMask.resolve(fieldItem);
          break;
        }
        case 'brand_icon': {
          cell = `
            
          `;
          break;
        }
        case 'phone': {
          let phoneMask;
          switch (fieldItem.length) {
            case 8: {
              phoneMask = imask.createMask({
github stone-payments / emerald-web-framework / packages / sling-web-component-table / src / component / Table.js View on Github external
break;
            }
            case 9: {
              phoneMask = imask.createMask({
                mask: '00000-0000',
              });
              break;
            }
            case 10: {
              phoneMask = imask.createMask({
                mask: '(00)0000-0000',
              });
              break;
            }
            default: {
              phoneMask = imask.createMask({
                mask: '(00)00000-0000',
              });
            }
          }
          cell = phoneMask.resolve(fieldItem);
          break;
        }
        default: {
          cell = fieldItem;
        }
      }
    }
    return cell;
  }
github stone-payments / emerald-web-framework / packages / sling-web-component-table / src / component / Table.js View on Github external
break;
        }
        case 'rate': {
          cell = `
            <span>${fieldItem.toString().replace('.', ',').concat('%')}</span>
          `;
          break;
        }
        case 'installment': {
          cell = `
            <span>${fieldItem.toString().concat('x')}</span>
          `;
          break;
        }
        case 'cpf': {
          const cpfMask = imask.createMask({
            mask: '000.000.000-00',
          });
          cell = cpfMask.resolve(fieldItem);
          break;
        }
        case 'cnpj': {
          const cnpjMask = imask.createMask({
            mask: '00.000.000/0000-00',
          });
          cell = cnpjMask.resolve(fieldItem);
          break;
        }
        case 'brand_icon': {
          cell = `
            
          `;

imask

vanilla javascript input mask

MIT
Latest version published 7 months ago

Package Health Score

81 / 100
Full package analysis