1import React, { useCallback, useEffect } from 'react';
2import cn from 'classnames';
4import Flex from './Flex';
5import { ErrorText } from './Typography';
7export default function Input({
37 // NB(shrugs): we disable exhaustive deps because we don't want the callbacks
38 // (whose identity might change between renders) to trigger a re-notify of
39 // state that we already know
40 // this also happens to prevent render loops when rendering a map of inputs
42 // notify parent of enter keypress iff not disabled and passing
43 const onKeyPress = useCallback(
44 e => !disabled && pass && e.key === 'Enter' && onEnter && onEnter(),
45 [disabled, pass] // eslint-disable-line react-hooks/exhaustive-deps
48 // notify parent of value only when passing
49 // TODO: deprecate/remove this
50 // keeping it around for now to avoid refactoring InviteEmail.js, but this
53 pass && onValue && onValue(data);
54 }, [pass, data]); // eslint-disable-line react-hooks/exhaustive-deps
58 className={cn(className, 'mb1')}
62 pointerEvents: 'none',
63 cursor: 'not-allowed',
66 <Flex.Item as="label" className="f6 lh-tall" htmlFor={name}>
69 <Flex.Item as={Flex} className="rel" row>
74 'b b1 p3 outline-none',
77 'bg-white': !disabled,
85 'b-green3': visiblyPassed,
86 'b-black': focused && !visiblyPassed,
87 'b-yellow3': !focused && error,
88 'b-gray3': !focused && !error && !visiblyPassed,
90 // TODO: inputClassName ?
94 onKeyPress={onKeyPress}
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