|
@ -45,6 +45,7 @@ function stopPropagation(e) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
|
|
|
|
onChangeFocus: boolean => void, |
|
|
onChange: (number, Unit) => void, // FIXME Unit shouldn't be provided (this is not "standard" onChange)
|
|
|
onChange: (number, Unit) => void, // FIXME Unit shouldn't be provided (this is not "standard" onChange)
|
|
|
onChangeUnit: Unit => void, |
|
|
onChangeUnit: Unit => void, |
|
|
renderRight: any, |
|
|
renderRight: any, |
|
@ -61,6 +62,7 @@ type State = { |
|
|
|
|
|
|
|
|
class InputCurrency extends PureComponent<Props, State> { |
|
|
class InputCurrency extends PureComponent<Props, State> { |
|
|
static defaultProps = { |
|
|
static defaultProps = { |
|
|
|
|
|
onChangeFocus: noop, |
|
|
onChange: noop, |
|
|
onChange: noop, |
|
|
renderRight: null, |
|
|
renderRight: null, |
|
|
units: [], |
|
|
units: [], |
|
@ -122,8 +124,15 @@ class InputCurrency extends PureComponent<Props, State> { |
|
|
this.setState({ displayValue: v || '' }) |
|
|
this.setState({ displayValue: v || '' }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleBlur = () => this.syncInput({ isFocused: false }) |
|
|
handleBlur = () => { |
|
|
handleFocus = () => this.syncInput({ isFocused: true }) |
|
|
this.syncInput({ isFocused: false }) |
|
|
|
|
|
this.props.onChangeFocus(false) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleFocus = () => { |
|
|
|
|
|
this.syncInput({ isFocused: true }) |
|
|
|
|
|
this.props.onChangeFocus(true) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
syncInput = ({ isFocused }: { isFocused: boolean }) => { |
|
|
syncInput = ({ isFocused }: { isFocused: boolean }) => { |
|
|
const { value, showAllDigits, unit } = this.props |
|
|
const { value, showAllDigits, unit } = this.props |
|
|