diff --git a/README.md b/README.md
index fb6e96b..99c6088 100644
--- a/README.md
+++ b/README.md
@@ -134,5 +134,7 @@ selectAllOnFocus | false | Selects all text on focus or does not
prefix | '' | Currency prefix
suffix | '' | Currency suffix
autoFocus | false | Autofocus
+maxValue | undefined | Maximum input value (state won't change if input is higher)
+minValue | undefined | Minimum input value (state won't change if input is lower)
***Note:** Enabling any mask-related features such as prefix, suffix or separators with an inputType="number" or "tel" could trigger errors. Most of those characters would be invalid in such input types.
diff --git a/lib/react-currency-input.cjs.js b/lib/react-currency-input.cjs.js
index 735ce0e..fe1dde9 100644
--- a/lib/react-currency-input.cjs.js
+++ b/lib/react-currency-input.cjs.js
@@ -168,6 +168,8 @@ var CurrencyInput = (function (Component$$1) {
delete customProps.suffix;
delete customProps.selectAllOnFocus;
delete customProps.autoFocus;
+ delete customProps.maxValue;
+ delete customProps.minValue;
var initialValue = props.value;
if (initialValue === null) {
@@ -316,6 +318,7 @@ var CurrencyInput = (function (Component$$1) {
var this$1 = this;
event.preventDefault();
+
var ref = mask(
event.target.value,
this.props.precision,
@@ -328,6 +331,12 @@ var CurrencyInput = (function (Component$$1) {
var maskedValue = ref.maskedValue;
var value = ref.value;
+ if ((this.props.maxValue && value > this.props.maxValue)
+ || (this.props.minValue && value < this.props.maxValue)) {
+ // if value exceeds min & max limits, do nothing...
+ return;
+ }
+
event.persist(); // fixes issue #23
this.setState({ maskedValue: maskedValue, value: value }, function () {
@@ -411,7 +420,9 @@ CurrencyInput.defaultProps = {
allowNegative: false,
prefix: '',
suffix: '',
- selectAllOnFocus: false
+ selectAllOnFocus: false,
+ maxValue: undefined,
+ minValue: undefined
};
module.exports = CurrencyInput;
diff --git a/lib/react-currency-input.cjs.js.map b/lib/react-currency-input.cjs.js.map
index 16522e4..4a19914 100644
--- a/lib/react-currency-input.cjs.js.map
+++ b/lib/react-currency-input.cjs.js.map
@@ -1 +1 @@
-{"version":3,"file":"react-currency-input.cjs.js","sources":["../src/object-assign-polyfill.js","../src/mask.js","../src/index.js"],"sourcesContent":["Object.assign = Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n","\nexport default function mask(value, precision = 2, decimalSeparator = '.', thousandSeparator = ',', allowNegative = false, prefix = '', suffix = ''){\n // provide some default values and arg validation.\n if (precision < 0) { precision = 0; } // precision cannot be negative\n if (precision > 20) { precision = 20; } // precision cannot be greater than 20\n \n if (value === null || value===undefined) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n \n value = String(value); //if the given value is a Number, let's convert into String to manipulate that\n\n if (value.length == 0) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n\n\n // extract digits. if no digits, fill in a zero.\n let digits = value.match(/\\d/g) || ['0'];\n \n let numberIsNegative = false;\n if (allowNegative) {\n let negativeSignCount = (value.match(/-/g) || []).length;\n // number will be negative if we have an odd number of \"-\"\n // ideally, we should only ever have 0, 1 or 2 (positive number, making a number negative\n // and making a negative number positive, respectively)\n numberIsNegative = negativeSignCount % 2 === 1;\n \n // if every digit in the array is '0', then the number should never be negative\n let allDigitsAreZero = true;\n for (let idx=0; idx < digits.length; idx += 1) {\n if(digits[idx] !== '0') {\n allDigitsAreZero = false;\n break;\n }\n }\n if (allDigitsAreZero) {\n numberIsNegative = false;\n }\n }\n\n // zero-pad a input\n while (digits.length <= precision) { digits.unshift('0'); }\n\n if (precision > 0) {\n // add the decimal separator\n digits.splice(digits.length - precision, 0, \".\");\n }\n\n // clean up extraneous digits like leading zeros.\n digits = Number(digits.join('')).toFixed(precision).split('');\n let raw = Number(digits.join(''));\n\n let decimalpos = digits.length - precision - 1; // -1 needed to position the decimal separator before the digits.\n if (precision > 0) {\n // set the final decimal separator\n digits[decimalpos] = decimalSeparator;\n } else {\n // when precision is 0, there is no decimal separator.\n decimalpos = digits.length;\n }\n\n // add in any thousand separators\n for (let x=decimalpos - 3; x > 0; x = x - 3) {\n digits.splice(x, 0, thousandSeparator);\n }\n\n // if we have a prefix or suffix, add them in.\n if (prefix.length > 0) { digits.unshift(prefix); }\n if (suffix.length > 0) { digits.push(suffix); }\n\n // if the number is negative, insert a \"-\" to\n // the front of the array and negate the raw value\n if (allowNegative && numberIsNegative) {\n digits.unshift('-');\n raw = -raw;\n }\n\n return {\n value: raw,\n maskedValue: digits.join('').trim()\n };\n}\n","import './object-assign-polyfill';\n\nimport PropTypes from 'prop-types';\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport mask from './mask.js'\n\n// IE* parseFloat polyfill\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat#Polyfill\nNumber.parseFloat = parseFloat;\n\nclass CurrencyInput extends Component {\n constructor(props) {\n super(props);\n this.prepareProps = this.prepareProps.bind(this);\n this.handleChange = this.handleChange.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.state = this.prepareProps(this.props);\n\n this.inputSelectionStart = 1;\n this.inputSelectionEnd = 1;\n }\n\n\n /**\n * Exposes the current masked value.\n *\n * @returns {String}\n */\n getMaskedValue() {\n return this.state.maskedValue;\n }\n\n\n /**\n * General function used to cleanup and define the final props used for rendering\n * @returns {{ maskedValue: {String}, value: {Number}, customProps: {Object} }}\n */\n prepareProps(props) {\n let customProps = {...props}; // babeljs converts to Object.assign, then polyfills.\n delete customProps.onChange;\n delete customProps.onChangeEvent;\n delete customProps.value;\n delete customProps.decimalSeparator;\n delete customProps.thousandSeparator;\n delete customProps.precision;\n delete customProps.inputType;\n delete customProps.allowNegative;\n delete customProps.allowEmpty;\n delete customProps.prefix;\n delete customProps.suffix;\n delete customProps.selectAllOnFocus;\n delete customProps.autoFocus;\n\n let initialValue = props.value;\n if (initialValue === null) {\n initialValue = props.allowEmpty? null : '';\n }else{\n\n if (typeof initialValue == 'string') {\n // Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\"\n // Now they have two problems.\n\n // Strip out thousand separators, prefix, and suffix, etc.\n if (props.thousandSeparator === \".\"){\n // special handle the . thousand separator\n initialValue = initialValue.replace(/\\./g, '');\n }\n\n if (props.decimalSeparator != \".\"){\n // fix the decimal separator\n initialValue = initialValue.replace(new RegExp(props.decimalSeparator, 'g'), '.');\n }\n\n //Strip out anything that is not a digit, -, or decimal separator\n initialValue = initialValue.replace(/[^0-9-.]/g, '');\n\n // now we can parse.\n initialValue = Number.parseFloat(initialValue);\n }\n initialValue = Number(initialValue).toLocaleString(undefined, {\n style : 'decimal',\n minimumFractionDigits: props.precision,\n maximumFractionDigits: props.precision\n })\n\n }\n\n const { maskedValue, value } = mask(\n initialValue,\n props.precision,\n props.decimalSeparator,\n props.thousandSeparator,\n props.allowNegative,\n props.prefix,\n props.suffix\n );\n\n return { maskedValue, value, customProps };\n }\n\n\n /**\n * Component lifecycle function.\n * Invoked when a component is receiving new props. This method is not called for the initial render.\n *\n * @param nextProps\n * @see https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops\n */\n componentWillReceiveProps(nextProps) {\n this.setState(this.prepareProps(nextProps));\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidmount\n */\n componentDidMount(){\n let node = ReactDOM.findDOMNode(this.theInput);\n let selectionStart, selectionEnd;\n\n if (this.props.autoFocus) {\n this.theInput.focus();\n selectionEnd = this.state.maskedValue.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n } else {\n selectionEnd = Math.min(node.selectionEnd, this.theInput.value.length - this.props.suffix.length);\n selectionStart = Math.min(node.selectionStart, selectionEnd);\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n }\n\n\n /**\n * Component lifecycle function\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentwillupdate\n */\n componentWillUpdate() {\n let node = ReactDOM.findDOMNode(this.theInput);\n this.inputSelectionStart = node.selectionStart;\n this.inputSelectionEnd = node.selectionEnd;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidupdate\n */\n componentDidUpdate(prevProps, prevState){\n const { decimalSeparator } = this.props;\n let node = ReactDOM.findDOMNode(this.theInput);\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let minPos = this.props.prefix.length + (isNegative ? 1 : 0);\n let selectionEnd = Math.max(minPos, Math.min(this.inputSelectionEnd, this.theInput.value.length - this.props.suffix.length));\n let selectionStart = Math.max(minPos, Math.min(this.inputSelectionEnd, selectionEnd));\n\n let regexEscapeRegex = /[-[\\]{}()*+?.,\\\\^$|#\\s]/g;\n let separatorsRegex = new RegExp(decimalSeparator.replace(regexEscapeRegex, '\\\\$&') + '|' + this.props.thousandSeparator.replace(regexEscapeRegex, '\\\\$&'), 'g');\n let currSeparatorCount = (this.state.maskedValue.match(separatorsRegex) || []).length;\n let prevSeparatorCount = (prevState.maskedValue.match(separatorsRegex) || []).length;\n let adjustment = Math.max(currSeparatorCount - prevSeparatorCount, 0);\n\n selectionEnd = selectionEnd + adjustment;\n selectionStart = selectionStart + adjustment;\n\n const precision = Number(this.props.precision);\n\n let baselength = this.props.suffix.length\n + this.props.prefix.length\n + (precision > 0 ? decimalSeparator.length : 0) // if precision is 0 there will be no decimal part\n + precision\n + 1; // This is to account for the default '0' value that comes before the decimal separator\n\n if (this.state.maskedValue.length == baselength){\n // if we are already at base length, position the cursor at the end.\n selectionEnd = this.theInput.value.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n /**\n * onChange Event Handler\n * @param event\n */\n handleChange(event) {\n event.preventDefault();\n let { maskedValue, value } = mask(\n event.target.value,\n this.props.precision,\n this.props.decimalSeparator,\n this.props.thousandSeparator,\n this.props.allowNegative,\n this.props.prefix,\n this.props.suffix\n );\n\n event.persist(); // fixes issue #23\n\n this.setState({ maskedValue, value }, () => {\n this.props.onChange(maskedValue, value, event);\n this.props.onChangeEvent(event, maskedValue, value);\n });\n }\n\n\n /**\n * onFocus Event Handler\n * @param event\n */\n handleFocus(event) {\n if (!this.theInput) return;\n\n //Whenever we receive focus check to see if the position is before the suffix, if not, move it.\n let selectionEnd = this.theInput.value.length - this.props.suffix.length;\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let selectionStart = this.props.prefix.length + (isNegative ? 1 : 0);\n this.props.selectAllOnFocus && event.target.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n handleBlur(event) {\n this.inputSelectionStart = 0;\n this.inputSelectionEnd = 0;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/component-specs.html#render\n */\n render() {\n return (\n { this.theInput = input; }}\n type={this.props.inputType}\n value={this.state.maskedValue}\n onChange={this.handleChange}\n onFocus={this.handleFocus}\n onMouseUp={this.handleFocus}\n {...this.state.customProps}\n />\n )\n }\n}\n\n\n\n/**\n * Prop validation.\n * @see https://facebook.github.io/react/docs/component-specs.html#proptypes\n */\n\nCurrencyInput.propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n decimalSeparator: PropTypes.string,\n thousandSeparator: PropTypes.string,\n precision: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n inputType: PropTypes.string,\n allowNegative: PropTypes.bool,\n allowEmpty: PropTypes.bool,\n prefix: PropTypes.string,\n suffix: PropTypes.string,\n selectAllOnFocus: PropTypes.bool\n};\n\n\nCurrencyInput.defaultProps = {\n onChange: function(maskValue, value, event) {/*no-op*/},\n onChangeEvent: function(event, maskValue, value) {/*no-op*/},\n autoFocus: false,\n value: '0',\n decimalSeparator: '.',\n thousandSeparator: ',',\n precision: '2',\n inputType: 'text',\n allowNegative: false,\n prefix: '',\n suffix: '',\n selectAllOnFocus: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CAC7B;SACL;KACJ,CAAA;;;EApPuBE,eAqP3B,GAAA;;;;;;;;;AASD,aAAa,CAAC,SAAS,GAAG;IACtB,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAChE,gBAAgB,EAAE,SAAS,CAAC,MAAM;IAClC,iBAAiB,EAAE,SAAS,CAAC,MAAM;IACnC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACpE,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,aAAa,EAAE,SAAS,CAAC,IAAI;IAC7B,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,gBAAgB,EAAE,SAAS,CAAC,IAAI;CACnC,CAAC;;;AAGF,aAAa,CAAC,YAAY,GAAG;IACzB,QAAQ,EAAE,SAAS,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW;IACvD,aAAa,EAAE,SAAS,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW;IAC5D,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,GAAG;IACV,gBAAgB,EAAE,GAAG;IACrB,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,MAAM;IACjB,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,gBAAgB,EAAE,KAAK;CAC1B,CAAC;;;;"}
\ No newline at end of file
+{"version":3,"file":"react-currency-input.cjs.js","sources":["../src/object-assign-polyfill.js","../src/mask.js","../src/index.js"],"sourcesContent":["Object.assign = Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n","\nexport default function mask(value, precision = 2, decimalSeparator = '.', thousandSeparator = ',', allowNegative = false, prefix = '', suffix = ''){\n // provide some default values and arg validation.\n if (precision < 0) { precision = 0; } // precision cannot be negative\n if (precision > 20) { precision = 20; } // precision cannot be greater than 20\n \n if (value === null || value===undefined) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n \n value = String(value); //if the given value is a Number, let's convert into String to manipulate that\n\n if (value.length == 0) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n\n\n // extract digits. if no digits, fill in a zero.\n let digits = value.match(/\\d/g) || ['0'];\n \n let numberIsNegative = false;\n if (allowNegative) {\n let negativeSignCount = (value.match(/-/g) || []).length;\n // number will be negative if we have an odd number of \"-\"\n // ideally, we should only ever have 0, 1 or 2 (positive number, making a number negative\n // and making a negative number positive, respectively)\n numberIsNegative = negativeSignCount % 2 === 1;\n \n // if every digit in the array is '0', then the number should never be negative\n let allDigitsAreZero = true;\n for (let idx=0; idx < digits.length; idx += 1) {\n if(digits[idx] !== '0') {\n allDigitsAreZero = false;\n break;\n }\n }\n if (allDigitsAreZero) {\n numberIsNegative = false;\n }\n }\n\n // zero-pad a input\n while (digits.length <= precision) { digits.unshift('0'); }\n\n if (precision > 0) {\n // add the decimal separator\n digits.splice(digits.length - precision, 0, \".\");\n }\n\n // clean up extraneous digits like leading zeros.\n digits = Number(digits.join('')).toFixed(precision).split('');\n let raw = Number(digits.join(''));\n\n let decimalpos = digits.length - precision - 1; // -1 needed to position the decimal separator before the digits.\n if (precision > 0) {\n // set the final decimal separator\n digits[decimalpos] = decimalSeparator;\n } else {\n // when precision is 0, there is no decimal separator.\n decimalpos = digits.length;\n }\n\n // add in any thousand separators\n for (let x=decimalpos - 3; x > 0; x = x - 3) {\n digits.splice(x, 0, thousandSeparator);\n }\n\n // if we have a prefix or suffix, add them in.\n if (prefix.length > 0) { digits.unshift(prefix); }\n if (suffix.length > 0) { digits.push(suffix); }\n\n // if the number is negative, insert a \"-\" to\n // the front of the array and negate the raw value\n if (allowNegative && numberIsNegative) {\n digits.unshift('-');\n raw = -raw;\n }\n\n return {\n value: raw,\n maskedValue: digits.join('').trim()\n };\n}\n","import './object-assign-polyfill';\n\nimport PropTypes from 'prop-types';\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport mask from './mask.js'\n\n// IE* parseFloat polyfill\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat#Polyfill\nNumber.parseFloat = parseFloat;\n\nclass CurrencyInput extends Component {\n constructor(props) {\n super(props);\n this.prepareProps = this.prepareProps.bind(this);\n this.handleChange = this.handleChange.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.state = this.prepareProps(this.props);\n\n this.inputSelectionStart = 1;\n this.inputSelectionEnd = 1;\n }\n\n\n /**\n * Exposes the current masked value.\n *\n * @returns {String}\n */\n getMaskedValue() {\n return this.state.maskedValue;\n }\n\n\n /**\n * General function used to cleanup and define the final props used for rendering\n * @returns {{ maskedValue: {String}, value: {Number}, customProps: {Object} }}\n */\n prepareProps(props) {\n let customProps = {...props}; // babeljs converts to Object.assign, then polyfills.\n delete customProps.onChange;\n delete customProps.onChangeEvent;\n delete customProps.value;\n delete customProps.decimalSeparator;\n delete customProps.thousandSeparator;\n delete customProps.precision;\n delete customProps.inputType;\n delete customProps.allowNegative;\n delete customProps.allowEmpty;\n delete customProps.prefix;\n delete customProps.suffix;\n delete customProps.selectAllOnFocus;\n delete customProps.autoFocus;\n delete customProps.maxValue;\n delete customProps.minValue;\n\n let initialValue = props.value;\n if (initialValue === null) {\n initialValue = props.allowEmpty? null : '';\n }else{\n\n if (typeof initialValue == 'string') {\n // Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\"\n // Now they have two problems.\n\n // Strip out thousand separators, prefix, and suffix, etc.\n if (props.thousandSeparator === \".\"){\n // special handle the . thousand separator\n initialValue = initialValue.replace(/\\./g, '');\n }\n\n if (props.decimalSeparator != \".\"){\n // fix the decimal separator\n initialValue = initialValue.replace(new RegExp(props.decimalSeparator, 'g'), '.');\n }\n\n //Strip out anything that is not a digit, -, or decimal separator\n initialValue = initialValue.replace(/[^0-9-.]/g, '');\n\n // now we can parse.\n initialValue = Number.parseFloat(initialValue);\n }\n initialValue = Number(initialValue).toLocaleString(undefined, {\n style : 'decimal',\n minimumFractionDigits: props.precision,\n maximumFractionDigits: props.precision\n })\n\n }\n\n const { maskedValue, value } = mask(\n initialValue,\n props.precision,\n props.decimalSeparator,\n props.thousandSeparator,\n props.allowNegative,\n props.prefix,\n props.suffix\n );\n\n return { maskedValue, value, customProps };\n }\n\n\n /**\n * Component lifecycle function.\n * Invoked when a component is receiving new props. This method is not called for the initial render.\n *\n * @param nextProps\n * @see https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops\n */\n componentWillReceiveProps(nextProps) {\n this.setState(this.prepareProps(nextProps));\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidmount\n */\n componentDidMount(){\n let node = ReactDOM.findDOMNode(this.theInput);\n let selectionStart, selectionEnd;\n\n if (this.props.autoFocus) {\n this.theInput.focus();\n selectionEnd = this.state.maskedValue.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n } else {\n selectionEnd = Math.min(node.selectionEnd, this.theInput.value.length - this.props.suffix.length);\n selectionStart = Math.min(node.selectionStart, selectionEnd);\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n }\n\n\n /**\n * Component lifecycle function\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentwillupdate\n */\n componentWillUpdate() {\n let node = ReactDOM.findDOMNode(this.theInput);\n this.inputSelectionStart = node.selectionStart;\n this.inputSelectionEnd = node.selectionEnd;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidupdate\n */\n componentDidUpdate(prevProps, prevState){\n const { decimalSeparator } = this.props;\n let node = ReactDOM.findDOMNode(this.theInput);\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let minPos = this.props.prefix.length + (isNegative ? 1 : 0);\n let selectionEnd = Math.max(minPos, Math.min(this.inputSelectionEnd, this.theInput.value.length - this.props.suffix.length));\n let selectionStart = Math.max(minPos, Math.min(this.inputSelectionEnd, selectionEnd));\n\n let regexEscapeRegex = /[-[\\]{}()*+?.,\\\\^$|#\\s]/g;\n let separatorsRegex = new RegExp(decimalSeparator.replace(regexEscapeRegex, '\\\\$&') + '|' + this.props.thousandSeparator.replace(regexEscapeRegex, '\\\\$&'), 'g');\n let currSeparatorCount = (this.state.maskedValue.match(separatorsRegex) || []).length;\n let prevSeparatorCount = (prevState.maskedValue.match(separatorsRegex) || []).length;\n let adjustment = Math.max(currSeparatorCount - prevSeparatorCount, 0);\n\n selectionEnd = selectionEnd + adjustment;\n selectionStart = selectionStart + adjustment;\n\n const precision = Number(this.props.precision);\n\n let baselength = this.props.suffix.length\n + this.props.prefix.length\n + (precision > 0 ? decimalSeparator.length : 0) // if precision is 0 there will be no decimal part\n + precision\n + 1; // This is to account for the default '0' value that comes before the decimal separator\n\n if (this.state.maskedValue.length == baselength){\n // if we are already at base length, position the cursor at the end.\n selectionEnd = this.theInput.value.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n /**\n * onChange Event Handler\n * @param event\n */\n handleChange(event) {\n event.preventDefault();\n\n let { maskedValue, value } = mask(\n event.target.value,\n this.props.precision,\n this.props.decimalSeparator,\n this.props.thousandSeparator,\n this.props.allowNegative,\n this.props.prefix,\n this.props.suffix\n );\n\n if ((this.props.maxValue && value > this.props.maxValue)\n || (this.props.minValue && value < this.props.maxValue)) {\n // if value exceeds min & max limits, do nothing...\n return;\n }\n\n event.persist(); // fixes issue #23\n\n this.setState({ maskedValue, value }, () => {\n this.props.onChange(maskedValue, value, event);\n this.props.onChangeEvent(event, maskedValue, value);\n });\n }\n\n\n /**\n * onFocus Event Handler\n * @param event\n */\n handleFocus(event) {\n if (!this.theInput) return;\n\n //Whenever we receive focus check to see if the position is before the suffix, if not, move it.\n let selectionEnd = this.theInput.value.length - this.props.suffix.length;\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let selectionStart = this.props.prefix.length + (isNegative ? 1 : 0);\n this.props.selectAllOnFocus && event.target.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n handleBlur(event) {\n this.inputSelectionStart = 0;\n this.inputSelectionEnd = 0;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/component-specs.html#render\n */\n render() {\n return (\n { this.theInput = input; }}\n type={this.props.inputType}\n value={this.state.maskedValue}\n onChange={this.handleChange}\n onFocus={this.handleFocus}\n onMouseUp={this.handleFocus}\n {...this.state.customProps}\n />\n )\n }\n}\n\n\n\n/**\n * Prop validation.\n * @see https://facebook.github.io/react/docs/component-specs.html#proptypes\n */\n\nCurrencyInput.propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n decimalSeparator: PropTypes.string,\n thousandSeparator: PropTypes.string,\n precision: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n inputType: PropTypes.string,\n allowNegative: PropTypes.bool,\n allowEmpty: PropTypes.bool,\n prefix: PropTypes.string,\n suffix: PropTypes.string,\n selectAllOnFocus: PropTypes.bool\n};\n\n\nCurrencyInput.defaultProps = {\n onChange: function(maskValue, value, event) {/*no-op*/},\n onChangeEvent: function(event, maskValue, value) {/*no-op*/},\n autoFocus: false,\n value: '0',\n decimalSeparator: '.',\n thousandSeparator: ',',\n precision: '2',\n inputType: 'text',\n allowNegative: false,\n prefix: '',\n suffix: '',\n selectAllOnFocus: false,\n maxValue: undefined,\n minValue: undefined\n};\n\n\nexport default CurrencyInput\n"],"names":["arguments","let","super","const","this","React","Component"],"mappings":";;;;;;;;;AAAA,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;EAC3B,SAAS,MAAM,EAAE;;;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;MACzC,IAAI,MAAM,GAAGA,WAAS,CAAC,CAAC,CAAC,CAAC;MAC1B,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;QACtB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;UACrD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;SAC3B;OACF;KACF;IACD,OAAO,MAAM,CAAC;GACf,CAAC;;ACVW,SAAS,IAAI,CAAC,KAAK,EAAE,SAAa,EAAE,gBAAsB,EAAE,iBAAuB,EAAE,aAAqB,EAAE,MAAW,EAAE,MAAW,CAAC;yCAAvG,GAAG,CAAC,CAAkB;uDAAA,GAAG,GAAG,CAAmB;yDAAA,GAAG,GAAG,CAAe;iDAAA,GAAG,KAAK,CAAQ;mCAAA,GAAG,EAAE,CAAQ;mCAAA,GAAG,EAAE;;;IAE/I,IAAI,SAAS,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,CAAC,CAAC,EAAE;IACrC,IAAI,SAAS,GAAG,EAAE,EAAE,EAAE,SAAS,GAAG,EAAE,CAAC,EAAE;;IAEvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,GAAG,SAAS,EAAE;UACnC,OAAO;cACH,KAAK,EAAE,CAAC;cACR,WAAW,EAAE,EAAE;WAClB,CAAC;MACN;;IAEF,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;;IAEtB,IAAI,KAAK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EAAE,GAAG;IACrB,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,MAAM;IACjB,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,gBAAgB,EAAE,KAAK;IACvB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;CACtB,CAAC;;;;"}
\ No newline at end of file
diff --git a/lib/react-currency-input.es.js b/lib/react-currency-input.es.js
index 1aa64b3..07bfc95 100644
--- a/lib/react-currency-input.es.js
+++ b/lib/react-currency-input.es.js
@@ -163,6 +163,8 @@ var CurrencyInput = (function (Component$$1) {
delete customProps.suffix;
delete customProps.selectAllOnFocus;
delete customProps.autoFocus;
+ delete customProps.maxValue;
+ delete customProps.minValue;
var initialValue = props.value;
if (initialValue === null) {
@@ -311,6 +313,7 @@ var CurrencyInput = (function (Component$$1) {
var this$1 = this;
event.preventDefault();
+
var ref = mask(
event.target.value,
this.props.precision,
@@ -323,6 +326,12 @@ var CurrencyInput = (function (Component$$1) {
var maskedValue = ref.maskedValue;
var value = ref.value;
+ if ((this.props.maxValue && value > this.props.maxValue)
+ || (this.props.minValue && value < this.props.maxValue)) {
+ // if value exceeds min & max limits, do nothing...
+ return;
+ }
+
event.persist(); // fixes issue #23
this.setState({ maskedValue: maskedValue, value: value }, function () {
@@ -406,7 +415,9 @@ CurrencyInput.defaultProps = {
allowNegative: false,
prefix: '',
suffix: '',
- selectAllOnFocus: false
+ selectAllOnFocus: false,
+ maxValue: undefined,
+ minValue: undefined
};
export default CurrencyInput;
diff --git a/lib/react-currency-input.es.js.map b/lib/react-currency-input.es.js.map
index aef02bc..f1701e9 100644
--- a/lib/react-currency-input.es.js.map
+++ b/lib/react-currency-input.es.js.map
@@ -1 +1 @@
-{"version":3,"file":"react-currency-input.es.js","sources":["../src/object-assign-polyfill.js","../src/mask.js","../src/index.js"],"sourcesContent":["Object.assign = Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n","\nexport default function mask(value, precision = 2, decimalSeparator = '.', thousandSeparator = ',', allowNegative = false, prefix = '', suffix = ''){\n // provide some default values and arg validation.\n if (precision < 0) { precision = 0; } // precision cannot be negative\n if (precision > 20) { precision = 20; } // precision cannot be greater than 20\n \n if (value === null || value===undefined) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n \n value = String(value); //if the given value is a Number, let's convert into String to manipulate that\n\n if (value.length == 0) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n\n\n // extract digits. if no digits, fill in a zero.\n let digits = value.match(/\\d/g) || ['0'];\n \n let numberIsNegative = false;\n if (allowNegative) {\n let negativeSignCount = (value.match(/-/g) || []).length;\n // number will be negative if we have an odd number of \"-\"\n // ideally, we should only ever have 0, 1 or 2 (positive number, making a number negative\n // and making a negative number positive, respectively)\n numberIsNegative = negativeSignCount % 2 === 1;\n \n // if every digit in the array is '0', then the number should never be negative\n let allDigitsAreZero = true;\n for (let idx=0; idx < digits.length; idx += 1) {\n if(digits[idx] !== '0') {\n allDigitsAreZero = false;\n break;\n }\n }\n if (allDigitsAreZero) {\n numberIsNegative = false;\n }\n }\n\n // zero-pad a input\n while (digits.length <= precision) { digits.unshift('0'); }\n\n if (precision > 0) {\n // add the decimal separator\n digits.splice(digits.length - precision, 0, \".\");\n }\n\n // clean up extraneous digits like leading zeros.\n digits = Number(digits.join('')).toFixed(precision).split('');\n let raw = Number(digits.join(''));\n\n let decimalpos = digits.length - precision - 1; // -1 needed to position the decimal separator before the digits.\n if (precision > 0) {\n // set the final decimal separator\n digits[decimalpos] = decimalSeparator;\n } else {\n // when precision is 0, there is no decimal separator.\n decimalpos = digits.length;\n }\n\n // add in any thousand separators\n for (let x=decimalpos - 3; x > 0; x = x - 3) {\n digits.splice(x, 0, thousandSeparator);\n }\n\n // if we have a prefix or suffix, add them in.\n if (prefix.length > 0) { digits.unshift(prefix); }\n if (suffix.length > 0) { digits.push(suffix); }\n\n // if the number is negative, insert a \"-\" to\n // the front of the array and negate the raw value\n if (allowNegative && numberIsNegative) {\n digits.unshift('-');\n raw = -raw;\n }\n\n return {\n value: raw,\n maskedValue: digits.join('').trim()\n };\n}\n","import './object-assign-polyfill';\n\nimport PropTypes from 'prop-types';\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport mask from './mask.js'\n\n// IE* parseFloat polyfill\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat#Polyfill\nNumber.parseFloat = parseFloat;\n\nclass CurrencyInput extends Component {\n constructor(props) {\n super(props);\n this.prepareProps = this.prepareProps.bind(this);\n this.handleChange = this.handleChange.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.state = this.prepareProps(this.props);\n\n this.inputSelectionStart = 1;\n this.inputSelectionEnd = 1;\n }\n\n\n /**\n * Exposes the current masked value.\n *\n * @returns {String}\n */\n getMaskedValue() {\n return this.state.maskedValue;\n }\n\n\n /**\n * General function used to cleanup and define the final props used for rendering\n * @returns {{ maskedValue: {String}, value: {Number}, customProps: {Object} }}\n */\n prepareProps(props) {\n let customProps = {...props}; // babeljs converts to Object.assign, then polyfills.\n delete customProps.onChange;\n delete customProps.onChangeEvent;\n delete customProps.value;\n delete customProps.decimalSeparator;\n delete customProps.thousandSeparator;\n delete customProps.precision;\n delete customProps.inputType;\n delete customProps.allowNegative;\n delete customProps.allowEmpty;\n delete customProps.prefix;\n delete customProps.suffix;\n delete customProps.selectAllOnFocus;\n delete customProps.autoFocus;\n\n let initialValue = props.value;\n if (initialValue === null) {\n initialValue = props.allowEmpty? null : '';\n }else{\n\n if (typeof initialValue == 'string') {\n // Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\"\n // Now they have two problems.\n\n // Strip out thousand separators, prefix, and suffix, etc.\n if (props.thousandSeparator === \".\"){\n // special handle the . thousand separator\n initialValue = initialValue.replace(/\\./g, '');\n }\n\n if (props.decimalSeparator != \".\"){\n // fix the decimal separator\n initialValue = initialValue.replace(new RegExp(props.decimalSeparator, 'g'), '.');\n }\n\n //Strip out anything that is not a digit, -, or decimal separator\n initialValue = initialValue.replace(/[^0-9-.]/g, '');\n\n // now we can parse.\n initialValue = Number.parseFloat(initialValue);\n }\n initialValue = Number(initialValue).toLocaleString(undefined, {\n style : 'decimal',\n minimumFractionDigits: props.precision,\n maximumFractionDigits: props.precision\n })\n\n }\n\n const { maskedValue, value } = mask(\n initialValue,\n props.precision,\n props.decimalSeparator,\n props.thousandSeparator,\n props.allowNegative,\n props.prefix,\n props.suffix\n );\n\n return { maskedValue, value, customProps };\n }\n\n\n /**\n * Component lifecycle function.\n * Invoked when a component is receiving new props. This method is not called for the initial render.\n *\n * @param nextProps\n * @see https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops\n */\n componentWillReceiveProps(nextProps) {\n this.setState(this.prepareProps(nextProps));\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidmount\n */\n componentDidMount(){\n let node = ReactDOM.findDOMNode(this.theInput);\n let selectionStart, selectionEnd;\n\n if (this.props.autoFocus) {\n this.theInput.focus();\n selectionEnd = this.state.maskedValue.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n } else {\n selectionEnd = Math.min(node.selectionEnd, this.theInput.value.length - this.props.suffix.length);\n selectionStart = Math.min(node.selectionStart, selectionEnd);\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n }\n\n\n /**\n * Component lifecycle function\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentwillupdate\n */\n componentWillUpdate() {\n let node = ReactDOM.findDOMNode(this.theInput);\n this.inputSelectionStart = node.selectionStart;\n this.inputSelectionEnd = node.selectionEnd;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidupdate\n */\n componentDidUpdate(prevProps, prevState){\n const { decimalSeparator } = this.props;\n let node = ReactDOM.findDOMNode(this.theInput);\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let minPos = this.props.prefix.length + (isNegative ? 1 : 0);\n let selectionEnd = Math.max(minPos, Math.min(this.inputSelectionEnd, this.theInput.value.length - this.props.suffix.length));\n let selectionStart = Math.max(minPos, Math.min(this.inputSelectionEnd, selectionEnd));\n\n let regexEscapeRegex = /[-[\\]{}()*+?.,\\\\^$|#\\s]/g;\n let separatorsRegex = new RegExp(decimalSeparator.replace(regexEscapeRegex, '\\\\$&') + '|' + this.props.thousandSeparator.replace(regexEscapeRegex, '\\\\$&'), 'g');\n let currSeparatorCount = (this.state.maskedValue.match(separatorsRegex) || []).length;\n let prevSeparatorCount = (prevState.maskedValue.match(separatorsRegex) || []).length;\n let adjustment = Math.max(currSeparatorCount - prevSeparatorCount, 0);\n\n selectionEnd = selectionEnd + adjustment;\n selectionStart = selectionStart + adjustment;\n\n const precision = Number(this.props.precision);\n\n let baselength = this.props.suffix.length\n + this.props.prefix.length\n + (precision > 0 ? decimalSeparator.length : 0) // if precision is 0 there will be no decimal part\n + precision\n + 1; // This is to account for the default '0' value that comes before the decimal separator\n\n if (this.state.maskedValue.length == baselength){\n // if we are already at base length, position the cursor at the end.\n selectionEnd = this.theInput.value.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n /**\n * onChange Event Handler\n * @param event\n */\n handleChange(event) {\n event.preventDefault();\n let { maskedValue, value } = mask(\n event.target.value,\n this.props.precision,\n this.props.decimalSeparator,\n this.props.thousandSeparator,\n this.props.allowNegative,\n this.props.prefix,\n this.props.suffix\n );\n\n event.persist(); // fixes issue #23\n\n this.setState({ maskedValue, value }, () => {\n this.props.onChange(maskedValue, value, event);\n this.props.onChangeEvent(event, maskedValue, value);\n });\n }\n\n\n /**\n * onFocus Event Handler\n * @param event\n */\n handleFocus(event) {\n if (!this.theInput) return;\n\n //Whenever we receive focus check to see if the position is before the suffix, if not, move it.\n let selectionEnd = this.theInput.value.length - this.props.suffix.length;\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let selectionStart = this.props.prefix.length + (isNegative ? 1 : 0);\n this.props.selectAllOnFocus && event.target.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n handleBlur(event) {\n this.inputSelectionStart = 0;\n this.inputSelectionEnd = 0;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/component-specs.html#render\n */\n render() {\n return (\n { this.theInput = input; }}\n type={this.props.inputType}\n value={this.state.maskedValue}\n onChange={this.handleChange}\n onFocus={this.handleFocus}\n onMouseUp={this.handleFocus}\n {...this.state.customProps}\n />\n )\n }\n}\n\n\n\n/**\n * Prop validation.\n * @see https://facebook.github.io/react/docs/component-specs.html#proptypes\n */\n\nCurrencyInput.propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n decimalSeparator: PropTypes.string,\n thousandSeparator: PropTypes.string,\n precision: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n inputType: PropTypes.string,\n allowNegative: PropTypes.bool,\n allowEmpty: PropTypes.bool,\n prefix: PropTypes.string,\n suffix: PropTypes.string,\n selectAllOnFocus: PropTypes.bool\n};\n\n\nCurrencyInput.defaultProps = {\n onChange: function(maskValue, value, event) {/*no-op*/},\n onChangeEvent: function(event, maskValue, value) {/*no-op*/},\n autoFocus: false,\n value: '0',\n decimalSeparator: '.',\n thousandSeparator: ',',\n precision: '2',\n inputType: 'text',\n allowNegative: false,\n prefix: '',\n suffix: '',\n selectAllOnFocus: false\n};\n\n\nexport default CurrencyInput\n"],"names":["arguments","let","super","const","this"],"mappings":";;;;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C,SAAS,GAAG;IACtB,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAChE,gBAAgB,EAAE,SAAS,CAAC,MAAM;IAClC,iBAAiB,EAAE,SAAS,CAAC,MAAM;IACnC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACpE,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,aAAa,EAAE,SAAS,CAAC,IAAI;IAC7B,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,gBAAgB,EAAE,SAAS,CAAC,IAAI;CACnC,CAAC;;;AAGF,aAAa,CAAC,YAAY,GAAG;IACzB,QAAQ,EAAE,SAAS,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW;IACvD,aAAa,EAAE,SAAS,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW;IAC5D,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,GAAG;IACV,gBAAgB,EAAE,GAAG;IACrB,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,MAAM;IACjB,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,gBAAgB,EAAE,KAAK;CAC1B,CAAC;;;;"}
\ No newline at end of file
+{"version":3,"file":"react-currency-input.es.js","sources":["../src/object-assign-polyfill.js","../src/mask.js","../src/index.js"],"sourcesContent":["Object.assign = Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n","\nexport default function mask(value, precision = 2, decimalSeparator = '.', thousandSeparator = ',', allowNegative = false, prefix = '', suffix = ''){\n // provide some default values and arg validation.\n if (precision < 0) { precision = 0; } // precision cannot be negative\n if (precision > 20) { precision = 20; } // precision cannot be greater than 20\n \n if (value === null || value===undefined) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n \n value = String(value); //if the given value is a Number, let's convert into String to manipulate that\n\n if (value.length == 0) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n\n\n // extract digits. if no digits, fill in a zero.\n let digits = value.match(/\\d/g) || ['0'];\n \n let numberIsNegative = false;\n if (allowNegative) {\n let negativeSignCount = (value.match(/-/g) || []).length;\n // number will be negative if we have an odd number of \"-\"\n // ideally, we should only ever have 0, 1 or 2 (positive number, making a number negative\n // and making a negative number positive, respectively)\n numberIsNegative = negativeSignCount % 2 === 1;\n \n // if every digit in the array is '0', then the number should never be negative\n let allDigitsAreZero = true;\n for (let idx=0; idx < digits.length; idx += 1) {\n if(digits[idx] !== '0') {\n allDigitsAreZero = false;\n break;\n }\n }\n if (allDigitsAreZero) {\n numberIsNegative = false;\n }\n }\n\n // zero-pad a input\n while (digits.length <= precision) { digits.unshift('0'); }\n\n if (precision > 0) {\n // add the decimal separator\n digits.splice(digits.length - precision, 0, \".\");\n }\n\n // clean up extraneous digits like leading zeros.\n digits = Number(digits.join('')).toFixed(precision).split('');\n let raw = Number(digits.join(''));\n\n let decimalpos = digits.length - precision - 1; // -1 needed to position the decimal separator before the digits.\n if (precision > 0) {\n // set the final decimal separator\n digits[decimalpos] = decimalSeparator;\n } else {\n // when precision is 0, there is no decimal separator.\n decimalpos = digits.length;\n }\n\n // add in any thousand separators\n for (let x=decimalpos - 3; x > 0; x = x - 3) {\n digits.splice(x, 0, thousandSeparator);\n }\n\n // if we have a prefix or suffix, add them in.\n if (prefix.length > 0) { digits.unshift(prefix); }\n if (suffix.length > 0) { digits.push(suffix); }\n\n // if the number is negative, insert a \"-\" to\n // the front of the array and negate the raw value\n if (allowNegative && numberIsNegative) {\n digits.unshift('-');\n raw = -raw;\n }\n\n return {\n value: raw,\n maskedValue: digits.join('').trim()\n };\n}\n","import './object-assign-polyfill';\n\nimport PropTypes from 'prop-types';\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport mask from './mask.js'\n\n// IE* parseFloat polyfill\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat#Polyfill\nNumber.parseFloat = parseFloat;\n\nclass CurrencyInput extends Component {\n constructor(props) {\n super(props);\n this.prepareProps = this.prepareProps.bind(this);\n this.handleChange = this.handleChange.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.state = this.prepareProps(this.props);\n\n this.inputSelectionStart = 1;\n this.inputSelectionEnd = 1;\n }\n\n\n /**\n * Exposes the current masked value.\n *\n * @returns {String}\n */\n getMaskedValue() {\n return this.state.maskedValue;\n }\n\n\n /**\n * General function used to cleanup and define the final props used for rendering\n * @returns {{ maskedValue: {String}, value: {Number}, customProps: {Object} }}\n */\n prepareProps(props) {\n let customProps = {...props}; // babeljs converts to Object.assign, then polyfills.\n delete customProps.onChange;\n delete customProps.onChangeEvent;\n delete customProps.value;\n delete customProps.decimalSeparator;\n delete customProps.thousandSeparator;\n delete customProps.precision;\n delete customProps.inputType;\n delete customProps.allowNegative;\n delete customProps.allowEmpty;\n delete customProps.prefix;\n delete customProps.suffix;\n delete customProps.selectAllOnFocus;\n delete customProps.autoFocus;\n delete customProps.maxValue;\n delete customProps.minValue;\n\n let initialValue = props.value;\n if (initialValue === null) {\n initialValue = props.allowEmpty? null : '';\n }else{\n\n if (typeof initialValue == 'string') {\n // Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\"\n // Now they have two problems.\n\n // Strip out thousand separators, prefix, and suffix, etc.\n if (props.thousandSeparator === \".\"){\n // special handle the . thousand separator\n initialValue = initialValue.replace(/\\./g, '');\n }\n\n if (props.decimalSeparator != \".\"){\n // fix the decimal separator\n initialValue = initialValue.replace(new RegExp(props.decimalSeparator, 'g'), '.');\n }\n\n //Strip out anything that is not a digit, -, or decimal separator\n initialValue = initialValue.replace(/[^0-9-.]/g, '');\n\n // now we can parse.\n initialValue = Number.parseFloat(initialValue);\n }\n initialValue = Number(initialValue).toLocaleString(undefined, {\n style : 'decimal',\n minimumFractionDigits: props.precision,\n maximumFractionDigits: props.precision\n })\n\n }\n\n const { maskedValue, value } = mask(\n initialValue,\n props.precision,\n props.decimalSeparator,\n props.thousandSeparator,\n props.allowNegative,\n props.prefix,\n props.suffix\n );\n\n return { maskedValue, value, customProps };\n }\n\n\n /**\n * Component lifecycle function.\n * Invoked when a component is receiving new props. This method is not called for the initial render.\n *\n * @param nextProps\n * @see https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops\n */\n componentWillReceiveProps(nextProps) {\n this.setState(this.prepareProps(nextProps));\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidmount\n */\n componentDidMount(){\n let node = ReactDOM.findDOMNode(this.theInput);\n let selectionStart, selectionEnd;\n\n if (this.props.autoFocus) {\n this.theInput.focus();\n selectionEnd = this.state.maskedValue.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n } else {\n selectionEnd = Math.min(node.selectionEnd, this.theInput.value.length - this.props.suffix.length);\n selectionStart = Math.min(node.selectionStart, selectionEnd);\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n }\n\n\n /**\n * Component lifecycle function\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentwillupdate\n */\n componentWillUpdate() {\n let node = ReactDOM.findDOMNode(this.theInput);\n this.inputSelectionStart = node.selectionStart;\n this.inputSelectionEnd = node.selectionEnd;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidupdate\n */\n componentDidUpdate(prevProps, prevState){\n const { decimalSeparator } = this.props;\n let node = ReactDOM.findDOMNode(this.theInput);\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let minPos = this.props.prefix.length + (isNegative ? 1 : 0);\n let selectionEnd = Math.max(minPos, Math.min(this.inputSelectionEnd, this.theInput.value.length - this.props.suffix.length));\n let selectionStart = Math.max(minPos, Math.min(this.inputSelectionEnd, selectionEnd));\n\n let regexEscapeRegex = /[-[\\]{}()*+?.,\\\\^$|#\\s]/g;\n let separatorsRegex = new RegExp(decimalSeparator.replace(regexEscapeRegex, '\\\\$&') + '|' + this.props.thousandSeparator.replace(regexEscapeRegex, '\\\\$&'), 'g');\n let currSeparatorCount = (this.state.maskedValue.match(separatorsRegex) || []).length;\n let prevSeparatorCount = (prevState.maskedValue.match(separatorsRegex) || []).length;\n let adjustment = Math.max(currSeparatorCount - prevSeparatorCount, 0);\n\n selectionEnd = selectionEnd + adjustment;\n selectionStart = selectionStart + adjustment;\n\n const precision = Number(this.props.precision);\n\n let baselength = this.props.suffix.length\n + this.props.prefix.length\n + (precision > 0 ? decimalSeparator.length : 0) // if precision is 0 there will be no decimal part\n + precision\n + 1; // This is to account for the default '0' value that comes before the decimal separator\n\n if (this.state.maskedValue.length == baselength){\n // if we are already at base length, position the cursor at the end.\n selectionEnd = this.theInput.value.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n /**\n * onChange Event Handler\n * @param event\n */\n handleChange(event) {\n event.preventDefault();\n\n let { maskedValue, value } = mask(\n event.target.value,\n this.props.precision,\n this.props.decimalSeparator,\n this.props.thousandSeparator,\n this.props.allowNegative,\n this.props.prefix,\n this.props.suffix\n );\n\n if ((this.props.maxValue && value > this.props.maxValue)\n || (this.props.minValue && value < this.props.maxValue)) {\n // if value exceeds min & max limits, do nothing...\n return;\n }\n\n event.persist(); // fixes issue #23\n\n this.setState({ maskedValue, value }, () => {\n this.props.onChange(maskedValue, value, event);\n this.props.onChangeEvent(event, maskedValue, value);\n });\n }\n\n\n /**\n * onFocus Event Handler\n * @param event\n */\n handleFocus(event) {\n if (!this.theInput) return;\n\n //Whenever we receive focus check to see if the position is before the suffix, if not, move it.\n let selectionEnd = this.theInput.value.length - this.props.suffix.length;\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let selectionStart = this.props.prefix.length + (isNegative ? 1 : 0);\n this.props.selectAllOnFocus && event.target.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n handleBlur(event) {\n this.inputSelectionStart = 0;\n this.inputSelectionEnd = 0;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/component-specs.html#render\n */\n render() {\n return (\n { this.theInput = input; }}\n type={this.props.inputType}\n value={this.state.maskedValue}\n onChange={this.handleChange}\n onFocus={this.handleFocus}\n onMouseUp={this.handleFocus}\n {...this.state.customProps}\n />\n )\n }\n}\n\n\n\n/**\n * Prop validation.\n * @see https://facebook.github.io/react/docs/component-specs.html#proptypes\n */\n\nCurrencyInput.propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n decimalSeparator: PropTypes.string,\n thousandSeparator: PropTypes.string,\n precision: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n inputType: PropTypes.string,\n allowNegative: PropTypes.bool,\n allowEmpty: PropTypes.bool,\n prefix: PropTypes.string,\n suffix: PropTypes.string,\n selectAllOnFocus: PropTypes.bool\n};\n\n\nCurrencyInput.defaultProps = {\n onChange: function(maskValue, value, event) {/*no-op*/},\n onChangeEvent: function(event, maskValue, value) {/*no-op*/},\n autoFocus: false,\n value: '0',\n decimalSeparator: '.',\n thousandSeparator: ',',\n precision: '2',\n inputType: 'text',\n allowNegative: false,\n prefix: '',\n suffix: '',\n selectAllOnFocus: false,\n maxValue: undefined,\n minValue: undefined\n};\n\n\nex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B,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,gBAAgB,EAAE,KAAK;IACvB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;CACtB,CAAC;;;;"}
\ No newline at end of file
diff --git a/lib/react-currency-input.min.js b/lib/react-currency-input.min.js
index c4141e4..0492475 100644
--- a/lib/react-currency-input.min.js
+++ b/lib/react-currency-input.min.js
@@ -1,2 +1,2 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("prop-types"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["prop-types","react","react-dom"],t):e["react-currency-input"]=t(e.PropTypes,e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var i="default"in t?t.default:t;function a(e,t,n,i,a,o,s){if(void 0===t&&(t=2),void 0===n&&(n="."),void 0===i&&(i=","),void 0===a&&(a=!1),void 0===o&&(o=""),void 0===s&&(s=""),t<0&&(t=0),t>20&&(t=20),null===e||void 0===e)return{value:0,maskedValue:""};if(0==(e=String(e)).length)return{value:0,maskedValue:""};var r=e.match(/\d/g)||["0"],p=!1;if(a){p=(e.match(/-/g)||[]).length%2==1;for(var l=!0,u=0;u0&&r.splice(r.length-t,0,"."),r=Number(r.join("")).toFixed(t).split("");var h=Number(r.join("")),c=r.length-t-1;t>0?r[c]=n:c=r.length;for(var d=c-3;d>0;d-=3)r.splice(d,0,i);return o.length>0&&r.unshift(o),s.length>0&&r.push(s),a&&p&&(r.unshift("-"),h=-h),{value:h,maskedValue:r.join("").trim()}}n=n&&n.hasOwnProperty("default")?n.default:n,Object.assign=Object.assign||function(e){for(var t=arguments,n=1;n0?i.length:0)+f+1;this.state.maskedValue.length==g&&(p=r=this.theInput.value.length-this.props.suffix.length),a.setSelectionRange(p,r),this.inputSelectionStart=p,this.inputSelectionEnd=r},t.prototype.handleChange=function(e){var t=this;e.preventDefault();var n=a(e.target.value,this.props.precision,this.props.decimalSeparator,this.props.thousandSeparator,this.props.allowNegative,this.props.prefix,this.props.suffix),i=n.maskedValue,o=n.value;e.persist(),this.setState({maskedValue:i,value:o},function(){t.props.onChange(i,o,e),t.props.onChangeEvent(e,i,o)})},t.prototype.handleFocus=function(e){if(this.theInput){var t=this.theInput.value.length-this.props.suffix.length,n=(this.theInput.value.match(/-/g)||[]).length%2==1,i=this.props.prefix.length+(n?1:0);this.props.selectAllOnFocus&&e.target.setSelectionRange(i,t),this.inputSelectionStart=i,this.inputSelectionEnd=t}},t.prototype.handleBlur=function(e){this.inputSelectionStart=0,this.inputSelectionEnd=0},t.prototype.render=function(){var e=this;return i.createElement("input",Object.assign({},{ref:function(t){e.theInput=t},type:this.props.inputType,value:this.state.maskedValue,onChange:this.handleChange,onFocus:this.handleFocus,onMouseUp:this.handleFocus},this.state.customProps))},t}(t.Component);return o.propTypes={onChange:e.func,value:e.oneOfType([e.number,e.string]),decimalSeparator:e.string,thousandSeparator:e.string,precision:e.oneOfType([e.number,e.string]),inputType:e.string,allowNegative:e.bool,allowEmpty:e.bool,prefix:e.string,suffix:e.string,selectAllOnFocus:e.bool},o.defaultProps={onChange:function(e,t,n){},onChangeEvent:function(e,t,n){},autoFocus:!1,value:"0",decimalSeparator:".",thousandSeparator:",",precision:"2",inputType:"text",allowNegative:!1,prefix:"",suffix:"",selectAllOnFocus:!1},o});
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("prop-types"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["prop-types","react","react-dom"],t):e["react-currency-input"]=t(e.PropTypes,e.React,e.ReactDOM)}(this,function(e,t,g){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var n="default"in t?t.default:t;function o(e,t,n,i,a,o,s){if(void 0===t&&(t=2),void 0===n&&(n="."),void 0===i&&(i=","),void 0===a&&(a=!1),void 0===o&&(o=""),void 0===s&&(s=""),t<0&&(t=0),20this.props.maxValue||this.props.minValue&&a 20) { precision = 20; } // precision cannot be greater than 20\n \n if (value === null || value===undefined) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n \n value = String(value); //if the given value is a Number, let's convert into String to manipulate that\n\n if (value.length == 0) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n\n\n // extract digits. if no digits, fill in a zero.\n let digits = value.match(/\\d/g) || ['0'];\n \n let numberIsNegative = false;\n if (allowNegative) {\n let negativeSignCount = (value.match(/-/g) || []).length;\n // number will be negative if we have an odd number of \"-\"\n // ideally, we should only ever have 0, 1 or 2 (positive number, making a number negative\n // and making a negative number positive, respectively)\n numberIsNegative = negativeSignCount % 2 === 1;\n \n // if every digit in the array is '0', then the number should never be negative\n let allDigitsAreZero = true;\n for (let idx=0; idx < digits.length; idx += 1) {\n if(digits[idx] !== '0') {\n allDigitsAreZero = false;\n break;\n }\n }\n if (allDigitsAreZero) {\n numberIsNegative = false;\n }\n }\n\n // zero-pad a input\n while (digits.length <= precision) { digits.unshift('0'); }\n\n if (precision > 0) {\n // add the decimal separator\n digits.splice(digits.length - precision, 0, \".\");\n }\n\n // clean up extraneous digits like leading zeros.\n digits = Number(digits.join('')).toFixed(precision).split('');\n let raw = Number(digits.join(''));\n\n let decimalpos = digits.length - precision - 1; // -1 needed to position the decimal separator before the digits.\n if (precision > 0) {\n // set the final decimal separator\n digits[decimalpos] = decimalSeparator;\n } else {\n // when precision is 0, there is no decimal separator.\n decimalpos = digits.length;\n }\n\n // add in any thousand separators\n for (let x=decimalpos - 3; x > 0; x = x - 3) {\n digits.splice(x, 0, thousandSeparator);\n }\n\n // if we have a prefix or suffix, add them in.\n if (prefix.length > 0) { digits.unshift(prefix); }\n if (suffix.length > 0) { digits.push(suffix); }\n\n // if the number is negative, insert a \"-\" to\n // the front of the array and negate the raw value\n if (allowNegative && numberIsNegative) {\n digits.unshift('-');\n raw = -raw;\n }\n\n return {\n value: raw,\n maskedValue: digits.join('').trim()\n };\n}\n","Object.assign = Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n","import './object-assign-polyfill';\n\nimport PropTypes from 'prop-types';\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport mask from './mask.js'\n\n// IE* parseFloat polyfill\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat#Polyfill\nNumber.parseFloat = parseFloat;\n\nclass CurrencyInput extends Component {\n constructor(props) {\n super(props);\n this.prepareProps = this.prepareProps.bind(this);\n this.handleChange = this.handleChange.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.state = this.prepareProps(this.props);\n\n this.inputSelectionStart = 1;\n this.inputSelectionEnd = 1;\n }\n\n\n /**\n * Exposes the current masked value.\n *\n * @returns {String}\n */\n getMaskedValue() {\n return this.state.maskedValue;\n }\n\n\n /**\n * General function used to cleanup and define the final props used for rendering\n * @returns {{ maskedValue: {String}, value: {Number}, customProps: {Object} }}\n */\n prepareProps(props) {\n let customProps = {...props}; // babeljs converts to Object.assign, then polyfills.\n delete customProps.onChange;\n delete customProps.onChangeEvent;\n delete customProps.value;\n delete customProps.decimalSeparator;\n delete customProps.thousandSeparator;\n delete customProps.precision;\n delete customProps.inputType;\n delete customProps.allowNegative;\n delete customProps.allowEmpty;\n delete customProps.prefix;\n delete customProps.suffix;\n delete customProps.selectAllOnFocus;\n delete customProps.autoFocus;\n\n let initialValue = props.value;\n if (initialValue === null) {\n initialValue = props.allowEmpty? null : '';\n }else{\n\n if (typeof initialValue == 'string') {\n // Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\"\n // Now they have two problems.\n\n // Strip out thousand separators, prefix, and suffix, etc.\n if (props.thousandSeparator === \".\"){\n // special handle the . thousand separator\n initialValue = initialValue.replace(/\\./g, '');\n }\n\n if (props.decimalSeparator != \".\"){\n // fix the decimal separator\n initialValue = initialValue.replace(new RegExp(props.decimalSeparator, 'g'), '.');\n }\n\n //Strip out anything that is not a digit, -, or decimal separator\n initialValue = initialValue.replace(/[^0-9-.]/g, '');\n\n // now we can parse.\n initialValue = Number.parseFloat(initialValue);\n }\n initialValue = Number(initialValue).toLocaleString(undefined, {\n style : 'decimal',\n minimumFractionDigits: props.precision,\n maximumFractionDigits: props.precision\n })\n\n }\n\n const { maskedValue, value } = mask(\n initialValue,\n props.precision,\n props.decimalSeparator,\n props.thousandSeparator,\n props.allowNegative,\n props.prefix,\n props.suffix\n );\n\n return { maskedValue, value, customProps };\n }\n\n\n /**\n * Component lifecycle function.\n * Invoked when a component is receiving new props. This method is not called for the initial render.\n *\n * @param nextProps\n * @see https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops\n */\n componentWillReceiveProps(nextProps) {\n this.setState(this.prepareProps(nextProps));\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidmount\n */\n componentDidMount(){\n let node = ReactDOM.findDOMNode(this.theInput);\n let selectionStart, selectionEnd;\n\n if (this.props.autoFocus) {\n this.theInput.focus();\n selectionEnd = this.state.maskedValue.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n } else {\n selectionEnd = Math.min(node.selectionEnd, this.theInput.value.length - this.props.suffix.length);\n selectionStart = Math.min(node.selectionStart, selectionEnd);\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n }\n\n\n /**\n * Component lifecycle function\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentwillupdate\n */\n componentWillUpdate() {\n let node = ReactDOM.findDOMNode(this.theInput);\n this.inputSelectionStart = node.selectionStart;\n this.inputSelectionEnd = node.selectionEnd;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidupdate\n */\n componentDidUpdate(prevProps, prevState){\n const { decimalSeparator } = this.props;\n let node = ReactDOM.findDOMNode(this.theInput);\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let minPos = this.props.prefix.length + (isNegative ? 1 : 0);\n let selectionEnd = Math.max(minPos, Math.min(this.inputSelectionEnd, this.theInput.value.length - this.props.suffix.length));\n let selectionStart = Math.max(minPos, Math.min(this.inputSelectionEnd, selectionEnd));\n\n let regexEscapeRegex = /[-[\\]{}()*+?.,\\\\^$|#\\s]/g;\n let separatorsRegex = new RegExp(decimalSeparator.replace(regexEscapeRegex, '\\\\$&') + '|' + this.props.thousandSeparator.replace(regexEscapeRegex, '\\\\$&'), 'g');\n let currSeparatorCount = (this.state.maskedValue.match(separatorsRegex) || []).length;\n let prevSeparatorCount = (prevState.maskedValue.match(separatorsRegex) || []).length;\n let adjustment = Math.max(currSeparatorCount - prevSeparatorCount, 0);\n\n selectionEnd = selectionEnd + adjustment;\n selectionStart = selectionStart + adjustment;\n\n const precision = Number(this.props.precision);\n\n let baselength = this.props.suffix.length\n + this.props.prefix.length\n + (precision > 0 ? decimalSeparator.length : 0) // if precision is 0 there will be no decimal part\n + precision\n + 1; // This is to account for the default '0' value that comes before the decimal separator\n\n if (this.state.maskedValue.length == baselength){\n // if we are already at base length, position the cursor at the end.\n selectionEnd = this.theInput.value.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n /**\n * onChange Event Handler\n * @param event\n */\n handleChange(event) {\n event.preventDefault();\n let { maskedValue, value } = mask(\n event.target.value,\n this.props.precision,\n this.props.decimalSeparator,\n this.props.thousandSeparator,\n this.props.allowNegative,\n this.props.prefix,\n this.props.suffix\n );\n\n event.persist(); // fixes issue #23\n\n this.setState({ maskedValue, value }, () => {\n this.props.onChange(maskedValue, value, event);\n this.props.onChangeEvent(event, maskedValue, value);\n });\n }\n\n\n /**\n * onFocus Event Handler\n * @param event\n */\n handleFocus(event) {\n if (!this.theInput) return;\n\n //Whenever we receive focus check to see if the position is before the suffix, if not, move it.\n let selectionEnd = this.theInput.value.length - this.props.suffix.length;\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let selectionStart = this.props.prefix.length + (isNegative ? 1 : 0);\n this.props.selectAllOnFocus && event.target.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n handleBlur(event) {\n this.inputSelectionStart = 0;\n this.inputSelectionEnd = 0;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/component-specs.html#render\n */\n render() {\n return (\n { this.theInput = input; }}\n type={this.props.inputType}\n value={this.state.maskedValue}\n onChange={this.handleChange}\n onFocus={this.handleFocus}\n onMouseUp={this.handleFocus}\n {...this.state.customProps}\n />\n )\n }\n}\n\n\n\n/**\n * Prop validation.\n * @see https://facebook.github.io/react/docs/component-specs.html#proptypes\n */\n\nCurrencyInput.propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n decimalSeparator: PropTypes.string,\n thousandSeparator: PropTypes.string,\n precision: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n inputType: PropTypes.string,\n allowNegative: PropTypes.bool,\n allowEmpty: PropTypes.bool,\n prefix: PropTypes.string,\n suffix: PropTypes.string,\n selectAllOnFocus: PropTypes.bool\n};\n\n\nCurrencyInput.defaultProps = {\n onChange: function(maskValue, value, event) {/*no-op*/},\n onChangeEvent: function(event, maskValue, value) {/*no-op*/},\n autoFocus: false,\n value: '0',\n decimalSeparator: '.',\n thousandSeparator: ',',\n precision: '2',\n inputType: 'text',\n allowNegative: false,\n prefix: '',\n suffix: '',\n selectAllOnFocus: false\n};\n\n\nexport default CurrencyInput\n"],"names":["mask","value","precision","decimalSeparator","thousandSeparator","allowNegative","prefix","suffix","undefined","maskedValue","String","length","let","digits","match","numberIsNegative","allDigitsAreZero","idx","unshift","splice","Number","join","toFixed","split","raw","decimalpos","x","push","trim","Object","assign","target","i","arguments","source","key","prototype","hasOwnProperty","call","parseFloat","CurrencyInput","props","super","this","prepareProps","bind","handleChange","handleFocus","state","inputSelectionStart","inputSelectionEnd","getMaskedValue","customProps","onChange","onChangeEvent","inputType","allowEmpty","selectAllOnFocus","autoFocus","initialValue","replace","RegExp","toLocaleString","style","minimumFractionDigits","maximumFractionDigits","componentWillReceiveProps","nextProps","setState","componentDidMount","selectionStart","selectionEnd","node","ReactDOM","findDOMNode","theInput","focus","Math","min","setSelectionRange","componentWillUpdate","componentDidUpdate","prevProps","prevState","isNegative","minPos","max","regexEscapeRegex","separatorsRegex","currSeparatorCount","prevSeparatorCount","adjustment","const","baselength","event","preventDefault","persist","handleBlur","render","React","ref","input","type","onFocus","onMouseUp","Component","propTypes","PropTypes","func","oneOfType","number","string","bool","defaultProps","maskValue"],"mappings":"iZACe,SAASA,EAAKC,EAAOC,EAAeC,EAAwBC,EAAyBC,EAAuBC,EAAaC,GAKpI,kBAL4C,kBAAsB,oBAAyB,qBAAqB,kBAAgB,mBAAa,IAEzIL,EAAY,IAAKA,EAAY,GAC7BA,EAAY,KAAMA,EAAY,IAEpB,OAAVD,QAA0BO,IAARP,EAChB,OACIA,MAAO,EACPQ,YAAa,IAMvB,GAAoB,IAFpBR,EAAQS,OAAOT,IAELU,OACN,OACIV,MAAO,EACPQ,YAAa,IAMrBG,IAAIC,EAASZ,EAAMa,MAAM,SAAW,KAEhCC,GAAmB,EACvB,GAAIV,EAAe,CAKfU,GAJyBd,EAAMa,MAAM,WAAaH,OAIX,GAAM,EAI7C,IADAC,IAAII,GAAmB,EACdC,EAAI,EAAGA,EAAMJ,EAAOF,OAAQM,GAAO,EACxC,GAAmB,MAAhBJ,EAAOI,GAAc,CACpBD,GAAmB,EACnB,MAGJA,IACAD,GAAmB,GAK3B,KAAOF,EAAOF,QAAUT,GAAaW,EAAOK,QAAQ,KAEhDhB,EAAY,GAEZW,EAAOM,OAAON,EAAOF,OAAST,EAAW,E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WF,EAAUG,OAAQH,EAAUI,SAC5DxD,UAAWoD,EAAUI,OACrB1G,cAAesG,EAAUK,KACzBxD,WAAYmD,EAAUK,KACtB1G,OAAQqG,EAAUI,OAClBxG,OAAQoG,EAAUI,OAClBtD,iBAAkBkD,EAAUK,MAIhCxE,EAAcyE,cACV5D,SAAU,SAAS6D,EAAWjH,EAAO6F,KACrCxC,cAAe,SAASwC,EAAOoB,EAAWjH,KAC1CyD,WAAW,EACXzD,MAAO,IACPE,iBAAkB,IAClBC,kBAAmB,IACnBF,UAAW,IACXqD,UAAW,OACXlD,eAAe,EACfC,OAAQ,GACRC,OAAQ,GACRkD,kBAAkB"}
\ No newline at end of file
+{"version":3,"file":"react-currency-input.min.js","sources":["../src/mask.js","../src/object-assign-polyfill.js","../src/index.js"],"sourcesContent":["\nexport default function mask(value, precision = 2, decimalSeparator = '.', thousandSeparator = ',', allowNegative = false, prefix = '', suffix = ''){\n // provide some default values and arg validation.\n if (precision < 0) { precision = 0; } // precision cannot be negative\n if (precision > 20) { precision = 20; } // precision cannot be greater than 20\n \n if (value === null || value===undefined) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n \n value = String(value); //if the given value is a Number, let's convert into String to manipulate that\n\n if (value.length == 0) {\n return {\n value: 0,\n maskedValue: ''\n };\n }\n\n\n // extract digits. if no digits, fill in a zero.\n let digits = value.match(/\\d/g) || ['0'];\n \n let numberIsNegative = false;\n if (allowNegative) {\n let negativeSignCount = (value.match(/-/g) || []).length;\n // number will be negative if we have an odd number of \"-\"\n // ideally, we should only ever have 0, 1 or 2 (positive number, making a number negative\n // and making a negative number positive, respectively)\n numberIsNegative = negativeSignCount % 2 === 1;\n \n // if every digit in the array is '0', then the number should never be negative\n let allDigitsAreZero = true;\n for (let idx=0; idx < digits.length; idx += 1) {\n if(digits[idx] !== '0') {\n allDigitsAreZero = false;\n break;\n }\n }\n if (allDigitsAreZero) {\n numberIsNegative = false;\n }\n }\n\n // zero-pad a input\n while (digits.length <= precision) { digits.unshift('0'); }\n\n if (precision > 0) {\n // add the decimal separator\n digits.splice(digits.length - precision, 0, \".\");\n }\n\n // clean up extraneous digits like leading zeros.\n digits = Number(digits.join('')).toFixed(precision).split('');\n let raw = Number(digits.join(''));\n\n let decimalpos = digits.length - precision - 1; // -1 needed to position the decimal separator before the digits.\n if (precision > 0) {\n // set the final decimal separator\n digits[decimalpos] = decimalSeparator;\n } else {\n // when precision is 0, there is no decimal separator.\n decimalpos = digits.length;\n }\n\n // add in any thousand separators\n for (let x=decimalpos - 3; x > 0; x = x - 3) {\n digits.splice(x, 0, thousandSeparator);\n }\n\n // if we have a prefix or suffix, add them in.\n if (prefix.length > 0) { digits.unshift(prefix); }\n if (suffix.length > 0) { digits.push(suffix); }\n\n // if the number is negative, insert a \"-\" to\n // the front of the array and negate the raw value\n if (allowNegative && numberIsNegative) {\n digits.unshift('-');\n raw = -raw;\n }\n\n return {\n value: raw,\n maskedValue: digits.join('').trim()\n };\n}\n","Object.assign = Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n","import './object-assign-polyfill';\n\nimport PropTypes from 'prop-types';\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport mask from './mask.js'\n\n// IE* parseFloat polyfill\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat#Polyfill\nNumber.parseFloat = parseFloat;\n\nclass CurrencyInput extends Component {\n constructor(props) {\n super(props);\n this.prepareProps = this.prepareProps.bind(this);\n this.handleChange = this.handleChange.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.state = this.prepareProps(this.props);\n\n this.inputSelectionStart = 1;\n this.inputSelectionEnd = 1;\n }\n\n\n /**\n * Exposes the current masked value.\n *\n * @returns {String}\n */\n getMaskedValue() {\n return this.state.maskedValue;\n }\n\n\n /**\n * General function used to cleanup and define the final props used for rendering\n * @returns {{ maskedValue: {String}, value: {Number}, customProps: {Object} }}\n */\n prepareProps(props) {\n let customProps = {...props}; // babeljs converts to Object.assign, then polyfills.\n delete customProps.onChange;\n delete customProps.onChangeEvent;\n delete customProps.value;\n delete customProps.decimalSeparator;\n delete customProps.thousandSeparator;\n delete customProps.precision;\n delete customProps.inputType;\n delete customProps.allowNegative;\n delete customProps.allowEmpty;\n delete customProps.prefix;\n delete customProps.suffix;\n delete customProps.selectAllOnFocus;\n delete customProps.autoFocus;\n delete customProps.maxValue;\n delete customProps.minValue;\n\n let initialValue = props.value;\n if (initialValue === null) {\n initialValue = props.allowEmpty? null : '';\n }else{\n\n if (typeof initialValue == 'string') {\n // Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\"\n // Now they have two problems.\n\n // Strip out thousand separators, prefix, and suffix, etc.\n if (props.thousandSeparator === \".\"){\n // special handle the . thousand separator\n initialValue = initialValue.replace(/\\./g, '');\n }\n\n if (props.decimalSeparator != \".\"){\n // fix the decimal separator\n initialValue = initialValue.replace(new RegExp(props.decimalSeparator, 'g'), '.');\n }\n\n //Strip out anything that is not a digit, -, or decimal separator\n initialValue = initialValue.replace(/[^0-9-.]/g, '');\n\n // now we can parse.\n initialValue = Number.parseFloat(initialValue);\n }\n initialValue = Number(initialValue).toLocaleString(undefined, {\n style : 'decimal',\n minimumFractionDigits: props.precision,\n maximumFractionDigits: props.precision\n })\n\n }\n\n const { maskedValue, value } = mask(\n initialValue,\n props.precision,\n props.decimalSeparator,\n props.thousandSeparator,\n props.allowNegative,\n props.prefix,\n props.suffix\n );\n\n return { maskedValue, value, customProps };\n }\n\n\n /**\n * Component lifecycle function.\n * Invoked when a component is receiving new props. This method is not called for the initial render.\n *\n * @param nextProps\n * @see https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops\n */\n componentWillReceiveProps(nextProps) {\n this.setState(this.prepareProps(nextProps));\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidmount\n */\n componentDidMount(){\n let node = ReactDOM.findDOMNode(this.theInput);\n let selectionStart, selectionEnd;\n\n if (this.props.autoFocus) {\n this.theInput.focus();\n selectionEnd = this.state.maskedValue.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n } else {\n selectionEnd = Math.min(node.selectionEnd, this.theInput.value.length - this.props.suffix.length);\n selectionStart = Math.min(node.selectionStart, selectionEnd);\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n }\n\n\n /**\n * Component lifecycle function\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentwillupdate\n */\n componentWillUpdate() {\n let node = ReactDOM.findDOMNode(this.theInput);\n this.inputSelectionStart = node.selectionStart;\n this.inputSelectionEnd = node.selectionEnd;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/react-component.html#componentdidupdate\n */\n componentDidUpdate(prevProps, prevState){\n const { decimalSeparator } = this.props;\n let node = ReactDOM.findDOMNode(this.theInput);\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let minPos = this.props.prefix.length + (isNegative ? 1 : 0);\n let selectionEnd = Math.max(minPos, Math.min(this.inputSelectionEnd, this.theInput.value.length - this.props.suffix.length));\n let selectionStart = Math.max(minPos, Math.min(this.inputSelectionEnd, selectionEnd));\n\n let regexEscapeRegex = /[-[\\]{}()*+?.,\\\\^$|#\\s]/g;\n let separatorsRegex = new RegExp(decimalSeparator.replace(regexEscapeRegex, '\\\\$&') + '|' + this.props.thousandSeparator.replace(regexEscapeRegex, '\\\\$&'), 'g');\n let currSeparatorCount = (this.state.maskedValue.match(separatorsRegex) || []).length;\n let prevSeparatorCount = (prevState.maskedValue.match(separatorsRegex) || []).length;\n let adjustment = Math.max(currSeparatorCount - prevSeparatorCount, 0);\n\n selectionEnd = selectionEnd + adjustment;\n selectionStart = selectionStart + adjustment;\n\n const precision = Number(this.props.precision);\n\n let baselength = this.props.suffix.length\n + this.props.prefix.length\n + (precision > 0 ? decimalSeparator.length : 0) // if precision is 0 there will be no decimal part\n + precision\n + 1; // This is to account for the default '0' value that comes before the decimal separator\n\n if (this.state.maskedValue.length == baselength){\n // if we are already at base length, position the cursor at the end.\n selectionEnd = this.theInput.value.length - this.props.suffix.length;\n selectionStart = selectionEnd;\n }\n\n node.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n /**\n * onChange Event Handler\n * @param event\n */\n handleChange(event) {\n event.preventDefault();\n\n let { maskedValue, value } = mask(\n event.target.value,\n this.props.precision,\n this.props.decimalSeparator,\n this.props.thousandSeparator,\n this.props.allowNegative,\n this.props.prefix,\n this.props.suffix\n );\n\n if ((this.props.maxValue && value > this.props.maxValue)\n || (this.props.minValue && value < this.props.maxValue)) {\n // if value exceeds min & max limits, do nothing...\n return;\n }\n\n event.persist(); // fixes issue #23\n\n this.setState({ maskedValue, value }, () => {\n this.props.onChange(maskedValue, value, event);\n this.props.onChangeEvent(event, maskedValue, value);\n });\n }\n\n\n /**\n * onFocus Event Handler\n * @param event\n */\n handleFocus(event) {\n if (!this.theInput) return;\n\n //Whenever we receive focus check to see if the position is before the suffix, if not, move it.\n let selectionEnd = this.theInput.value.length - this.props.suffix.length;\n let isNegative = (this.theInput.value.match(/-/g) || []).length % 2 === 1;\n let selectionStart = this.props.prefix.length + (isNegative ? 1 : 0);\n this.props.selectAllOnFocus && event.target.setSelectionRange(selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n\n handleBlur(event) {\n this.inputSelectionStart = 0;\n this.inputSelectionEnd = 0;\n }\n\n\n /**\n * Component lifecycle function.\n * @returns {XML}\n * @see https://facebook.github.io/react/docs/component-specs.html#render\n */\n render() {\n return (\n { this.theInput = input; }}\n type={this.props.inputType}\n value={this.state.maskedValue}\n onChange={this.handleChange}\n onFocus={this.handleFocus}\n onMouseUp={this.handleFocus}\n {...this.state.customProps}\n />\n )\n }\n}\n\n\n\n/**\n * Prop validation.\n * @see https://facebook.github.io/react/docs/component-specs.html#proptypes\n */\n\nCurrencyInput.propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n decimalSeparator: PropTypes.string,\n thousandSeparator: PropTypes.string,\n precision: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n inputType: PropTypes.string,\n allowNegative: PropTypes.bool,\n allowEmpty: PropTypes.bool,\n prefix: PropTypes.string,\n suffix: PropTypes.string,\n selectAllOnFocus: PropTypes.bool\n};\n\n\nCurrencyInput.defaultProps = {\n onChange: function(maskValue, value, event) {/*no-op*/},\n onChangeEvent: function(event, maskValue, value) {/*no-op*/},\n autoFocus: false,\n value: '0',\n decimalSeparator: '.',\n thousandSeparator: ',',\n precision: '2',\n inputType: 'text',\n allowNegative: false,\n prefix: '',\n suffix: '',\n selectAllOnFocus: false,\n maxValue: undefined,\n minValue: undefined\n};\n\n\nexport default CurrencyInput\n"],"names":["mask","value","precision","decimalSeparator","thousandSeparator","allowNegative","prefix","suffix","maskedValue","String","length","let","digits","match","numberIsNegative","allDigitsAreZero","idx","unshift","splice","Number","join","toFixed","split","raw","decimalpos","x","push","trim","Object","assign","target","i","arguments","source","key","prototype","hasOwnProperty","call","parseFloat","CurrencyInput","props","super","this","prepareProps","bind","handleChange","handleFocus","state","inputSelectionStart","inputSelectionEnd","getMaskedValue","customProps","onChange","onChangeEvent","inputType","allowEmpty","selectAllOnFocus","autoFocus","maxValue","minValue","initialValue","replace","RegExp","toLocaleString","undefined","style","minimumFractionDigits","maximumFractionDigits","componentWillReceiveProps","nextProps","setState","componentDidMount","selectionStart","selectionEnd","node","ReactDOM","findDOMNode","theInput","focus","Math","min","setSelectionRange","componentWillUpdate","componentDidUpdate","prevProps","prevState","isNegative","minPos","max","regexEscapeRegex","separatorsRegex","currSeparatorCount","prevSeparatorCount","adjustment","const","baselength","event","preventDefault","persist","handleBlur","render","React","ref","input","type","onFocus","onMouseUp","Component","propTypes","PropTypes","func","oneOfType","number","string","bool","defaultProps","maskValue"],"mappings":"iZACe,SAASA,EAAKC,EAAOC,EAAeC,EAAwBC,EAAyBC,EAAuBC,EAAaC,GAKpI,kBAL4C,kBAAsB,oBAAyB,qBAAqB,kBAAgB,mBAAa,IAEzIL,EAAY,IAAKA,EAAY,GACjB,GAAZA,IAAkBA,EAAY,IAE9BD,MAAAA,EACE,MAAO,CACHA,MAAO,EACPO,YAAa,IAMvB,GAAoB,IAFpBP,EAAQQ,OAAOR,IAELS,OACN,MAAO,CACHT,MAAO,EACPO,YAAa,IAMrBG,IAAIC,EAASX,EAAMY,MAAM,QAAU,CAAC,KAEhCC,GAAmB,EACvB,GAAIT,EAAe,CAKfS,GAJyBb,EAAMY,MAAM,OAAS,IAAIH,OAIX,GAAM,EAI7C,IADAC,IAAII,GAAmB,EACdC,EAAI,EAAGA,EAAMJ,EAAOF,OAAQM,GAAO,EACxC,GAAmB,MAAhBJ,EAAOI,GAAc,CACpBD,GAAmB,EACnB,MAGJA,IACAD,GAAmB,GAK3B,KAAOF,EAAOF,QAAUR,GAAaU,EAAOK,QAAQ,KAEpC,EAAZf,GAEAU,EAAOM,OAAON,EAAOF,OAASR,EAAW,EAAG,KAIhDU,EAASO,OAAOP,EAAOQ,KAAK,KAAKC,QAAQnB,GAAWoB,MAAM,IAC1DX,IAAIY,EAAMJ,OAAOP,EAAOQ,KAAK,KAEzBI,EAAaZ,EAAOF,OAASR,EAAY,EAC7B,EAAZA,EAEAU,EAAOY,GAAcrB,EAGrBqB,EAAaZ,EAAOF,OAIxB,IAAKC,IAAIc,EAAED,EAAa,EAAO,EAAJC,EAAOA,GAAQ,EACtCb,EAAOM,OAAOO,EAAG,EAAGrB,GAcxB,OAVoB,EAAhBE,EAAOI,QAAcE,EAAOK,QAAQX,GACpB,EAAhBC,EAAOG,QAAcE,EAAOc,KAAKnB,GAIjCF,GAAiBS,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U,SAASgE,EAAWnH,EAAO+F,KACrC3C,cAAe,SAAS2C,EAAOoB,EAAWnH,KAC1CwD,WAAW,EACXxD,MAAO,IACPE,iBAAkB,IAClBC,kBAAmB,IACnBF,UAAW,IACXoD,UAAW,OACXjD,eAAe,EACfC,OAAQ,GACRC,OAAQ,GACRiD,kBAAkB,EAClBE,cAAUM,EACVL,cAAUK"}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index ce4e303..34c7c57 100644
--- a/src/index.js
+++ b/src/index.js
@@ -51,6 +51,8 @@ class CurrencyInput extends Component {
delete customProps.suffix;
delete customProps.selectAllOnFocus;
delete customProps.autoFocus;
+ delete customProps.maxValue;
+ delete customProps.minValue;
let initialValue = props.value;
if (initialValue === null) {
@@ -194,6 +196,7 @@ class CurrencyInput extends Component {
*/
handleChange(event) {
event.preventDefault();
+
let { maskedValue, value } = mask(
event.target.value,
this.props.precision,
@@ -204,6 +207,12 @@ class CurrencyInput extends Component {
this.props.suffix
);
+ if ((this.props.maxValue && value > this.props.maxValue)
+ || (this.props.minValue && value < this.props.maxValue)) {
+ // if value exceeds min & max limits, do nothing...
+ return;
+ }
+
event.persist(); // fixes issue #23
this.setState({ maskedValue, value }, () => {
@@ -290,7 +299,9 @@ CurrencyInput.defaultProps = {
allowNegative: false,
prefix: '',
suffix: '',
- selectAllOnFocus: false
+ selectAllOnFocus: false,
+ maxValue: undefined,
+ minValue: undefined
};