From a4190c8ab4db2fd5bcce3d2e8dfce740e856b446 Mon Sep 17 00:00:00 2001 From: Deivison Sporteman Date: Fri, 26 Oct 2018 16:06:54 -0300 Subject: [PATCH] Building cjs, es and min file to get fix #74 --- lib/react-currency-input.cjs.js | 17 +++++++++++++++-- lib/react-currency-input.cjs.js.map | 2 +- lib/react-currency-input.es.js | 17 +++++++++++++++-- lib/react-currency-input.es.js.map | 2 +- lib/react-currency-input.min.js | 2 +- lib/react-currency-input.min.js.map | 2 +- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/react-currency-input.cjs.js b/lib/react-currency-input.cjs.js index 735ce0e..a529748 100644 --- a/lib/react-currency-input.cjs.js +++ b/lib/react-currency-input.cjs.js @@ -128,6 +128,7 @@ var CurrencyInput = (function (Component$$1) { this.prepareProps = this.prepareProps.bind(this); this.handleChange = this.handleChange.bind(this); this.handleFocus = this.handleFocus.bind(this); + this.setSelectionRange = this.setSelectionRange.bind(this); this.state = this.prepareProps(this.props); this.inputSelectionStart = 1; @@ -249,7 +250,7 @@ var CurrencyInput = (function (Component$$1) { selectionStart = Math.min(node.selectionStart, selectionEnd); } - node.setSelectionRange(selectionStart, selectionEnd); + this.setSelectionRange(node, selectionStart, selectionEnd); }; @@ -302,11 +303,23 @@ var CurrencyInput = (function (Component$$1) { selectionStart = selectionEnd; } - node.setSelectionRange(selectionStart, selectionEnd); + this.setSelectionRange(node, selectionStart, selectionEnd); this.inputSelectionStart = selectionStart; this.inputSelectionEnd = selectionEnd; }; + /** + * Set selection range only if input is in focused state + * @param node DOMElement + * @param start number + * @param end number + */ + CurrencyInput.prototype.setSelectionRange = function setSelectionRange (node, start, end) { + if (document.activeElement === node) { + node.setSelectionRange(start, end); + } + }; + /** * onChange Event Handler diff --git a/lib/react-currency-input.cjs.js.map b/lib/react-currency-input.cjs.js.map index 16522e4..7ed934e 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: false\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,CAAC,MAAM,IAA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,EAC5B,IAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,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.setSelectionRange = this.setSelectionRange.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 this.setSelectionRange(node, 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 this.setSelectionRange(node, selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n /**\n * Set selection range only if input is in focused state\n * @param node DOMElement\n * @param start number\n * @param end number\n */\n setSelectionRange(node, start, end) {\n if (document.activeElement === node) {\n node.setSelectionRange(start, end);\n }\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","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,GAA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AAE,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 diff --git a/lib/react-currency-input.es.js b/lib/react-currency-input.es.js index 1aa64b3..368449e 100644 --- a/lib/react-currency-input.es.js +++ b/lib/react-currency-input.es.js @@ -123,6 +123,7 @@ var CurrencyInput = (function (Component$$1) { this.prepareProps = this.prepareProps.bind(this); this.handleChange = this.handleChange.bind(this); this.handleFocus = this.handleFocus.bind(this); + this.setSelectionRange = this.setSelectionRange.bind(this); this.state = this.prepareProps(this.props); this.inputSelectionStart = 1; @@ -244,7 +245,7 @@ var CurrencyInput = (function (Component$$1) { selectionStart = Math.min(node.selectionStart, selectionEnd); } - node.setSelectionRange(selectionStart, selectionEnd); + this.setSelectionRange(node, selectionStart, selectionEnd); }; @@ -297,11 +298,23 @@ var CurrencyInput = (function (Component$$1) { selectionStart = selectionEnd; } - node.setSelectionRange(selectionStart, selectionEnd); + this.setSelectionRange(node, selectionStart, selectionEnd); this.inputSelectionStart = selectionStart; this.inputSelectionEnd = selectionEnd; }; + /** + * Set selection range only if input is in focused state + * @param node DOMElement + * @param start number + * @param end number + */ + CurrencyInput.prototype.setSelectionRange = function setSelectionRange (node, start, end) { + if (document.activeElement === node) { + node.setSelectionRange(start, end); + } + }; + /** * onChange Event Handler diff --git a/lib/react-currency-input.es.js.map b/lib/react-currency-input.es.js.map index aef02bc..94eacef 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"],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,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.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.setSelectionRange = this.setSelectionRange.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 this.setSelectionRange(node, 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 this.setSelectionRange(node, selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n /**\n * Set selection range only if input is in focused state\n * @param node DOMElement\n * @param start number\n * @param end number\n */\n setSelectionRange(node, start, end) {\n if (document.activeElement === node) {\n node.setSelectionRange(start, end);\n }\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: '',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E,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 diff --git a/lib/react-currency-input.min.js b/lib/react-currency-input.min.js index fdf6f8d..688e467 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,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),20 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","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","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,EA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AM,OAAS,IAAIH,OAAS,GAAM,EACpE4D,EAAiB5B,KAAKF,MAAMlC,OAAOI,QAAU0E,EAAa,EAAI,GAClE1C,KAAKF,MAAMgB,kBAAoBsC,EAAMhE,OAAOiD,kBAAkBT,EAAgBC,GAC9E7B,KAAKM,oBAAsBsB,EAC3B5B,KAAKO,kBAAoBsB,IAI7BhC,YAAA0D,oBAAWH,GACPpD,KAAKM,oBAAsB,EAC3BN,KAAKO,kBAAoB,GAS7BV,YAAA2D,6BACI,OACIC,gBAAC,yBACG,CAAAC,IAAI,SAAEC,GAAY3D,EAAKiC,SAAW0B,GAClCC,KAAK5D,KAAMF,MAAMc,UACjBrD,MAAMyC,KAAMK,MAAMvC,YAClB4C,SAASV,KAAMG,aACf0D,QAAQ7D,KAAMI,YACd0D,UAAU9D,KAAMI,aAChBJ,KAASK,MAAMI,kBAjPHsD,oBA8P5BlE,EAAcmE,UAAY,CACtBtD,SAAUuD,EAAUC,KACpB3G,MAAO0G,EAAUE,UAAU,CAACF,EAAUG,OAAQH,EAAUI,SACxD5G,iBAAkBwG,EAAUI,OAC5B3G,kBAAmBuG,EAAUI,OAC7B7G,UAAWyG,EAAUE,UAAU,CAACF,EAAUG,OAAQH,EAAUI,SAC5DzD,UAAWqD,EAAUI,OACrB1G,cAAesG,EAAUK,KACzBzD,WAAYoD,EAAUK,KACtB1G,OAAQqG,EAAUI,OAClBxG,OAAQoG,EAAUI,OAClBvD,iBAAkBmD,EAAUK,MAIhCzE,EAAc0E,aAAe,CACzB7D,SAAU,SAAS8D,EAAWjH,EAAO6F,KACrCzC,cAAe,SAASyC,EAAOoB,EAAWjH,KAC1CwD,WAAW,EACXxD,MAAO,IACPE,iBAAkB,IAClBC,kBAAmB,IACnBF,UAAW,IACXoD,UAAW,OACXjD,eAAe,EACfC,OAAQ,GACRC,OAAQ,GACRiD,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.setSelectionRange = this.setSelectionRange.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 this.setSelectionRange(node, 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 this.setSelectionRange(node, selectionStart, selectionEnd);\n this.inputSelectionStart = selectionStart;\n this.inputSelectionEnd = selectionEnd;\n }\n\n /**\n * Set selection range only if input is in focused state\n * @param node DOMElement\n * @param start number\n * @param end number\n */\n setSelectionRange(node, start, end) {\n if (document.activeElement === node) {\n node.setSelectionRange(start, end);\n }\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","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","setSelectionRange","state","inputSelectionStart","inputSelectionEnd","getMaskedValue","customProps","onChange","onChangeEvent","inputType","allowEmpty","selectAllOnFocus","autoFocus","initialValue","replace","RegExp","toLocaleString","undefined","style","minimumFractionDigits","maximumFractionDigits","componentWillReceiveProps","nextProps","setState","componentDidMount","selectionStart","selectionEnd","node","ReactDOM","findDOMNode","theInput","focus","Math","min","componentWillUpdate","componentDidUpdate","prevProps","prevState","isNegative","minPos","max","regexEscapeRegex","separatorsRegex","currSeparatorCount","prevSeparatorCount","adjustment","const","baselength","start","end","document","activeElement","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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