1import React from 'react';
2import cn from 'classnames';
3import { useField } from 'react-final-form';
4import Flex from './Flex';
5import { ErrorText } from './Typography';
7export default function Input({
30 meta: { active, error, submitting, touched, valid },
31 } = useField(name, config);
33 disabled = disabled || submitting;
35 // choose the base dom component
36 const BaseComponent = type === 'textarea' ? 'textarea' : 'input';
38 // notify parent of enter keypress iff not disabled and passing
39 // TODO: integrate this into react-final-form submission
40 // const onKeyPress = useCallback(
41 // e => !disabled && valid && e.key === 'Enter' && onEnter && onEnter(),
42 // [disabled, valid] // eslint-disable-line react-hooks/exhaustive-deps
45 // console.log(input);
50 className={cn(className, 'mb1')}
53 pointerEvents: 'none',
54 cursor: 'not-allowed',
59 className={cn('f6 lh-tall', {
66 <Flex.Item as={Flex} row className="rel">
71 // NOTE: 24px = 12px * 2 (from p3 styling)
72 style={type === 'textarea' ? { minHeight: 'calc(1rem + 24px)' } : {}}
74 'b b1 p3 outline-none',
77 'bg-white': !disabled,
81 gray4: !(active || touched),
82 black: active || touched,
86 'b-black': !valid && active,
87 'b-yellow3': !valid && !active && touched,
88 'b-gray2': !valid && !active && !touched,
94 type={type === 'textarea' ? undefined : type}
112 <Flex.Item as={ErrorText} className="mv1">
117 {touched && !active && error && (
118 <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