1import React, { useCallback } from 'react';
2import cn from 'classnames';
4import Flex from './Flex';
5import { ErrorText } from './Typography';
7export default React.memo(function Input({
38 // NB(shrugs): we disable exhaustive deps because we don't want the callbacks
39 // (whose identity might change between renders) to trigger a re-notify of
40 // state that we already know
41 // this also happens to prevent render loops when rendering a map of inputs
43 // notify parent of enter keypress iff not disabled and passing
44 const onKeyPress = useCallback(
45 e => !disabled && pass && e.key === 'Enter' && onEnter && onEnter(),
46 [disabled, pass] // eslint-disable-line react-hooks/exhaustive-deps
51 className={cn(className, 'mb1')}
55 pointerEvents: 'none',
56 cursor: 'not-allowed',
61 className={cn('f6 lh-tall', {
68 <Flex.Item as={Flex} className="rel" row>
73 'b b1 p3 outline-none',
76 'bg-white': !disabled,
84 'b-green3': visiblyPassed,
85 'b-black': focused && !visiblyPassed,
86 'b-yellow3': !focused && hintError,
87 'b-gray2': !focused && !hintError && !visiblyPassed,
89 // TODO: inputClassName ?
93 onKeyPress={onKeyPress}
112 <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