aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/Input.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ui/Input.tsx')
-rw-r--r--src/components/ui/Input.tsx21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/components/ui/Input.tsx b/src/components/ui/Input.tsx
index 78b3a9200..c22dc5838 100644
--- a/src/components/ui/Input.tsx
+++ b/src/components/ui/Input.tsx
@@ -1,8 +1,16 @@
1import { ChangeEvent, Component, createRef, RefObject } from 'react'; 1import {
2 ChangeEvent,
3 ChangeEventHandler,
4 Component,
5 createRef,
6 ReactElement,
7 RefObject,
8} from 'react';
2import { observer } from 'mobx-react'; 9import { observer } from 'mobx-react';
3import classnames from 'classnames'; 10import classnames from 'classnames';
4import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl'; 11import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl';
5import { mdiEye, mdiEyeOff } from '@mdi/js'; 12import { mdiEye, mdiEyeOff } from '@mdi/js';
13import { noop } from 'lodash';
6import { scorePassword as scorePasswordFunc } from '../../helpers/password-helpers'; 14import { scorePassword as scorePasswordFunc } from '../../helpers/password-helpers';
7import Icon from './icon'; 15import Icon from './icon';
8import { Field } from '../../@types/mobx-form.types'; 16import { Field } from '../../@types/mobx-form.types';
@@ -23,6 +31,8 @@ interface IProps extends WrappedComponentProps {
23 scorePassword?: boolean; 31 scorePassword?: boolean;
24 prefix?: string; 32 prefix?: string;
25 suffix?: string; 33 suffix?: string;
34 placeholder?: string;
35 onChange?: ChangeEventHandler<HTMLInputElement>;
26} 36}
27 37
28interface IState { 38interface IState {
@@ -53,14 +63,17 @@ class Input extends Component<IProps, IState> {
53 } 63 }
54 64
55 onChange(e: ChangeEvent<HTMLInputElement>): void { 65 onChange(e: ChangeEvent<HTMLInputElement>): void {
56 const { field, scorePassword } = this.props; 66 const { field, scorePassword, onChange = noop } = this.props;
57 67
58 if (field.onChange) { 68 if (field.onChange) {
69 onChange(e);
59 field.onChange(e); 70 field.onChange(e);
60 } 71 }
61 72
62 if (scorePassword) { 73 if (scorePassword) {
63 this.setState({ passwordScore: scorePasswordFunc(field.value) }); 74 this.setState({
75 passwordScore: scorePasswordFunc(field.value as string),
76 });
64 } 77 }
65 } 78 }
66 79
@@ -70,7 +83,7 @@ class Input extends Component<IProps, IState> {
70 } 83 }
71 } 84 }
72 85
73 render() { 86 render(): ReactElement {
74 const { 87 const {
75 field, 88 field,
76 className = null, 89 className = null,