| |
| |
| |
| |
| |
|
|
| import type React from 'react'; |
| import { Box, Text } from 'ink'; |
| import type { LoadableSettingScope } from '../../../config/settings.js'; |
| import { getScopeItems } from '../../../utils/dialogScopeUtils.js'; |
| import { RadioButtonSelect } from './RadioButtonSelect.js'; |
|
|
| interface ScopeSelectorProps { |
| |
| onSelect: (scope: LoadableSettingScope) => void; |
| |
| onHighlight: (scope: LoadableSettingScope) => void; |
| |
| isFocused: boolean; |
| |
| initialScope: LoadableSettingScope; |
| } |
|
|
| export function ScopeSelector({ |
| onSelect, |
| onHighlight, |
| isFocused, |
| initialScope, |
| }: ScopeSelectorProps): React.JSX.Element { |
| const scopeItems = getScopeItems().map((item) => ({ |
| ...item, |
| key: item.value, |
| })); |
|
|
| const initialIndex = scopeItems.findIndex( |
| (item) => item.value === initialScope, |
| ); |
| const safeInitialIndex = initialIndex >= 0 ? initialIndex : 0; |
|
|
| return ( |
| <Box flexDirection="column"> |
| <Text bold={isFocused} wrap="truncate"> |
| {isFocused ? '> ' : ' '}Apply To |
| </Text> |
| <RadioButtonSelect |
| items={scopeItems} |
| initialIndex={safeInitialIndex} |
| onSelect={onSelect} |
| onHighlight={onHighlight} |
| isFocused={isFocused} |
| showNumbers={isFocused} |
| /> |
| </Box> |
| ); |
| } |
|
|