1import React, { useCallback, useEffect } from 'react';
2import cn from 'classnames';
4import Flex from './Flex';
6export default function Input({
39 // NB(shrugs): we disable exhaustive deps because we don't want the callbacks
40 // (whose identity might change between renders) to trigger a re-notify of
41 // state that we already know
42 // this also happens to prevent render loops when rendering a map of inputs
44 // notify parent of enter keypress iff not disabled
45 const onKeyPress = useCallback(
46 e => !disabled && e.key === 'Enter' && onEnter && onEnter(),
47 [disabled] // eslint-disable-line react-hooks/exhaustive-deps
50 // notify parent of value only when passing
52 pass && onValue && onValue(data);
53 }, [pass, data]); // eslint-disable-line react-hooks/exhaustive-deps
55 // notify parent of pass
57 onPass && onPass(pass);
58 }, [pass]); // eslint-disable-line react-hooks/exhaustive-deps
60 // notify parent of error whenever error changes
62 onError && onError(error);
63 }, [error]); // eslint-disable-line react-hooks/exhaustive-deps
65 // notify parent of focus
67 onFocus && onFocus(focused);
68 }, [focused]); // eslint-disable-line react-hooks/exhaustive-deps
71 <Flex className={className} col>
72 <Flex.Item as="label" className="f6 lh-tall" htmlFor={name}>
79 cols={[1, accessory ? 11 : 13]}
81 'b b1 p3 outline-none',
84 'bg-white': !disabled,
92 'b-green3': visiblyPassed,
93 'b-black': focused && !visiblyPassed,
94 'b-yellow3': !focused && !visiblyPassed && error,
95 'b-gray3': !focused && !error && !visiblyPassed,
97 // TODO: inputClassName ?
101 pointerEvents: 'none',
102 cursor: 'not-allowed',
107 onKeyPress={onKeyPress}
113 style={{ height: '45px', width: '45px', overflow: 'hidden' }}>
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