1import React from 'react';
2import cn from 'classnames';
3import { useField } from 'react-final-form';
5import Flex from './Flex';
6import { ErrorText } from './Typography';
8export default function Input({
30 meta: { active, error, submitting, touched, valid },
31 } = useField(name, config);
33 disabled = disabled || submitting;
35 // notify parent of enter keypress iff not disabled and passing
36 // TODO: integrate this into react-final-form submission
37 // const onKeyPress = useCallback(
38 // e => !disabled && valid && e.key === 'Enter' && onEnter && onEnter(),
39 // [disabled, valid] // eslint-disable-line react-hooks/exhaustive-deps
45 className={cn(className, 'mb1')}
48 pointerEvents: 'none',
49 cursor: 'not-allowed',
54 className={cn('f6 lh-tall', {
61 <Flex.Item as={Flex} row className="rel">
64 as={type === 'textarea' ? 'textarea' : 'input'}
66 // NOTE: 24px = 12px * 2 (from p3 styling)
67 style={type === 'textarea' ? { minHeight: 'calc(1rem + 24px)' } : {}}
69 'b b1 p3 outline-none',
72 'bg-white': !disabled,
76 gray4: !(active || touched),
77 black: active || touched,
81 'b-black': !valid && active,
82 'b-yellow3': !valid && !active && touched,
83 'b-gray2': !valid && !active && !touched,
89 type={type === 'textarea' ? undefined : type}
107 <Flex.Item as={ErrorText} className="mv1">
112 {touched && !active && error && (
113 <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