react-input-mask
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -65,4 +65,4 @@ // https://github.com/sanniassin/react-input-mask | ||
for (i = value.length - 1; i >= 0; --i) { | ||
var char = value[i]; | ||
if (!this.isPermanentChar(i) && this.isAllowedChar(char, i)) { | ||
var character = value[i]; | ||
if (!this.isPermanentChar(i) && this.isAllowedChar(character, i)) { | ||
break; | ||
@@ -97,4 +97,4 @@ } | ||
return !value.split("").some(function (char, i) { | ||
return !_this.isPermanentChar(i) && _this.isAllowedChar(char, i); | ||
return !value.split("").some(function (character, i) { | ||
return !_this.isPermanentChar(i) && _this.isAllowedChar(character, i); | ||
}); | ||
@@ -138,5 +138,5 @@ }, | ||
} | ||
return value.split("").concat(this.createFilledArray(mask.length - value.length, null)).map(function (char, pos) { | ||
if (_this2.isAllowedChar(char, pos)) { | ||
return char; | ||
return value.split("").concat(this.createFilledArray(mask.length - value.length, null)).map(function (character, pos) { | ||
if (_this2.isAllowedChar(character, pos)) { | ||
return character; | ||
} else if (_this2.isPermanentChar(pos)) { | ||
@@ -157,3 +157,3 @@ return mask[pos]; | ||
var prefixLen = this.getPrefix().length; | ||
value = value.split("").filter(function (char, i) { | ||
value = value.split("").filter(function (character, i) { | ||
return i < prefixLen || i < start || i >= end; | ||
@@ -163,5 +163,5 @@ }).join(""); | ||
} | ||
return value.split("").map(function (char, i) { | ||
return value.split("").map(function (character, i) { | ||
if (i < start || i >= end) { | ||
return char; | ||
return character; | ||
} | ||
@@ -192,12 +192,12 @@ if (_this3.isPermanentChar(i)) { | ||
if (!isPermanent || mask[i] === substr[0]) { | ||
var char = substr.shift(); | ||
if (this.isAllowedChar(char, i, true)) { | ||
var character = substr.shift(); | ||
if (this.isAllowedChar(character, i, true)) { | ||
if (i < value.length) { | ||
if (maskChar || isFilled || i < prefixLen) { | ||
value = this.replaceSubstr(value, char, i); | ||
value = this.replaceSubstr(value, character, i); | ||
} else { | ||
value = this.formatValue(value.substr(0, i) + char + value.substr(i)); | ||
value = this.formatValue(value.substr(0, i) + character + value.substr(i)); | ||
} | ||
} else if (!maskChar) { | ||
value += char; | ||
value += character; | ||
} | ||
@@ -224,4 +224,4 @@ ++i; | ||
if (!this.isPermanentChar(i) || mask[i] === substr[0]) { | ||
var char = substr.shift(); | ||
if (this.isAllowedChar(char, i, true)) { | ||
var character = substr.shift(); | ||
if (this.isAllowedChar(character, i, true)) { | ||
++i; | ||
@@ -235,3 +235,3 @@ } | ||
}, | ||
isAllowedChar: function (char, pos) { | ||
isAllowedChar: function (character, pos) { | ||
var allowMaskChar = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; | ||
@@ -242,7 +242,7 @@ var mask = this.mask; | ||
if (this.isPermanentChar(pos)) { | ||
return mask[pos] === char; | ||
return mask[pos] === character; | ||
} | ||
var ruleChar = mask[pos]; | ||
var charRule = this.charsRules[ruleChar]; | ||
return new RegExp(charRule).test(char || "") || allowMaskChar && char === maskChar; | ||
return new RegExp(charRule).test(character || "") || allowMaskChar && character === maskChar; | ||
}, | ||
@@ -332,10 +332,10 @@ isPermanentChar: function (pos) { | ||
mask.split("").forEach(function (char) { | ||
if (!isPermanent && char === "\\") { | ||
mask.split("").forEach(function (character) { | ||
if (!isPermanent && character === "\\") { | ||
isPermanent = true; | ||
} else { | ||
if (isPermanent || !_this4.charsRules[char]) { | ||
if (isPermanent || !_this4.charsRules[character]) { | ||
permanents.push(str.length); | ||
} | ||
str += char; | ||
str += character; | ||
isPermanent = false; | ||
@@ -342,0 +342,0 @@ } |
@@ -61,4 +61,4 @@ // https://github.com/sanniassin/react-input-mask | ||
for (i = value.length - 1; i >= 0; --i) { | ||
var char = value[i]; | ||
if (!this.isPermanentChar(i) && this.isAllowedChar(char, i)) { | ||
var character = value[i]; | ||
if (!this.isPermanentChar(i) && this.isAllowedChar(character, i)) { | ||
break; | ||
@@ -88,4 +88,4 @@ } | ||
isEmpty: function(value = this.state.value) { | ||
return !value.split("").some((char, i) => | ||
!this.isPermanentChar(i) && this.isAllowedChar(char, i) | ||
return !value.split("").some((character, i) => | ||
!this.isPermanentChar(i) && this.isAllowedChar(character, i) | ||
); | ||
@@ -125,5 +125,5 @@ }, | ||
.concat(this.createFilledArray(mask.length - value.length, null)) | ||
.map((char, pos) => { | ||
if (this.isAllowedChar(char, pos)) { | ||
return char; | ||
.map((character, pos) => { | ||
if (this.isAllowedChar(character, pos)) { | ||
return character; | ||
} | ||
@@ -143,3 +143,3 @@ else if (this.isPermanentChar(pos)) { | ||
value = value.split("") | ||
.filter((char, i) => i < prefixLen || i < start || i >= end) | ||
.filter((character, i) => i < prefixLen || i < start || i >= end) | ||
.join(""); | ||
@@ -149,5 +149,5 @@ return this.formatValue(value); | ||
return value.split("") | ||
.map((char, i) => { | ||
.map((character, i) => { | ||
if (i < start || i >= end) { | ||
return char; | ||
return character; | ||
} | ||
@@ -177,14 +177,14 @@ if (this.isPermanentChar(i)) { | ||
if (!isPermanent || mask[i] === substr[0]) { | ||
var char = substr.shift(); | ||
if (this.isAllowedChar(char, i, true)) { | ||
var character = substr.shift(); | ||
if (this.isAllowedChar(character, i, true)) { | ||
if (i < value.length) { | ||
if (maskChar || isFilled || i < prefixLen) { | ||
value = this.replaceSubstr(value, char, i); | ||
value = this.replaceSubstr(value, character, i); | ||
} | ||
else { | ||
value = this.formatValue(value.substr(0, i) + char + value.substr(i)); | ||
value = this.formatValue(value.substr(0, i) + character + value.substr(i)); | ||
} | ||
} | ||
else if (!maskChar) { | ||
value += char; | ||
value += character; | ||
} | ||
@@ -211,4 +211,4 @@ ++i; | ||
if (!this.isPermanentChar(i) || mask[i] === substr[0]) { | ||
var char = substr.shift(); | ||
if (this.isAllowedChar(char, i, true)) { | ||
var character = substr.shift(); | ||
if (this.isAllowedChar(character, i, true)) { | ||
++i; | ||
@@ -223,10 +223,10 @@ } | ||
}, | ||
isAllowedChar: function(char, pos, allowMaskChar = false) { | ||
isAllowedChar: function(character, pos, allowMaskChar = false) { | ||
var { mask, maskChar } = this; | ||
if (this.isPermanentChar(pos)) { | ||
return mask[pos] === char; | ||
return mask[pos] === character; | ||
} | ||
var ruleChar = mask[pos]; | ||
var charRule = this.charsRules[ruleChar]; | ||
return (new RegExp(charRule)).test(char || "") || (allowMaskChar && char === maskChar); | ||
return (new RegExp(charRule)).test(character || "") || (allowMaskChar && character === maskChar); | ||
}, | ||
@@ -318,11 +318,11 @@ isPermanentChar: function(pos) { | ||
mask.split("").forEach((char) => { | ||
if (!isPermanent && char === "\\") { | ||
mask.split("").forEach((character) => { | ||
if (!isPermanent && character === "\\") { | ||
isPermanent = true; | ||
} | ||
else { | ||
if (isPermanent || !this.charsRules[char]) { | ||
if (isPermanent || !this.charsRules[character]) { | ||
permanents.push(str.length); | ||
} | ||
str += char; | ||
str += character; | ||
isPermanent = false; | ||
@@ -329,0 +329,0 @@ } |
{ | ||
"name": "react-input-mask", | ||
"description": "Masked input component for React", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"homepage": "https://github.com/sanniassin/react-input-mask", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69071