@@ -1,7 +1,7 @@
11import React, { useCallback, useEffect, useMemo, useState } from 'react';
22import cn from 'classnames';
33
4−import Grid from 'components/Grid';
4+import { Flex } from 'indigo-react';
55
66import { compose } from 'lib/lib';
77import { kDefaultValidator } from 'lib/validators';
@@ -124,6 +124,8 @@ export default function Input({
124124 onPass,
125125 onError,
126126 onFocus,
127+ onEnter,
128+ accessory,
127129 disabled = false,
128130 mono = false,
129131 autoFocus = false,
@@ -137,6 +139,12 @@ export default function Input({
137139 autoFocus: actuallyAutoFocus,
138140 });
139141
142+ // notify parent of enter keypress iff not disabled
143+ const onKeyPress = useCallback(
144+ e => !disabled && e.key === 'Enter' && onEnter && onEnter(),
145+ [disabled, onEnter]
146+ );
147+
140148 // notify parent of value only when passing
141149 useEffect(() => {
142150 pass && onValue && onValue(data);
@@ -158,15 +166,15 @@ export default function Input({
158166 }, [focused, onFocus]);
159167
160168 return (
161− <Grid>
162− <Grid.Item full>
163− <label className="f6 lh-tall" htmlFor={name}>
164− {label}
165− </label>
166− </Grid.Item>
167− <Grid.Item full>
168− <input
169+ <Flex col>
170+ <Flex.Item as="label" className="f6 lh-tall" htmlFor={name}>
171+ {label}
172+ </Flex.Item>
173+ <Flex row>
174+ <Flex.Item
175+ as="input"
169176 {...rest}
177+ cols={[1, accessory ? 11 : 13]}
170178 className={cn(
171179 'b b1 p3',
172180 { mono },
@@ -189,12 +197,18 @@ export default function Input({
189197 style={{
190198 ...(disabled && { pointerEvents: 'none', cursor: 'not-allowed' }),
191199 }}
200+ onKeyPress={onKeyPress}
192201 id={name}
193− name={name}
194202 autoFocus={actuallyAutoFocus}
195203 {...bind}
204+ flex
196205 />
197− </Grid.Item>
198− </Grid>
206+ {accessory && (
207+ <Flex.Item style={{ height: '45px', overflow: 'hidden' }}>
208+ {accessory}
209+ </Flex.Item>
210+ )}
211+ </Flex>
212+ </Flex>
199213 );
200214}