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.0.0 to 2.1.0

7

CHANGELOG.md

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

# [2.1.0](https://github.com/cchanxzy/react-currency-input-field/compare/v2.0.0...v2.1.0) (2020-08-13)
### Features
* add prop to turn off separators ([#54](https://github.com/cchanxzy/react-currency-input-field/issues/54)) ([396f567](https://github.com/cchanxzy/react-currency-input-field/commit/396f56719e92353b1e45d419a32fd7c0a916cd7a))
# [2.0.0](https://github.com/cchanxzy/react-currency-input-field/compare/v1.0.1...v2.0.0) (2020-07-02)

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

13

dist/components/CurrencyInputProps.d.ts

@@ -6,2 +6,3 @@ /// <reference types="react" />

* Allow decimals
*
* Default = true

@@ -15,5 +16,5 @@ */

/**
* Component name
* Maximum characters the user can enter
*/
name?: string;
maxLength?: number;
/**

@@ -25,2 +26,3 @@ * Class names

* Limit length of decimals allowed
*
* Default = 2

@@ -35,2 +37,3 @@ */

* Disabled
*
* Default = false

@@ -56,6 +59,8 @@ */

/**
* Maximum characters the user can enter
* Disable auto adding separator between values eg. 1000 > 1,000
*
* Default = false
*/
maxLength?: number;
turnOffSeparators?: boolean;
}>;
export {};

@@ -12,2 +12,2 @@ export declare const addCommas: (value: string) => string;

*/
export declare const formatValue: (value: string, prefix?: string | undefined) => string;
export declare const formatValue: (value: string, turnOffSeparators: boolean, prefix?: string | undefined) => string;

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

module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.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 a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));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 a=n(r(1));t.default=a.default},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},a=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&a(t,e,r);return u(t,e),t},o=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.CurrencyInput=void 0;var l=i(r(2)),c=r(3);t.CurrencyInput=function(e){var t=e.allowDecimals,r=void 0===t||t,a=e.id,u=e.name,i=e.className,f=e.decimalsLimit,s=void 0===f?2:f,d=e.defaultValue,p=e.disabled,m=void 0!==p&&p,v=e.value,b=e.onChange,h=e.placeholder,g=e.precision,y=e.prefix,_=e.maxLength,O=o(e,["allowDecimals","id","name","className","decimalsLimit","defaultValue","disabled","value","onChange","placeholder","precision","prefix","maxLength"]),V=d?c.formatValue(String(d),y):"",j=l.useState(V),P=j[0],S=j[1],x=l.useState(0),M=x[0],C=x[1],N=l.useRef(null);l.useEffect((function(){N&&N.current&&N.current.setSelectionRange(M,M)}),[M,N,P]);var w=v?c.formatValue(String(v),y):void 0;return l.default.createElement("input",n({type:"text",inputMode:"decimal",id:a,name:u,className:i,onChange:function(e){var t=e.target,n=t.selectionStart,a=t.value,i=c.cleanValue(a,r,s,y);if(!i)return b&&b(void 0,u),S("");if(c.checkIsValidNumber(i)){var o=c.formatValue(i,y);if(n){var l=n+(o.length-a.length)||1;C(l)}S(o)}b&&b(i,u)},onBlur:function(e){var t=e.target.value,n=c.cleanValue(t,r,s,y),a=c.padTrimValue(n,g),i=c.formatValue(a,y);S(i),b&&b(a,u)},onFocus:function(){return P?P.length:0},placeholder:h,disabled:m,value:w||P,ref:N,maxLength:_},O))},t.default=t.CurrencyInput},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatValue=t.padTrimValue=t.cleanValue=t.checkIsValidNumber=t.removeCommas=t.addCommas=void 0;var n=r(4);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,a,u){var i=u?e.replace(u,""):e,o=t.removeCommas(i),l=n.parseAbbrValue(o)||o;if(String(l).includes(".")){var c=o.split("."),f=c[0],s=c[1];return""+f+(r?"."+(a?s.slice(0,a):s):"")}return String(l)},t.padTrimValue=function(e,t){if(!t)return e;var r=e.split("."),n=r[0],a=r[1]||"";if(a.length<t)for(;a.length<t;)a+="0";else a=a.slice(0,t);return n+"."+a},t.formatValue=function(e,r){var n=e.split("."),a=n[0],u=n[1],i=r||"",o=e.includes(".")?"."+u:"";return""+i+t.addCommas(a)+o}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseAbbrValue=t.abbrValue=void 0,t.abbrValue=function(e,t){if(void 0===t&&(t=10),e>999){var r=(""+e).length,n=Math.pow,a=n(10,t);return r-=r%3,Math.round(e*a/n(10,r))/a+" kMGTPE"[r/3]}return String(e)};var n={k:1e3,m:1e6,b:1e9};t.parseAbbrValue=function(e){var t=e.match(/(\d+(.\d+)?)([kmb])$/i);if(t){var r=t[1],a=t[3],u=a?n[a.toLowerCase()]:null;if(r&&u)return Number(r)*u}}}]);
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.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 a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));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 a=n(r(1));t.default=a.default},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},a=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&a(t,e,r);return u(t,e),t},o=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.CurrencyInput=void 0;var l=i(r(2)),c=r(3);t.CurrencyInput=function(e){var t=e.allowDecimals,r=void 0===t||t,a=e.id,u=e.name,i=e.className,f=e.decimalsLimit,s=void 0===f?2:f,d=e.defaultValue,p=e.disabled,m=void 0!==p&&p,v=e.maxLength,b=e.value,h=e.onChange,g=e.placeholder,y=e.precision,O=e.prefix,_=e.turnOffSeparators,V=void 0!==_&&_,j=o(e,["allowDecimals","id","name","className","decimalsLimit","defaultValue","disabled","maxLength","value","onChange","placeholder","precision","prefix","turnOffSeparators"]),S=d?c.formatValue(String(d),V,O):"",P=l.useState(S),x=P[0],M=P[1],C=l.useState(0),N=C[0],w=C[1],I=l.useRef(null);l.useEffect((function(){I&&I.current&&I.current.setSelectionRange(N,N)}),[N,I,x]);var k=b?c.formatValue(String(b),V,O):void 0;return l.default.createElement("input",n({type:"text",inputMode:"decimal",id:a,name:u,className:i,onChange:function(e){var t=e.target,n=t.selectionStart,a=t.value,i=c.cleanValue(a,r,s,O);if(!i)return h&&h(void 0,u),M("");if(c.checkIsValidNumber(i)){var o=c.formatValue(i,V,O);if(n){var l=n+(o.length-a.length)||1;w(l)}M(o)}h&&h(i,u)},onBlur:function(e){var t=e.target.value,n=c.cleanValue(t,r,s,O),a=c.padTrimValue(n,y),i=c.formatValue(a,V,O);M(i),h&&h(a,u)},onFocus:function(){return x?x.length:0},placeholder:g,disabled:m,value:k||x,ref:I,maxLength:v},j))},t.default=t.CurrencyInput},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatValue=t.padTrimValue=t.cleanValue=t.checkIsValidNumber=t.removeCommas=t.addCommas=void 0;var n=r(4);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,a,u){var i=u?e.replace(u,""):e,o=t.removeCommas(i),l=n.parseAbbrValue(o)||o;if(String(l).includes(".")){var c=o.split("."),f=c[0],s=c[1];return""+f+(r?"."+(a?s.slice(0,a):s):"")}return String(l)},t.padTrimValue=function(e,t){if(!t)return e;var r=e.split("."),n=r[0],a=r[1]||"";if(a.length<t)for(;a.length<t;)a+="0";else a=a.slice(0,t);return n+"."+a},t.formatValue=function(e,r,n){var a=e.split("."),u=a[0],i=a[1],o=n||"",l=e.includes(".")?"."+i:"";return""+o+(r?u:t.addCommas(u))+l}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseAbbrValue=t.abbrValue=void 0,t.abbrValue=function(e,t){if(void 0===t&&(t=10),e>999){var r=(""+e).length,n=Math.pow,a=n(10,t);return r-=r%3,Math.round(e*a/n(10,r))/a+" kMGTPE"[r/3]}return String(e)};var n={k:1e3,m:1e6,b:1e9};t.parseAbbrValue=function(e){var t=e.match(/(\d+(.\d+)?)([kmb])$/i);if(t){var r=t[1],a=t[3],u=a?n[a.toLowerCase()]:null;if(r&&u)return Number(r)*u}}}]);
//# sourceMappingURL=index.js.map
{
"name": "react-currency-input-field",
"version": "2.0.0",
"version": "2.1.0",
"description": "React <input /> component for formatting currency and numbers.",

@@ -43,24 +43,24 @@ "files": [

"devDependencies": {
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@types/enzyme": "^3.10.5",
"@types/jest": "^26.0.3",
"@types/react": "^16.9.41",
"@types/jest": "^26.0.9",
"@types/react": "^16.9.46",
"@types/react-dom": "^16.9.8",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/parser": "^3.5.0",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"awesome-typescript-loader": "^5.2.1",
"codecov": "^3.7.0",
"codecov": "^3.7.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^7.3.1",
"enzyme-adapter-react-16": "^1.15.3",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react": "^7.20.6",
"gh-pages": "^3.1.0",
"html-webpack-plugin": "^4.3.0",
"husky": "^4.2.5",
"jest": "^26.1.0",
"jest": "^26.4.0",
"lint-staged": "^10.2.11",

@@ -73,5 +73,5 @@ "prettier": "^2.0.5",

"source-map-loader": "^1.0.1",
"ts-jest": "^26.1.1",
"typescript": "^3.9.6",
"webpack": "^4.43.0",
"ts-jest": "^26.2.0",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",

@@ -78,0 +78,0 @@ "webpack-dev-server": "^3.11.0"

@@ -58,16 +58,16 @@ # React Currency Input Field Component

| Name | Type | Default | Description |
| ------------- | ---------- | ------- | ---------------------------------------------- |
| allowDecimals | `boolean` | `true` | Allow decimals |
| id | `string` | | Component id |
| name | `string` | | Component (input) name |
| className | `string` | | Class names |
| decimalsLimit | `number` | `2` | Limit length of decimals allowed |
| defaultValue | `number` | | Default value |
| disabled | `boolean` | `false` | Disabled |
| onChange | `function` | | Handle change in value |
| placeholder | `string` | | Placeholder if no value |
| precision | `number` | | Specify decimal precision for padding/trimming |
| prefix | `string` | | Include a prefix eg. £ or \$ |
| maxLength | `number` | | Maximum characters the user can enter |
| Name | Type | Default | Description |
| ----------------- | ---------- | ------- | ------------------------------------------------------------- |
| allowDecimals | `boolean` | `true` | Allow decimals |
| className | `string` | | Class names |
| decimalsLimit | `number` | `2` | Limit length of decimals allowed |
| defaultValue | `number` | | Default value |
| disabled | `boolean` | `false` | Disabled |
| id | `string` | | Component id |
| maxLength | `number` | | Maximum characters the user can enter |
| onChange | `function` | | Handle change in value |
| placeholder | `string` | | Placeholder if no value |
| precision | `number` | | Specify decimal precision for padding/trimming |
| prefix | `string` | | Include a prefix eg. £ or \$ |
| turnOffSeparators | `boolean` | `false` | Disable auto adding separator between values eg. 1000 > 1,000 |

@@ -74,0 +74,0 @@ ## Issues

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