forked from aws/agentcore-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWizardSelect.tsx
More file actions
91 lines (86 loc) · 2.28 KB
/
Copy pathWizardSelect.tsx
File metadata and controls
91 lines (86 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { MultiSelectList } from './MultiSelectList';
import { SelectList, type SelectableItem } from './SelectList';
import { Box, Text } from 'ink';
interface WizardSelectBaseProps {
/** Bold title displayed above the list */
title: string;
/** Optional dimmed description below the title */
description?: string;
/** Items to display */
items: SelectableItem[];
/** Message to show when items is empty */
emptyMessage?: string;
}
interface WizardSelectProps extends WizardSelectBaseProps {
/** Current selected index */
selectedIndex: number;
}
interface WizardMultiSelectProps extends WizardSelectBaseProps {
/** Current cursor index */
cursorIndex: number;
/** Currently selected item IDs */
selectedIds: Set<string>;
}
/**
* Styled single-select list for wizard steps.
* Combines title, description, and SelectList.
*
* @example
* ```tsx
* <WizardSelect
* title="Select identity type"
* description="Choose the type of credential provider"
* items={typeItems}
* selectedIndex={typeNav.selectedIndex}
* />
* ```
*/
export function WizardSelect({ title, description, items, selectedIndex, emptyMessage }: WizardSelectProps) {
return (
<Box flexDirection="column">
<Text bold>{title}</Text>
{description && <Text dimColor>{description}</Text>}
<Box marginTop={1}>
<SelectList items={items} selectedIndex={selectedIndex} emptyMessage={emptyMessage} />
</Box>
</Box>
);
}
/**
* Styled multi-select list for wizard steps.
* Combines title, description, and MultiSelectList.
*
* @example
* ```tsx
* <WizardMultiSelect
* title="Select agents to grant access"
* description="These agents can use the credentials"
* items={agentItems}
* cursorIndex={nav.cursorIndex}
* selectedIds={nav.selectedIds}
* />
* ```
*/
export function WizardMultiSelect({
title,
description,
items,
cursorIndex,
selectedIds,
emptyMessage,
}: WizardMultiSelectProps) {
return (
<Box flexDirection="column">
<Text bold>{title}</Text>
{description && <Text dimColor>{description}</Text>}
<Box marginTop={1}>
<MultiSelectList
items={items}
selectedIndex={cursorIndex}
selectedIds={selectedIds}
emptyMessage={emptyMessage}
/>
</Box>
</Box>
);
}