diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 00000000..4edbe3a2 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,7 @@ +var _maskService=require('./lib/mask-service');var _maskService2=_interopRequireDefault(_maskService); +var _textInputMask=require('./lib/text-input-mask');var _textInputMask2=_interopRequireDefault(_textInputMask); +var _textMask=require('./lib/text-mask');var _textMask2=_interopRequireDefault(_textMask);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} + +module.exports.MaskService=_maskService2.default; +module.exports.TextInputMask=_textInputMask2.default; +module.exports.TextMask=_textMask2.default; \ No newline at end of file diff --git a/dist/lib/base-text-component.js b/dist/lib/base-text-component.js new file mode 100644 index 00000000..ec2342fd --- /dev/null +++ b/dist/lib/base-text-component.js @@ -0,0 +1,108 @@ +Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;icentsLength?opts.precision:centsLength; + +cents=(cents+centsValue).slice(-centsSliced); +} + +var unitToApply=opts.unit[opts.unit.length-1]===' '? +opts.unit.substring(0,opts.unit.length-1): + +opts.unit; +var output=unitToApply+masked+opts.separator+cents+opts.suffixUnit; +return output.replace(clearSeparator,""); +}; + +VMasker.toPattern=function(value,opts){ +var pattern=typeof opts==='object'?opts.pattern:opts, +patternChars=pattern.replace(/\W/g,''), +output=pattern.split(""), +values=value.toString().replace(/\W/g,""), +charsValues=values.replace(/\W/g,''), +index=0, +i, +outputLength=output.length, +placeholder=typeof opts==='object'?opts.placeholder:undefined; + + +for(i=0;i=values.length){ +if(patternChars.length==charsValues.length){ +return output.join(""); +}else +if(placeholder!==undefined&&patternChars.length>charsValues.length){ +return addPlaceholdersToOutput(output,i,placeholder).join(""); +}else +{ +break; +} +}else + +{ +if(output[i]===DIGIT&&values[index].match(/[0-9]/)|| +output[i]===ALPHA&&values[index].match(/[a-zA-Z]/)|| +output[i]===ALPHANUM&&values[index].match(/[0-9a-zA-Z]/)){ +output[i]=values[index++]; +}else if(output[i]===DIGIT||output[i]===ALPHA||output[i]===ALPHANUM){ +if(placeholder!==undefined){ +return addPlaceholdersToOutput(output,i,placeholder).join(""); +}else +{ +return output.slice(0,i).join(""); +} +} +} +} +return output.join("").substr(0,i); +}; + +VMasker.toNumber=function(value){ +return value.toString().replace(/(?!^-)[^0-9]/g,""); +}; + +VMasker.toAlphaNumeric=function(value){ +return value.toString().replace(/[^a-z0-9 ]+/i,""); +}; + +return VMasker; +}); \ No newline at end of file diff --git a/dist/lib/mask-resolver.js b/dist/lib/mask-resolver.js new file mode 100644 index 00000000..f35ec2c9 --- /dev/null +++ b/dist/lib/mask-resolver.js @@ -0,0 +1,19 @@ +Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i=9; +}else +{ +return numbers.length>=9; +} +}(); + +if(use9DigitMask){ +mask=PHONE_9_MASK; +} + +if(mergedSettings.withDDD){ +mask=''+mergedSettings.dddMask+mask; +} + +return mask; +}}],[{key:'getType',value:function getType(){return'cel-phone';}}]);return CelPhoneMask;}(_base2.default);exports.default=CelPhoneMask; \ No newline at end of file diff --git a/dist/lib/masks/cnpj.mask.js b/dist/lib/masks/cnpj.mask.js new file mode 100644 index 00000000..7c083722 --- /dev/null +++ b/dist/lib/masks/cnpj.mask.js @@ -0,0 +1,40 @@ +Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i0?cnpj.charAt(i-1)*valida[i]:0; +dig2+=cnpj.charAt(i)*valida[i]; +} +dig1=dig1%11<2?0:11-dig1%11; +dig2=dig2%11<2?0:11-dig2%11; + +return dig1*10+dig2==digito; +};var + +CnpjMask=function(_BaseMask){_inherits(CnpjMask,_BaseMask);function CnpjMask(){_classCallCheck(this,CnpjMask);return _possibleConstructorReturn(this,(CnpjMask.__proto__||Object.getPrototypeOf(CnpjMask)).apply(this,arguments));}_createClass(CnpjMask,[{key:'getValue',value:function getValue( + + + + +value,settings){ +return this.getVMasker().toPattern(value,CNPJ_MASK); +}},{key:'getRawValue',value:function getRawValue( + +maskedValue,settings){ +return _get(CnpjMask.prototype.__proto__||Object.getPrototypeOf(CnpjMask.prototype),'removeNotNumbers',this).call(this,maskedValue); +}},{key:'validate',value:function validate( + +value,settings){ +return validateCnpj(value); +}}],[{key:'getType',value:function getType(){return'cnpj';}}]);return CnpjMask;}(_base2.default);exports.default=CnpjMask; \ No newline at end of file diff --git a/dist/lib/masks/cpf.mask.js b/dist/lib/masks/cpf.mask.js new file mode 100644 index 00000000..7e96b597 --- /dev/null +++ b/dist/lib/masks/cpf.mask.js @@ -0,0 +1,69 @@ +Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){ +return text.substring(0,index)+string+text.substring(index,text.length); +}else +{ +return string+text; +} +}}],[{key:'getType',value:function getType(){return'money';}}]);return MoneyMask;}(_base2.default);exports.default=MoneyMask; \ No newline at end of file diff --git a/dist/lib/masks/only-numbers.mask.js b/dist/lib/masks/only-numbers.mask.js new file mode 100644 index 00000000..5bcc8ecf --- /dev/null +++ b/dist/lib/masks/only-numbers.mask.js @@ -0,0 +1,18 @@ +Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i