Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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];
}
}
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({
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;
}
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 = `
`;