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 0.7.0 to 0.8.0

7

CHANGELOG.md

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

# [0.8.0](https://github.com/cchanxzy/react-currency-input-field/compare/v0.7.0...v0.8.0) (2020-04-13)
### Features
* adding maxLength prop ([#32](https://github.com/cchanxzy/react-currency-input-field/issues/32)) ([3b1ec54](https://github.com/cchanxzy/react-currency-input-field/commit/3b1ec54d98a278b0a854518ba4d3f3baf66bcbdf))
# [0.7.0](https://github.com/cchanxzy/react-currency-input-field/compare/v0.6.0...v0.7.0) (2020-04-10)

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

4

dist/components/CurrencyInputProps.d.ts

@@ -45,2 +45,6 @@ export declare type CurrencyInputProps = {

prefix?: string;
/**
* Max Length
*/
maxLength?: number;
};

2

dist/index.js

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

module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(r(1));t.default=u.default},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var u=n(r(2)),a=r(3);t.CurrencyInput=function(e){var t=e.allowDecimals,r=void 0===t||t,n=e.id,o=e.name,l=e.className,i=e.decimalsLimit,c=void 0===i?2:i,f=e.defaultValue,s=e.disabled,d=void 0!==s&&s,p=e.onChange,m=e.placeholder,v=e.prefix,b=f?a.formatValue(String(f),v):"",_=u.useState(b),y=_[0],g=_[1],h=u.useState(0),O=h[0],j=h[1],S=u.useRef(null);return u.useEffect((function(){S&&S.current&&S.current.setSelectionRange(O,O)}),[O,S,y]),u.default.createElement("input",{type:"string",id:n,name:o,className:l,onChange:function(e){var t=e.target,n=t.selectionStart,u=t.value,l=a.cleanValue(u,r,c,v);if(!l)return p(null,o),g("");if(a.checkIsValidNumber(l)){var i=a.formatValue(l,v);if(n){var f=n+(i.length-u.length)||1;j(f)}g(i)}p(Number(l),o)},onFocus:function(){return y?y.length:0},placeholder:m,disabled:d,value:y,pattern:"[0-9]+([\\.,][0-9]+)?",ref:S})},t.default=t.CurrencyInput},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addCommas=function(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,",")},t.removeCommas=function(e){return e.replace(/,/g,"")},t.checkIsValidNumber=function(e){return!(Number(e)<0||isNaN(Number(e)))},t.cleanValue=function(e,r,n,u){var a=u?e.replace(u,""):e,o=t.removeCommas(a);if(o.includes(".")){var l=o.split("."),i=l[0],c=l[1];return""+i+(r?"."+(n?c.slice(0,n):c):"")}return o},t.formatValue=function(e,r){var n=e.split("."),u=n[0],a=n[1],o=r||"",l=e.includes(".")?"."+a:"";return""+o+t.addCommas(u)+l}}]);
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(r(1));t.default=u.default},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var u=n(r(2)),a=r(3);t.CurrencyInput=function(e){var t=e.allowDecimals,r=void 0===t||t,n=e.id,o=e.name,l=e.className,i=e.decimalsLimit,c=void 0===i?2:i,f=e.defaultValue,s=e.disabled,d=void 0!==s&&s,m=e.onChange,p=e.placeholder,v=e.prefix,b=e.maxLength,_=f?a.formatValue(String(f),v):"",g=u.useState(_),y=g[0],h=g[1],O=u.useState(0),j=O[0],S=O[1],x=u.useRef(null);return u.useEffect((function(){x&&x.current&&x.current.setSelectionRange(j,j)}),[j,x,y]),u.default.createElement("input",{type:"string",id:n,name:o,className:l,onChange:function(e){var t=e.target,n=t.selectionStart,u=t.value,l=a.cleanValue(u,r,c,v);if(!l)return m(null,o),h("");if(a.checkIsValidNumber(l)){var i=a.formatValue(l,v);if(n){var f=n+(i.length-u.length)||1;S(f)}h(i)}m(Number(l),o)},onFocus:function(){return y?y.length:0},placeholder:p,disabled:d,value:y,pattern:"[0-9]+([\\.,][0-9]+)?",ref:x,maxLength:b})},t.default=t.CurrencyInput},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addCommas=function(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,",")},t.removeCommas=function(e){return e.replace(/,/g,"")},t.checkIsValidNumber=function(e){return!(Number(e)<0||isNaN(Number(e)))},t.cleanValue=function(e,r,n,u){var a=u?e.replace(u,""):e,o=t.removeCommas(a);if(o.includes(".")){var l=o.split("."),i=l[0],c=l[1];return""+i+(r?"."+(n?c.slice(0,n):c):"")}return o},t.formatValue=function(e,r){var n=e.split("."),u=n[0],a=n[1],o=r||"",l=e.includes(".")?"."+a:"";return""+o+t.addCommas(u)+l}}]);
//# sourceMappingURL=index.js.map
{
"name": "react-currency-input-field",
"version": "0.7.0",
"version": "0.8.0",
"description": "React input field component for 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