react-currency-input-field
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -5,97 +5,84 @@ # Changelog | ||
### [0.3.1](https://github.com/cchanxzy/React-Currency-Input-Field/compare/v0.3.0...v0.3.1) (2019-11-21) | ||
### [0.3.1](https://github.com/cchanxzy/react-currency-input-field/compare/v0.3.0...v0.3.1) (2019-11-21) | ||
## [0.3.0](https://github.com/cchanxzy/React-Currency-Input-Field/compare/v0.2.0...v0.3.0) (2019-11-21) | ||
## [0.3.0](https://github.com/cchanxzy/react-currency-input-field/compare/v0.2.0...v0.3.0) (2019-11-21) | ||
### Features | ||
* can set default value and decimals ([#8](https://github.com/cchanxzy/React-Currency-Input-Field/issues/8)) ([54b2d4b](https://github.com/cchanxzy/React-Currency-Input-Field/commit/54b2d4b)) | ||
- can set default value and decimals ([#8](https://github.com/cchanxzy/react-currency-input-field/issues/8)) ([54b2d4b](https://github.com/cchanxzy/react-currency-input-field/commit/54b2d4b)) | ||
### [0.2.1](https://github.com/cchanxzy/React-Currency-Input-Field/compare/v0.2.0...v0.2.1) (2019-11-21) | ||
### [0.2.1](https://github.com/cchanxzy/react-currency-input-field/compare/v0.2.0...v0.2.1) (2019-11-21) | ||
### Features | ||
* can set default value and decimals ([#8](https://github.com/cchanxzy/React-Currency-Input-Field/issues/8)) ([54b2d4b](https://github.com/cchanxzy/React-Currency-Input-Field/commit/54b2d4b)) | ||
- can set default value and decimals ([#8](https://github.com/cchanxzy/react-currency-input-field/issues/8)) ([54b2d4b](https://github.com/cchanxzy/react-currency-input-field/commit/54b2d4b)) | ||
## 0.2.0 (2019-09-08) | ||
### ⚠ BREAKING CHANGES | ||
* removed limit prop | ||
- removed limit prop | ||
* chore: updated workflow | ||
- chore: updated workflow | ||
* Feat/remove limit update with hooks (#5) ([a3463bd](https://github.com/cchanxzy/React-Currency-Input-Field/commit/a3463bd)), closes [#5](https://github.com/cchanxzy/React-Currency-Input-Field/issues/5) | ||
- Feat/remove limit update with hooks (#5) ([a3463bd](https://github.com/cchanxzy/react-currency-input-field/commit/a3463bd)), closes [#5](https://github.com/cchanxzy/react-currency-input-field/issues/5) | ||
### Bug Fixes | ||
* updated packages ([42db1d8](https://github.com/cchanxzy/React-Currency-Input-Field/commit/42db1d8)) | ||
- updated packages ([42db1d8](https://github.com/cchanxzy/react-currency-input-field/commit/42db1d8)) | ||
## 0.1.0 (2019-09-08) | ||
### ⚠ BREAKING CHANGES | ||
* removed limit prop | ||
- removed limit prop | ||
* chore: updated workflow | ||
- chore: updated workflow | ||
* Feat/remove limit update with hooks (#5) ([a3463bd](https://github.com/cchanxzy/React-Currency-Input-Field/commit/a3463bd)), closes [#5](https://github.com/cchanxzy/React-Currency-Input-Field/issues/5) | ||
- Feat/remove limit update with hooks (#5) ([a3463bd](https://github.com/cchanxzy/react-currency-input-field/commit/a3463bd)), closes [#5](https://github.com/cchanxzy/react-currency-input-field/issues/5) | ||
### Bug Fixes | ||
* updated packages ([42db1d8](https://github.com/cchanxzy/React-Currency-Input-Field/commit/42db1d8)) | ||
- updated packages ([42db1d8](https://github.com/cchanxzy/react-currency-input-field/commit/42db1d8)) | ||
### [0.0.47](https://github.com/cchanxzy/React-Currency-Input-Field/compare/v0.10.0...v0.0.47) (2019-09-08) | ||
### [0.0.47](https://github.com/cchanxzy/react-currency-input-field/compare/v0.10.0...v0.0.47) (2019-09-08) | ||
## 0.10.0 (2019-09-08) | ||
### ⚠ BREAKING CHANGES | ||
* removed limit prop | ||
- removed limit prop | ||
* removed limit prop, updated tests and examples ([ed24b8e](https://github.com/cchanxzy/React-Currency-Input-Field/commit/ed24b8e)) | ||
- removed limit prop, updated tests and examples ([ed24b8e](https://github.com/cchanxzy/react-currency-input-field/commit/ed24b8e)) | ||
### Bug Fixes | ||
* updated packages ([7e80871](https://github.com/cchanxzy/React-Currency-Input-Field/commit/7e80871)) | ||
- updated packages ([7e80871](https://github.com/cchanxzy/react-currency-input-field/commit/7e80871)) | ||
## 0.1.0 (2019-09-08) | ||
### ⚠ BREAKING CHANGES | ||
* removed limit prop | ||
- removed limit prop | ||
* removed limit prop, updated tests and examples ([ed24b8e](https://github.com/cchanxzy/React-Currency-Input-Field/commit/ed24b8e)) | ||
- removed limit prop, updated tests and examples ([ed24b8e](https://github.com/cchanxzy/react-currency-input-field/commit/ed24b8e)) | ||
### Bug Fixes | ||
* updated packages ([7e80871](https://github.com/cchanxzy/React-Currency-Input-Field/commit/7e80871)) | ||
- updated packages ([7e80871](https://github.com/cchanxzy/react-currency-input-field/commit/7e80871)) | ||
### 0.0.47 (2019-09-08) | ||
### Bug Fixes | ||
* updated packages ([7e80871](https://github.com/cchanxzy/React-Currency-Input-Field/commit/7e80871)) | ||
- updated packages ([7e80871](https://github.com/cchanxzy/react-currency-input-field/commit/7e80871)) | ||
### Features | ||
* upating tests and examples ([e18c23a](https://github.com/cchanxzy/React-Currency-Input-Field/commit/e18c23a)) | ||
- upating tests and examples ([e18c23a](https://github.com/cchanxzy/react-currency-input-field/commit/e18c23a)) | ||
### 0.0.46 (2019-08-29) | ||
### Bug Fixes | ||
* updated packages ([7e80871](https://github.com/cchanxzy/React-Currency-Input-Field/commit/7e80871)) | ||
- updated packages ([7e80871](https://github.com/cchanxzy/react-currency-input-field/commit/7e80871)) |
@@ -7,7 +7,3 @@ module.exports = { | ||
'scope-case': [2, 'always', 'lower-case'], | ||
'subject-case': [ | ||
2, | ||
'never', | ||
['sentence-case', 'start-case', 'pascal-case', 'upper-case'], | ||
], | ||
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], | ||
'subject-empty': [2, 'never'], | ||
@@ -14,0 +10,0 @@ 'subject-full-stop': [2, 'never', '.'], |
@@ -1,2 +0,127 @@ | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}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 o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));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});const o=n(r(1));t.default=o.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});const o=n(r(2)),u=r(3);class a extends o.PureComponent{constructor(e){super(e),this.state={value:""},this.processChange=this.processChange.bind(this)}processChange(e){const{target:{value:t}}=e,{onChange:r,limit:n,prefix:o}=this.props;let a=t;if(o&&(a=t.replace(o,"")),""===a||null===a)return this.setState({value:""}),r(null),!1;let s=parseInt(u.removeCommas(a),10);const l=n||9999999999999;if(u.checkIsValidNumber(s,l)){let e=u.addCommas(s);o&&(e=`${o}${e}`),this.setState({value:e})}r(s)}render(){const{className:e,id:t,handleError:r,placeholder:n}=this.props,{value:u}=this.state;return o.default.createElement("input",{type:"string",id:t,className:e,onChange:this.processChange,placeholder:n,value:u})}}t.CurrenyInput=a,t.default=a},function(e,t){e.exports=React},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addCommas=(e=>e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")),t.removeCommas=(e=>e.replace(/,/g,"")),t.checkIsValidNumber=((e,t)=>0===e||!(e<0||Number.isNaN(e))&&e<=t)}]); | ||
//# sourceMappingURL=bundle.js.map | ||
!(function(e) { | ||
const t = {}; | ||
function r(n) { | ||
if (t[n]) return t[n].exports; | ||
const o = (t[n] = { i: n, l: !1, exports: {} }); | ||
return e[n].call(o.exports, o, o.exports, r), (o.l = !0), o.exports; | ||
} | ||
(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; | ||
const n = Object.create(null); | ||
if ( | ||
(r.r(n), | ||
Object.defineProperty(n, 'default', { enumerable: !0, value: e }), | ||
2 & t && 'string' != typeof e) | ||
) | ||
for (const o in e) | ||
r.d( | ||
n, | ||
o, | ||
function(t) { | ||
return e[t]; | ||
}.bind(null, o) | ||
); | ||
return n; | ||
}), | ||
(r.n = function(e) { | ||
const 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'; | ||
const n = | ||
(this && this.__importDefault) || | ||
function(e) { | ||
return e && e.__esModule ? e : { default: e }; | ||
}; | ||
Object.defineProperty(t, '__esModule', { value: !0 }); | ||
const o = n(r(1)); | ||
t.default = o.default; | ||
}, | ||
function(e, t, r) { | ||
'use strict'; | ||
const n = | ||
(this && this.__importStar) || | ||
function(e) { | ||
if (e && e.__esModule) return e; | ||
const t = {}; | ||
if (null != e) for (const r in e) Object.hasOwnProperty.call(e, r) && (t[r] = e[r]); | ||
return (t.default = e), t; | ||
}; | ||
Object.defineProperty(t, '__esModule', { value: !0 }); | ||
const o = n(r(2)), | ||
u = r(3); | ||
class a extends o.PureComponent { | ||
constructor(e) { | ||
super(e), | ||
(this.state = { value: '' }), | ||
(this.processChange = this.processChange.bind(this)); | ||
} | ||
processChange(e) { | ||
const { | ||
target: { value: t }, | ||
} = e, | ||
{ onChange: r, limit: n, prefix: o } = this.props; | ||
let a = t; | ||
if ((o && (a = t.replace(o, '')), '' === a || null === a)) | ||
return this.setState({ value: '' }), r(null), !1; | ||
const s = parseInt(u.removeCommas(a), 10); | ||
const l = n || 9999999999999; | ||
if (u.checkIsValidNumber(s, l)) { | ||
let e = u.addCommas(s); | ||
o && (e = `${o}${e}`), this.setState({ value: e }); | ||
} | ||
r(s); | ||
} | ||
render() { | ||
const { className: e, id: t, handleError: r, placeholder: n } = this.props, | ||
{ value: u } = this.state; | ||
return o.default.createElement('input', { | ||
type: 'string', | ||
id: t, | ||
className: e, | ||
onChange: this.processChange, | ||
placeholder: n, | ||
value: u, | ||
}); | ||
} | ||
} | ||
(t.CurrenyInput = a), (t.default = a); | ||
}, | ||
function(e, t) { | ||
e.exports = React; | ||
}, | ||
function(e, t, r) { | ||
'use strict'; | ||
Object.defineProperty(t, '__esModule', { value: !0 }), | ||
(t.addCommas = e => e.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')), | ||
(t.removeCommas = e => e.replace(/,/g, '')), | ||
(t.checkIsValidNumber = (e, t) => 0 === e || (!(e < 0 || Number.isNaN(e)) && e <= t)); | ||
}, | ||
]); | ||
//# sourceMappingURL=bundle.js.map |
{ | ||
"name": "react-currency-input-field", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "React input field component for currency and numbers", | ||
"main": "dist/index.js", | ||
"homepage": "https://cchanxzy.github.io/React-Currency-Input-Field", | ||
"homepage": "https://cchanxzy.github.io/react-currency-input-field", | ||
"scripts": { | ||
@@ -12,13 +12,16 @@ "build": "NODE_ENV='prod' webpack --mode=production", | ||
"test:watch": "jest --coverage --watch", | ||
"release": "standard-version", | ||
"predeploy": "NODE_ENV='dev' webpack --mode=development", | ||
"deploy": "gh-pages -d dist" | ||
"lint": "tsc --noEmit && eslint 'src/**/*.{js,ts,tsx}' --max-warnings=0", | ||
"gh-predeploy": "NODE_ENV='dev' webpack --mode=development", | ||
"gh-deploy": "gh-pages -d dist", | ||
"ci": "yarn && yarn build", | ||
"codecov": "codecov", | ||
"semantic-release": "semantic-release" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cchanxzy/React-Currency-Input-Field" | ||
"url": "https://github.com/cchanxzy/react-currency-input-field" | ||
}, | ||
"bugs": { | ||
"email": "cchan.xzy@gmail.com", | ||
"url": "https://github.com/cchanxzy/React-Currency-Input-Field/issues" | ||
"url": "https://github.com/cchanxzy/react-currency-input-field/issues" | ||
}, | ||
@@ -28,6 +31,9 @@ "keywords": [ | ||
"component", | ||
"currency", | ||
"form", | ||
"field", | ||
"number", | ||
"input" | ||
], | ||
"author": "cchan.xzy", | ||
"author": "cchanxzy", | ||
"license": "MIT", | ||
@@ -37,2 +43,3 @@ "devDependencies": { | ||
"@commitlint/config-conventional": "^8.1.0", | ||
"@semantic-release/git": "^7.0.18", | ||
"@types/enzyme": "^3.1.14", | ||
@@ -42,5 +49,12 @@ "@types/jest": "^24.0.18", | ||
"@types/react-dom": "^16.0.7", | ||
"@typescript-eslint/eslint-plugin": "^2.8.0", | ||
"@typescript-eslint/parser": "^2.8.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"codecov": "^3.6.1", | ||
"enzyme": "^3.6.0", | ||
"enzyme-adapter-react-16": "^1.5.0", | ||
"eslint": "^6.7.0", | ||
"eslint-config-prettier": "^6.7.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"eslint-plugin-react": "^7.16.0", | ||
"gh-pages": "^2.1.1", | ||
@@ -50,14 +64,10 @@ "html-webpack-plugin": "^3.2.0", | ||
"jest": "^25.0.0", | ||
"prettier": "^1.18.2", | ||
"lint-staged": "^9.4.3", | ||
"prettier": "^1.19.1", | ||
"react": "^16.9.0", | ||
"react-dom": "^16.5.2", | ||
"react-hot-loader": "^4.3.11", | ||
"semantic-release": "^15.13.31", | ||
"source-map-loader": "^0.2.4", | ||
"standard-version": "^7.0.0", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.11.0", | ||
"tslint-config-airbnb": "^5.11.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-plugin-prettier": "^2.0.1", | ||
"tslint-react": "^4.0.0", | ||
"typescript": "^3.0.3", | ||
@@ -74,2 +84,3 @@ "webpack": "^4.19.1", | ||
"verbose": true, | ||
"collectCoverage": true, | ||
"setupFilesAfterEnv": [ | ||
@@ -96,2 +107,3 @@ "./.enzymerc.js" | ||
"hooks": { | ||
"pre-commit": "yarn lint", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
@@ -98,0 +110,0 @@ } |
## React Currency Input Field Component | ||
[![npm](https://img.shields.io/npm/v/react-currency-input-field)](https://www.npmjs.com/package/react-currency-input-field) [![NPM](https://img.shields.io/npm/l/react-currency-input-field)](https://www.npmjs.com/package/react-currency-input-field) | ||
[![npm](https://img.shields.io/npm/v/react-currency-input-field)](https://www.npmjs.com/package/react-currency-input-field) [![NPM](https://img.shields.io/npm/l/react-currency-input-field)](https://www.npmjs.com/package/react-currency-input-field) [![Codecov Coverage](https://img.shields.io/codecov/c/github/cchanxzy/react-currency-input-field)](https://codecov.io/gh/cchanxzy/react-currency-input-field/) [![Release build](https://github.com/cchanxzy/react-currency-input-field/workflows/Release/badge.svg)](https://github.com/cchanxzy/react-currency-input-field/actions?query=workflow%3ARelease) | ||
@@ -14,3 +14,3 @@ Features: | ||
[Demo](https://cchanxzy.github.io/React-Currency-Input-Field) | ||
[Demo](https://cchanxzy.github.io/react-currency-input-field) | ||
@@ -42,3 +42,3 @@ ![React Currency Input Demo](demo/demo.gif) | ||
Have a look in [`src/examples`](https://github.com/cchanxzy/React-Currency-Input-Field/tree/master/src/examples) for more examples on implementing. | ||
Have a look in [`src/examples`](https://github.com/cchanxzy/react-currency-input-field/tree/master/src/examples) for more examples on implementing. | ||
@@ -45,0 +45,0 @@ ### Issues |
@@ -34,3 +34,3 @@ import { addCommas, checkIsValidNumber, cleanValue, formatValue, removeCommas } from '../utilities'; | ||
it('should return false if value is not a number', () => { | ||
const check = checkIsValidNumber('abc' as any); | ||
const check = checkIsValidNumber('abc'); | ||
expect(check).toBe(false); | ||
@@ -37,0 +37,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
export interface ICurrencyInput { | ||
export interface CurrencyInputProps { | ||
/** | ||
@@ -3,0 +3,0 @@ * Allow decimals. |
@@ -1,6 +0,6 @@ | ||
export const addCommas = (value: string) => value.replace(/\B(?=(\d{3})+(?!\d))/g, ','); | ||
export const addCommas = (value: string): string => value.replace(/\B(?=(\d{3})+(?!\d))/g, ','); | ||
export const removeCommas = (value: string): string => value.replace(/,/g, ''); | ||
export const checkIsValidNumber = (input: string) => { | ||
export const checkIsValidNumber = (input: string): boolean => { | ||
if (Number(input) < 0 || isNaN(Number(input))) { | ||
@@ -21,3 +21,3 @@ return false; | ||
prefix?: string | ||
) => { | ||
): string => { | ||
const withoutPrefix = prefix ? value.replace(prefix, '') : value; | ||
@@ -41,3 +41,3 @@ const withoutCommas = removeCommas(withoutPrefix); | ||
*/ | ||
export const formatValue = (value: string, prefix?: string) => { | ||
export const formatValue = (value: string, prefix?: string): string => { | ||
const [int, decimals] = value.split('.'); | ||
@@ -44,0 +44,0 @@ const includePrefix = prefix ? prefix : ''; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
419682
31
643
2
33