Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-currency-input-field

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-currency-input-field - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [2.3.2](https://github.com/cchanxzy/react-currency-input-field/compare/v2.3.1...v2.3.2) (2020-09-27)
### Bug Fixes
* prefix 0 value ([d7fa074](https://github.com/cchanxzy/react-currency-input-field/commit/d7fa0747f09da9a33bb46146172563277a1b5fc3))
## [2.3.1](https://github.com/cchanxzy/react-currency-input-field/compare/v2.3.0...v2.3.1) (2020-09-25)

@@ -2,0 +9,0 @@

2

dist/index.js

@@ -1,2 +0,2 @@

module.exports=function(e){var r={};function t(a){if(r[a])return r[a].exports;var n=r[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,a){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(a,n,function(r){return e[r]}.bind(null,n));return a},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.escapeRegExp=void 0,r.escapeRegExp=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}},function(e,r,t){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var n=a(t(2));r.default=n.default},function(e,r,t){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)},n=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t),Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),i=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),u=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.hasOwnProperty.call(e,t)&&n(r,e,t);return i(r,e),r},o=this&&this.__rest||function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t};Object.defineProperty(r,"__esModule",{value:!0}),r.CurrencyInput=void 0;var l=u(t(3)),c=t(4);r.CurrencyInput=function(e){var r=e.allowDecimals,t=void 0===r||r,n=e.allowNegativeValue,i=void 0===n||n,u=e.id,d=e.name,f=e.className,s=e.decimalsLimit,p=e.defaultValue,v=e.disabled,m=void 0!==v&&v,b=e.maxLength,g=e.value,h=e.onChange,_=e.fixedDecimalLength,y=e.placeholder,O=e.precision,S=e.prefix,j=e.decimalSeparator,x=void 0===j?".":j,V=e.groupSeparator,w=void 0===V?",":V,P=e.turnOffSeparators,M=void 0!==P&&P,N=o(e,["allowDecimals","allowNegativeValue","id","name","className","decimalsLimit","defaultValue","disabled","maxLength","value","onChange","fixedDecimalLength","placeholder","precision","prefix","decimalSeparator","groupSeparator","turnOffSeparators"]);if(x===w)throw new Error("decimalSeparator cannot be the same as groupSeparator");if(c.checkIsValidNumber(x))throw new Error("decimalSeparator cannot be a number");if(c.checkIsValidNumber(w))throw new Error("groupSeparator cannot be a number");var E={decimalSeparator:x,groupSeparator:w,turnOffSeparators:M,prefix:S},D={decimalSeparator:x,groupSeparator:w,allowDecimals:t,decimalsLimit:s||_||2,allowNegativeValue:i,prefix:S},L=p?c.formatValue(a({value:String(p)},E)):"",R=l.useState(L),I=R[0],k=R[1],C=l.useRef(null),T=g?c.formatValue(a({value:String(g)},E)):g;return l.default.createElement("input",a({type:"text",inputMode:"decimal",id:u,name:d,className:f,onChange:function(e){var r=e.target.value,t=c.cleanValue(a({value:r},D));if(!t)return h&&h(void 0,d),void k("");if(!(b&&t.length>b)){if("-"===t)return k(r),void(h&&h(t,d));var n=c.formatValue(a({value:t},E));k(n),h&&h(t,d)}},onBlur:function(e){var r=e.target.value,t=c.cleanValue(a({value:r},D));if("-"!==t){var n=c.fixedDecimalValue(t,x,_),i=c.padTrimValue(n,x,O||_),u=c.formatValue(a({value:i},E));k(u),h&&h(i,d)}else k("")},onFocus:function(){return I?I.length:0},placeholder:y,disabled:m,value:void 0!==T?T:I,ref:C},N))},r.default=r.CurrencyInput},function(e,r){e.exports=require("react")},function(e,r,t){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t),Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),n=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||r.hasOwnProperty(t)||a(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),n(t(5),r),n(t(6),r),n(t(9),r),n(t(10),r),n(t(12),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.checkIsValidNumber=void 0,r.checkIsValidNumber=function(e){return!(Number(e)<0||Number.isNaN(Number(e)))}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.cleanValue=void 0;var a=t(7),n=t(8);r.cleanValue=function(e){var r=e.value,t=e.decimalSeparator,i=e.groupSeparator,u=e.allowDecimals,o=e.decimalsLimit,l=e.allowNegativeValue,c=void 0===l||l,d=e.prefix,f=r.includes("-"),s=f?r.replace("-",""):r,p=d?s.replace(d,""):s,v=n.removeSeparators(p,i),m=a.parseAbbrValue(v,t)||v,b=f&&c?"-":"";if(String(m).includes(t)){var g=v.split(t),h=g[0],_=g[1],y=o?_.slice(0,o):_;return""+b+h+(u?""+t+y:"")}return""+b+m}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseAbbrValue=r.abbrValue=void 0;var a=t(0);r.abbrValue=function(e,r,t){if(void 0===r&&(r="."),void 0===t&&(t=10),e>999){var a=(""+e).length,n=Math.pow,i=n(10,t);return a-=a%3,(Math.round(e*i/n(10,a))/i+" kMGTPE"[a/3]).replace(".",r)}return String(e)};var n={k:1e3,m:1e6,b:1e9};r.parseAbbrValue=function(e,r){void 0===r&&(r=".");var t=new RegExp("(\\d+("+a.escapeRegExp(r)+"\\d+)?)([kmb])$","i"),i=e.match(t);if(i){var u=i[1],o=i[3],l=o?n[o.toLowerCase()]:null;if(u&&l)return Number(u.replace(r,"."))*l}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.removeSeparators=void 0;var a=t(0);r.removeSeparators=function(e,r){void 0===r&&(r=",");var t=new RegExp(a.escapeRegExp(r),"g");return e.replace(t,"")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.fixedDecimalValue=void 0,r.fixedDecimalValue=function(e,r,t){if(t&&e.length>1){if(e.includes(r)){var a=e.split(r),n=a[0];if((i=a[1]).length>t)return""+n+r+i.slice(0,t)}var i,u=e.length>t?new RegExp("(\\d+)(\\d{"+t+"})"):new RegExp("(\\d)(\\d+)"),o=e.match(u);if(o)return""+(n=o[1])+r+(i=o[2])}return e}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatValue=void 0;var a=t(11);r.formatValue=function(e){var r=e.value,t=e.decimalSeparator,n=e.groupSeparator,i=e.turnOffSeparators,u=void 0!==i&&i,o=e.prefix;if(""===r||void 0===r)return"";if("-"===r)return"-";var l=r.includes("-"),c=r.split(t),d=c[0],f=c[1],s=l?d.replace("-",""):d;return""+(l?"-":"")+(o||"")+(u?s:a.addSeparators(s,n))+(r.includes(t)?""+t+f:"")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addSeparators=void 0,r.addSeparators=function(e,r){return void 0===r&&(r=","),e.replace(/\B(?=(\d{3})+(?!\d))/g,r)}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.padTrimValue=void 0,r.padTrimValue=function(e,r,t){if(void 0===r&&(r="."),!t||""===e||void 0===e)return e;if(!e.match(/\d/g))return"";var a=e.split(r),n=a[0],i=a[1]||"";if(i.length<t)for(;i.length<t;)i+="0";else i=i.slice(0,t);return""+n+r+i}}]);
module.exports=function(e){var r={};function t(a){if(r[a])return r[a].exports;var n=r[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,a){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(a,n,function(r){return e[r]}.bind(null,n));return a},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.escapeRegExp=void 0,r.escapeRegExp=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}},function(e,r,t){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var n=a(t(2));r.default=n.default},function(e,r,t){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)},n=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t),Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),i=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.hasOwnProperty.call(e,t)&&n(r,e,t);return i(r,e),r},u=this&&this.__rest||function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t};Object.defineProperty(r,"__esModule",{value:!0}),r.CurrencyInput=void 0;var l=o(t(3)),c=t(4);r.CurrencyInput=function(e){var r=e.allowDecimals,t=void 0===r||r,n=e.allowNegativeValue,i=void 0===n||n,o=e.id,d=e.name,f=e.className,s=e.decimalsLimit,p=e.defaultValue,v=e.disabled,m=void 0!==v&&v,b=e.maxLength,g=e.value,h=e.onChange,_=e.fixedDecimalLength,y=e.placeholder,O=e.precision,S=e.prefix,j=e.decimalSeparator,x=void 0===j?".":j,V=e.groupSeparator,w=void 0===V?",":V,P=e.turnOffSeparators,M=void 0!==P&&P,N=u(e,["allowDecimals","allowNegativeValue","id","name","className","decimalsLimit","defaultValue","disabled","maxLength","value","onChange","fixedDecimalLength","placeholder","precision","prefix","decimalSeparator","groupSeparator","turnOffSeparators"]);if(x===w)throw new Error("decimalSeparator cannot be the same as groupSeparator");if(c.checkIsValidNumber(x))throw new Error("decimalSeparator cannot be a number");if(c.checkIsValidNumber(w))throw new Error("groupSeparator cannot be a number");var E={decimalSeparator:x,groupSeparator:w,turnOffSeparators:M,prefix:S},D={decimalSeparator:x,groupSeparator:w,allowDecimals:t,decimalsLimit:s||_||2,allowNegativeValue:i,prefix:S},L=p?c.formatValue(a({value:String(p)},E)):"",R=l.useState(L),I=R[0],k=R[1],C=l.useRef(null),T=void 0!==g?c.formatValue(a({value:String(g)},E)):void 0;return l.default.createElement("input",a({type:"text",inputMode:"decimal",id:o,name:d,className:f,onChange:function(e){var r=e.target.value,t=c.cleanValue(a({value:String(r)},D));if(!t)return h&&h(void 0,d),void k("");if(!(b&&t.length>b)){if("-"===t)return k(r),void(h&&h(t,d));var n=c.formatValue(a({value:t},E));k(n),h&&h(t,d)}},onBlur:function(e){var r=e.target.value,t=c.cleanValue(a({value:r},D));if("-"!==t){var n=c.fixedDecimalValue(t,x,_),i=c.padTrimValue(n,x,O||_),o=c.formatValue(a({value:i},E));k(o),h&&h(i,d)}else k("")},onFocus:function(){return I?I.length:0},placeholder:y,disabled:m,value:void 0!==T?T:I,ref:C},N))},r.default=r.CurrencyInput},function(e,r){e.exports=require("react")},function(e,r,t){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t),Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),n=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||r.hasOwnProperty(t)||a(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),n(t(5),r),n(t(6),r),n(t(9),r),n(t(10),r),n(t(12),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.checkIsValidNumber=void 0,r.checkIsValidNumber=function(e){return!(Number(e)<0||Number.isNaN(Number(e)))}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.cleanValue=void 0;var a=t(7),n=t(8);r.cleanValue=function(e){var r=e.value,t=e.decimalSeparator,i=e.groupSeparator,o=e.allowDecimals,u=e.decimalsLimit,l=e.allowNegativeValue,c=void 0===l||l,d=e.prefix,f=r.includes("-"),s=f?r.replace("-",""):r,p=d?s.replace(d,""):s,v=n.removeSeparators(p,i),m=a.parseAbbrValue(v,t)||v,b=f&&c?"-":"";if(String(m).includes(t)){var g=v.split(t),h=g[0],_=g[1],y=u?_.slice(0,u):_;return""+b+h+(o?""+t+y:"")}return""+b+m}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseAbbrValue=r.abbrValue=void 0;var a=t(0);r.abbrValue=function(e,r,t){if(void 0===r&&(r="."),void 0===t&&(t=10),e>999){var a=(""+e).length,n=Math.pow,i=n(10,t);return a-=a%3,(Math.round(e*i/n(10,a))/i+" kMGTPE"[a/3]).replace(".",r)}return String(e)};var n={k:1e3,m:1e6,b:1e9};r.parseAbbrValue=function(e,r){void 0===r&&(r=".");var t=new RegExp("(\\d+("+a.escapeRegExp(r)+"\\d+)?)([kmb])$","i"),i=e.match(t);if(i){var o=i[1],u=i[3],l=u?n[u.toLowerCase()]:null;if(o&&l)return Number(o.replace(r,"."))*l}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.removeSeparators=void 0;var a=t(0);r.removeSeparators=function(e,r){void 0===r&&(r=",");var t=new RegExp(a.escapeRegExp(r),"g");return e.replace(t,"")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.fixedDecimalValue=void 0,r.fixedDecimalValue=function(e,r,t){if(t&&e.length>1){if(e.includes(r)){var a=e.split(r),n=a[0];if((i=a[1]).length>t)return""+n+r+i.slice(0,t)}var i,o=e.length>t?new RegExp("(\\d+)(\\d{"+t+"})"):new RegExp("(\\d)(\\d+)"),u=e.match(o);if(u)return""+(n=u[1])+r+(i=u[2])}return e}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatValue=void 0;var a=t(11);r.formatValue=function(e){var r=e.value,t=e.decimalSeparator,n=e.groupSeparator,i=e.turnOffSeparators,o=void 0!==i&&i,u=e.prefix;if(""===r||void 0===r)return"";if("-"===r)return"-";var l=r.includes("-"),c=r.split(t),d=c[0],f=c[1],s=l?d.replace("-",""):d;return""+(l?"-":"")+(u||"")+(o?s:a.addSeparators(s,n))+(r.includes(t)?""+t+f:"")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addSeparators=void 0,r.addSeparators=function(e,r){return void 0===r&&(r=","),e.replace(/\B(?=(\d{3})+(?!\d))/g,r)}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.padTrimValue=void 0,r.padTrimValue=function(e,r,t){if(void 0===r&&(r="."),!t||""===e||void 0===e)return e;if(!e.match(/\d/g))return"";var a=e.split(r),n=a[0],i=a[1]||"";if(i.length<t)for(;i.length<t;)i+="0";else i=i.slice(0,t);return""+n+r+i}}]);
//# sourceMappingURL=index.js.map
{
"name": "react-currency-input-field",
"version": "2.3.1",
"version": "2.3.2",
"description": "React <input /> component for formatting currency and numbers.",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc