From 5f1ea01cd6f83fcab405d89d5c9c9b588754b434 Mon Sep 17 00:00:00 2001 From: David Nussio Date: Wed, 2 Dec 2020 08:03:40 +0100 Subject: [PATCH] Allow empty value and let user to cancel current value - Added prettier rule { "arrowParens": "avoid" } to avoid unexpected formatting code --- lib/components/Number.js | 3 +++ package.json | 3 ++- stories/Demo.js | 9 +++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/components/Number.js b/lib/components/Number.js index 82d90544..5a47d5bc 100644 --- a/lib/components/Number.js +++ b/lib/components/Number.js @@ -15,6 +15,9 @@ const positiveValidation = value => { const integerValidation = value => parseFloat(value) % 1 === 0; const numberValidator = (decimal, negative) => value => { + if (value === '') { + return true; + } if (value === '-' && negative) { return true; } diff --git a/package.json b/package.json index 19ab7ac2..4222f1ab 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,8 @@ "prettier": { "printWidth": 100, "singleQuote": true, - "trailingComma": "es5" + "trailingComma": "es5", + "arrowParens": "avoid" }, "husky": { "hooks": { diff --git a/stories/Demo.js b/stories/Demo.js index b81de80b..151346e2 100644 --- a/stories/Demo.js +++ b/stories/Demo.js @@ -99,6 +99,7 @@ const NumPadDemo = () => { negative={false} position="startTopLeft" placeholder="Positive" + value={state.positiveNumber} > @@ -196,12 +197,8 @@ const NumPadDemo = () => { onChange={value => dispatch({ type: 'markers.calendar', value })} dateFormat="DD.MM.YYYY" markers={[ - moment() - .subtract(4, 'days') - .format('DD.MM.YYYY'), - moment() - .add(1, 'days') - .format('DD.MM.YYYY'), + moment().subtract(4, 'days').format('DD.MM.YYYY'), + moment().add(1, 'days').format('DD.MM.YYYY'), ]} position="startTopLeft" >