1import React, { useCallback } from 'react';
2import cn from 'classnames';
4import Flex from './Flex';
5import { ErrorText } from './Typography';
6import { useField } from 'react-final-form';
8export default function Input({
45 } = useField(name, config);
47 disabled = disabled || submitting;
49 // notify parent of enter keypress iff not disabled and passing
50 const onKeyPress = useCallback(
51 e => !disabled && valid && e.key === 'Enter' && onEnter && onEnter(),
52 [disabled, valid] // eslint-disable-line react-hooks/exhaustive-deps
58 className={cn(className, 'mb1')}
61 pointerEvents: 'none',
62 cursor: 'not-allowed',
67 className={cn('f6 lh-tall', {
74 <Flex.Item as={Flex} row className="rel">
77 as={type === 'textarea' ? 'textarea' : 'input'}
78 type={type === 'textarea' ? undefined : type}
80 // NOTE: 24px = 12px * 2 (from p3 styling)
81 style={type === 'textarea' ? { minHeight: 'calc(1rem + 24px)' } : {}}
83 'b b1 p3 outline-none',
86 'bg-white': !disabled,
90 gray4: !(active || touched),
91 black: active || touched,
95 'b-black': !valid && active,
96 'b-yellow3': !valid && !active && touched && error,
97 'b-gray2': !valid && !active && !touched && !error,
102 onKeyPress={onKeyPress}
119 {touched && error && (
120 <Flex.Item as={ErrorText} className="mv1">
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list