react-input-mask
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -95,5 +95,6 @@ // https://github.com/sanniassin/react-input-mask | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? this.state.value : arguments[0]; | ||
var state = arguments.length <= 1 || arguments[1] === undefined ? this.state : arguments[1]; | ||
return !value.split("").some(function (char, i) { | ||
return !_this.isPermanentChar(i) && _this.isAllowedChar(char, i); | ||
return !_this.isPermanentChar(i, state) && _this.isAllowedChar(char, i, state); | ||
}); | ||
@@ -380,5 +381,9 @@ }, | ||
var isMaskChanged = mask.mask && mask.mask !== this.state.mask; | ||
if (isMaskChanged || mask.mask && (newValue || nextProps.alwaysShowMask || this.isFocused())) { | ||
var showEmpty = nextProps.alwaysShowMask || this.isFocused(); | ||
if (isMaskChanged || mask.mask && (newValue || showEmpty)) { | ||
newValue = this.formatValue(newValue, state); | ||
} | ||
if (mask.mask && this.isEmpty(newValue, state) && !showEmpty) { | ||
newValue = ""; | ||
} | ||
if (this.state.value !== newValue) { | ||
@@ -385,0 +390,0 @@ state.value = newValue; |
@@ -85,5 +85,5 @@ // https://github.com/sanniassin/react-input-mask | ||
}, | ||
isEmpty: function(value = this.state.value) { | ||
isEmpty: function(value = this.state.value, state = this.state) { | ||
return !value.split("").some((char, i) => | ||
!this.isPermanentChar(i) && this.isAllowedChar(char, i) | ||
!this.isPermanentChar(i, state) && this.isAllowedChar(char, i, state) | ||
); | ||
@@ -366,5 +366,9 @@ }, | ||
var isMaskChanged = mask.mask && mask.mask !== this.state.mask; | ||
if (isMaskChanged || (mask.mask && (newValue || nextProps.alwaysShowMask || this.isFocused()))) { | ||
var showEmpty = nextProps.alwaysShowMask || this.isFocused(); | ||
if (isMaskChanged || (mask.mask && (newValue || showEmpty))) { | ||
newValue = this.formatValue(newValue, state); | ||
} | ||
if (mask.mask && this.isEmpty(newValue, state) && !showEmpty) { | ||
newValue = ""; | ||
} | ||
if (this.state.value !== newValue) { | ||
@@ -371,0 +375,0 @@ state.value = newValue; |
{ | ||
"name": "react-input-mask", | ||
"description": "Masked input component for React", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"homepage": "https://github.com/sanniassin/react-input-mask", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
43470
1143