mirror of
https://github.com/openai/codex.git
synced 2026-04-30 17:36:40 +00:00
17
codex-cli/src/components/vendor/ink-select/use-select.js
vendored
Normal file
17
codex-cli/src/components/vendor/ink-select/use-select.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
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 },
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user