react-numeric
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -61,3 +61,18 @@ "use strict"; | ||
value: function componentWillReceiveProps(newProps) { | ||
if (this.props.value !== newProps.value && this.getValue() !== newProps.value) this.autonumeric.set(newProps.value); | ||
var isOptionsChanged = JSON.stringify(_extends({}, this.props, { value: undefined })) !== JSON.stringify(_extends({}, newProps, { value: undefined })); | ||
var isValueChanged = this.props.value !== newProps.value && this.getValue() !== newProps.value; | ||
if (isValueChanged) { | ||
this.autonumeric.set(newProps.value); | ||
} | ||
if (isOptionsChanged) { | ||
this.autonumeric.update(_extends({}, newProps.preDefined, newProps, { | ||
onChange: undefined, | ||
onFocus: undefined, | ||
onBlur: undefined, | ||
onKeyPress: undefined, | ||
onKeyUp: undefined, | ||
onKeyDown: undefined, | ||
watchExternalChanges: false | ||
})); | ||
} | ||
} | ||
@@ -64,0 +79,0 @@ }, { |
{ | ||
"name": "react-numeric", | ||
"description": "A React component for choosing dates and date ranges.", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -26,4 +26,20 @@ import React from "react"; | ||
componentWillReceiveProps(newProps) { | ||
if (this.props.value !== newProps.value && this.getValue() !== newProps.value) | ||
const isOptionsChanged = JSON.stringify({...this.props, value: undefined}) !== JSON.stringify({...newProps, value: undefined}); | ||
const isValueChanged = this.props.value !== newProps.value && this.getValue() !== newProps.value; | ||
if (isValueChanged){ | ||
this.autonumeric.set(newProps.value); | ||
} | ||
if (isOptionsChanged) { | ||
this.autonumeric.update({ | ||
...newProps.preDefined, | ||
...newProps, | ||
onChange: undefined, | ||
onFocus: undefined, | ||
onBlur: undefined, | ||
onKeyPress: undefined, | ||
onKeyUp: undefined, | ||
onKeyDown: undefined, | ||
watchExternalChanges: false, | ||
}); | ||
} | ||
} | ||
@@ -30,0 +46,0 @@ getValue() { |
Sorry, the diff of this file is not supported yet
290128
335