commit
f9e6d2e834
|
@ -41,7 +41,7 @@
|
|||
"react-helmet": "6.0.0-beta",
|
||||
"react-highlight-words": "^0.11.0",
|
||||
"react-i18next": "^10.0.1",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-redux": "^7.0.3",
|
||||
"react-router": "^4.3.1",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"react-select": "^1.2.1",
|
||||
|
@ -54,7 +54,7 @@
|
|||
"reduce-reducers": "^0.1.2",
|
||||
"redux": "^3.7.2",
|
||||
"redux-batched-actions": "^0.4.1",
|
||||
"redux-form": "^7.4.2",
|
||||
"redux-form": "^8.2.0",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"reselect": "^4.0.0",
|
||||
"screenfull": "^3.3.2",
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* @flow */
|
||||
|
||||
import { resetSimulation } from 'Actions/actions'
|
||||
import Overlay from 'Components/Overlay'
|
||||
import RuleLink from 'Components/RuleLink'
|
||||
|
@ -96,7 +94,7 @@ export default compose(
|
|||
withColours,
|
||||
connect(
|
||||
state => ({ answers: answerWithValueSelector(state) }),
|
||||
(dispatch: Function) => ({
|
||||
dispatch => ({
|
||||
resetSimulation: () => {
|
||||
dispatch(resetSimulation())
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import classnames from 'classnames'
|
||||
import { omit } from 'ramda'
|
||||
import React, { Component } from 'react'
|
||||
import { debounce, isIE } from '../../utils'
|
||||
import { debounce } from '../../utils'
|
||||
import './CurrencyInput.css'
|
||||
|
||||
let isCurrencyPrefixed = language =>
|
||||
|
@ -21,42 +21,13 @@ class CurrencyInput extends Component {
|
|||
: this.props.onChange
|
||||
input = React.createRef()
|
||||
|
||||
getSnapshotBeforeUpdate = () => {
|
||||
if (!this.input.current) {
|
||||
return
|
||||
}
|
||||
return this.input.current.selectionStart
|
||||
}
|
||||
componentDidMount() {
|
||||
this.adaptInputSize()
|
||||
}
|
||||
adaptInputSize = () => {
|
||||
// Because ch mesurement in IE is not consistent with other browsers, we have to apply a multiplier
|
||||
// https://stackoverflow.com/questions/17825638/css3-ch-unit-inconsistent-between-ie9-and-other-browsers
|
||||
const widthMultiplier = isIE() ? 1.4 : 1
|
||||
|
||||
if (this.input.current && isCurrencyPrefixed(this.props.language))
|
||||
this.input.current.style.width =
|
||||
widthMultiplier * (this.input.current.value.length + 0.2) + 'ch'
|
||||
}
|
||||
componentDidUpdate = (_, __, cursorPosition) => {
|
||||
if (!this.input.current) {
|
||||
return
|
||||
}
|
||||
this.input.current.selectionStart = cursorPosition
|
||||
this.input.current.selectionEnd = cursorPosition
|
||||
this.adaptInputSize()
|
||||
}
|
||||
focusInput = () => {
|
||||
this.input.current.focus()
|
||||
}
|
||||
handleChange = event => {
|
||||
let value = event.target.value
|
||||
value = value
|
||||
.replace(/,/g, '.')
|
||||
.replace(/[^\d.]/g, '')
|
||||
.replace(/\.(.*)\.(.*)/g, '$1.$2')
|
||||
this.setState({ value }, this.adaptInputSize)
|
||||
this.setState({ value })
|
||||
|
||||
if (value.endsWith('.')) {
|
||||
return
|
||||
|
@ -77,7 +48,6 @@ class CurrencyInput extends Component {
|
|||
|
||||
return (
|
||||
<div
|
||||
onClick={this.focusInput}
|
||||
className={classnames(
|
||||
this.props.className,
|
||||
'currencyInput__container'
|
||||
|
|
|
@ -250,7 +250,6 @@ let CurrencyField = withColours(props => {
|
|||
}}
|
||||
debounce={600}
|
||||
className="targetInput"
|
||||
key={props.input.value}
|
||||
defaultValue={props.input.value}
|
||||
{...props.input}
|
||||
{...props}
|
||||
|
@ -267,31 +266,32 @@ let TargetInputOrValue = withLanguage(
|
|||
language,
|
||||
firstStepCompleted,
|
||||
inversionFail
|
||||
}) => (
|
||||
<span className="targetInputOrValue">
|
||||
{activeInput === target.dottedName ||
|
||||
!target.formule ||
|
||||
isEmpty(target.formule) ? (
|
||||
<Field
|
||||
name={target.dottedName}
|
||||
{...(target.formule ? { autoFocus: true } : {})}
|
||||
component={CurrencyField}
|
||||
language={language}
|
||||
/>
|
||||
) : (
|
||||
<TargetValue
|
||||
{...{
|
||||
targets,
|
||||
target,
|
||||
activeInput,
|
||||
setActiveInput,
|
||||
firstStepCompleted,
|
||||
inversionFail
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}) => {
|
||||
let inputIsActive = activeInput === target.dottedName
|
||||
return (
|
||||
<span className="targetInputOrValue">
|
||||
{inputIsActive || !target.formule || isEmpty(target.formule) ? (
|
||||
<Field
|
||||
name={target.dottedName}
|
||||
component={CurrencyField}
|
||||
{...(inputIsActive ? { autoFocus: true } : {})}
|
||||
language={language}
|
||||
/>
|
||||
) : (
|
||||
<TargetValue
|
||||
{...{
|
||||
targets,
|
||||
target,
|
||||
activeInput,
|
||||
setActiveInput,
|
||||
firstStepCompleted,
|
||||
inversionFail
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
const TargetValue = connect(
|
||||
|
|
71
yarn.lock
71
yarn.lock
|
@ -710,6 +710,13 @@
|
|||
dependencies:
|
||||
regenerator-runtime "^0.13.2"
|
||||
|
||||
"@babel/runtime@^7.2.0", "@babel/runtime@^7.4.3":
|
||||
version "7.4.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.4.tgz#dc2e34982eb236803aa27a07fea6857af1b9171d"
|
||||
integrity sha512-w0+uT71b6Yi7i5SE0co4NioIpSYS6lLiXvCzWzGSKvpK5vdQtCbICHMj+gbAKAOtxiV6HsVh/MBdaF9EQ6faSg==
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.2"
|
||||
|
||||
"@babel/template@^7.1.0", "@babel/template@^7.2.2", "@babel/template@^7.4.0":
|
||||
version "7.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.0.tgz#12474e9c077bae585c5d835a95c0b0b790c25c8b"
|
||||
|
@ -4316,19 +4323,12 @@ hoek@4.x.x:
|
|||
version "4.2.1"
|
||||
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
|
||||
|
||||
hoist-non-react-statics@^2.2.2, hoist-non-react-statics@^2.5.0, hoist-non-react-statics@^2.5.4:
|
||||
hoist-non-react-statics@^2.2.2, hoist-non-react-statics@^2.5.0:
|
||||
version "2.5.5"
|
||||
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47"
|
||||
integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==
|
||||
|
||||
hoist-non-react-statics@^3.1.0:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.2.1.tgz#c09c0555c84b38a7ede6912b61efddafd6e75e1e"
|
||||
integrity sha512-TFsu3TV3YLY+zFTZDrN8L2DTFanObwmBLpWvJs1qfUuEQ5bTAdFcwfx2T/bsCXfM9QHSLvjfP+nihEl0yvozxw==
|
||||
dependencies:
|
||||
react-is "^16.3.2"
|
||||
|
||||
hoist-non-react-statics@^3.3.0:
|
||||
hoist-non-react-statics@^3.2.1, hoist-non-react-statics@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
|
||||
integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==
|
||||
|
@ -5380,7 +5380,7 @@ locate-path@^3.0.0:
|
|||
p-locate "^3.0.0"
|
||||
path-exists "^3.0.0"
|
||||
|
||||
lodash-es@^4.17.10, lodash-es@^4.2.1:
|
||||
lodash-es@^4.17.11, lodash-es@^4.2.1:
|
||||
version "4.17.11"
|
||||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.11.tgz#145ab4a7ac5c5e52a3531fb4f310255a152b4be0"
|
||||
|
||||
|
@ -7392,37 +7392,31 @@ react-input-autosize@^2.1.2:
|
|||
dependencies:
|
||||
prop-types "^15.5.8"
|
||||
|
||||
react-is@^16.3.2:
|
||||
version "16.6.3"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.3.tgz#d2d7462fcfcbe6ec0da56ad69047e47e56e7eac0"
|
||||
integrity sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA==
|
||||
|
||||
react-is@^16.6.0:
|
||||
version "16.8.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.1.tgz#a80141e246eb894824fb4f2901c0c50ef31d4cdb"
|
||||
integrity sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA==
|
||||
|
||||
react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4:
|
||||
version "16.8.4"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2"
|
||||
integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA==
|
||||
|
||||
react-lifecycles-compat@^3.0.0, react-lifecycles-compat@^3.0.4:
|
||||
react-is@^16.8.6:
|
||||
version "16.8.6"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
|
||||
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
|
||||
|
||||
react-lifecycles-compat@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
|
||||
|
||||
react-redux@^5.0.7:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.1.1.tgz#88e368682c7fa80e34e055cd7ac56f5936b0f52f"
|
||||
integrity sha512-LE7Ned+cv5qe7tMV5BPYkGQ5Lpg8gzgItK07c67yHvJ8t0iaD9kPFPAli/mYkiyJYrs2pJgExR2ZgsGqlrOApg==
|
||||
react-redux@^7.0.3:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.0.3.tgz#983c5a6de81cb1e696bd1c090ba826545f9170f1"
|
||||
integrity sha512-vYZA7ftOYlDk3NetitsI7fLjryt/widNl1SLXYvFenIpm7vjb4ryK0EeFrgn62usg5fYkyIAWNUPKnwWPevKLg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.1.2"
|
||||
hoist-non-react-statics "^3.1.0"
|
||||
"@babel/runtime" "^7.4.3"
|
||||
hoist-non-react-statics "^3.3.0"
|
||||
invariant "^2.2.4"
|
||||
loose-envify "^1.1.0"
|
||||
prop-types "^15.6.1"
|
||||
react-is "^16.6.0"
|
||||
react-lifecycles-compat "^3.0.0"
|
||||
loose-envify "^1.4.0"
|
||||
prop-types "^15.7.2"
|
||||
react-is "^16.8.6"
|
||||
|
||||
react-router-dom@^4.3.1:
|
||||
version "4.3.1"
|
||||
|
@ -7665,17 +7659,20 @@ redux-batched-actions@^0.4.1:
|
|||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/redux-batched-actions/-/redux-batched-actions-0.4.1.tgz#a8de8cef50a1db4f009d5222820c836515597e22"
|
||||
|
||||
redux-form@^7.4.2:
|
||||
version "7.4.2"
|
||||
resolved "https://registry.yarnpkg.com/redux-form/-/redux-form-7.4.2.tgz#d6061088fb682eb9fc5fb9749bd8b102f03154b0"
|
||||
redux-form@^8.2.0:
|
||||
version "8.2.0"
|
||||
resolved "https://registry.yarnpkg.com/redux-form/-/redux-form-8.2.0.tgz#87667f39a7eebd4c6ed368817481c1ece80c8890"
|
||||
integrity sha512-KXsOLwlhV1hn8unTWtxNpFJW2vtIyoGX4zCIw3lSbWCqz8kOyG774aSTPt7k9MTKzJBtxNGZK0O0d2UhTk+JkQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.2.0"
|
||||
es6-error "^4.1.1"
|
||||
hoist-non-react-statics "^2.5.4"
|
||||
hoist-non-react-statics "^3.2.1"
|
||||
invariant "^2.2.4"
|
||||
is-promise "^2.1.0"
|
||||
lodash "^4.17.10"
|
||||
lodash-es "^4.17.10"
|
||||
lodash "^4.17.11"
|
||||
lodash-es "^4.17.11"
|
||||
prop-types "^15.6.1"
|
||||
react-is "^16.7.0"
|
||||
react-lifecycles-compat "^3.0.4"
|
||||
|
||||
redux-thunk@^2.3.0:
|
||||
|
|
Loading…
Reference in New Issue