aboutsummaryrefslogtreecommitdiffstats
path: root/packages/forms/src/input/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/forms/src/input/index.tsx')
-rw-r--r--packages/forms/src/input/index.tsx20
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/forms/src/input/index.tsx b/packages/forms/src/input/index.tsx
index 478738cad..a2d7c62d5 100644
--- a/packages/forms/src/input/index.tsx
+++ b/packages/forms/src/input/index.tsx
@@ -25,6 +25,7 @@ interface IProps extends React.InputHTMLAttributes<HTMLInputElement>, IFormField
25 showPasswordToggle?: boolean; 25 showPasswordToggle?: boolean;
26 data: IData; 26 data: IData;
27 inputClassName?: string; 27 inputClassName?: string;
28 onEnterKey?: Function;
28} 29}
29 30
30interface IState { 31interface IState {
@@ -33,7 +34,7 @@ interface IState {
33} 34}
34 35
35class InputComponent extends Component<IProps, IState> { 36class InputComponent extends Component<IProps, IState> {
36 public static defaultProps = { 37 static defaultProps = {
37 focus: false, 38 focus: false,
38 onChange: () => {}, 39 onChange: () => {},
39 onBlur: () => {}, 40 onBlur: () => {},
@@ -81,6 +82,13 @@ class InputComponent extends Component<IProps, IState> {
81 } 82 }
82 } 83 }
83 84
85 onInputKeyPress(e: React.KeyboardEvent) {
86 if (e.key === "Enter") {
87 const { onEnterKey } = this.props;
88 onEnterKey && onEnterKey();
89 }
90 }
91
84 render() { 92 render() {
85 const { 93 const {
86 classes, 94 classes,
@@ -102,6 +110,10 @@ class InputComponent extends Component<IProps, IState> {
102 spellCheck, 110 spellCheck,
103 onBlur, 111 onBlur,
104 onFocus, 112 onFocus,
113 min,
114 max,
115 step,
116 required,
105 } = this.props; 117 } = this.props;
106 118
107 const { 119 const {
@@ -120,6 +132,8 @@ class InputComponent extends Component<IProps, IState> {
120 title={label} 132 title={label}
121 showLabel={showLabel} 133 showLabel={showLabel}
122 htmlFor={id} 134 htmlFor={id}
135 className={classes.label}
136 isRequired={required}
123 > 137 >
124 <div 138 <div
125 className={classnames({ 139 className={classnames({
@@ -147,6 +161,10 @@ class InputComponent extends Component<IProps, IState> {
147 onFocus={onFocus} 161 onFocus={onFocus}
148 onBlur={onBlur} 162 onBlur={onBlur}
149 disabled={disabled} 163 disabled={disabled}
164 onKeyPress={this.onInputKeyPress.bind(this)}
165 min={min}
166 max={max}
167 step={step}
150 /> 168 />
151 {suffix && ( 169 {suffix && (
152 <span className={classes.suffix}> 170 <span className={classes.suffix}>