mirror of
https://github.com/openai/codex.git
synced 2026-04-28 02:11:08 +03:00
18 lines
382 B
JavaScript
18 lines
382 B
JavaScript
import { useInput } from "ink";
|
|
export const useSelect = ({ isDisabled = false, state }) => {
|
|
useInput(
|
|
(_input, key) => {
|
|
if (key.downArrow) {
|
|
state.focusNextOption();
|
|
}
|
|
if (key.upArrow) {
|
|
state.focusPreviousOption();
|
|
}
|
|
if (key.return) {
|
|
state.selectFocusedOption();
|
|
}
|
|
},
|
|
{ isActive: !isDisabled },
|
|
);
|
|
};
|