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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Selection item trait for generic selection widgets
//!
//! This module defines the `SelectionItem` trait used by RadioGroup, SegmentedControl,
//! TabBar, and SidebarNav widgets. It also provides `StringItem` as a simple default
//! implementation for string-based selections.
//!
//! # Example: Custom Selection Type
//!
//! ```ignore
//! use ccf_gpui_widgets::widgets::SelectionItem;
//! use gpui::*;
//!
//! #[derive(Clone, PartialEq)]
//! enum Size {
//! Small,
//! Medium,
//! Large,
//! }
//!
//! impl SelectionItem for Size {
//! fn label(&self) -> SharedString {
//! match self {
//! Size::Small => "Small".into(),
//! Size::Medium => "Medium".into(),
//! Size::Large => "Large".into(),
//! }
//! }
//!
//! fn id(&self) -> ElementId {
//! match self {
//! Size::Small => "size_small".into(),
//! Size::Medium => "size_medium".into(),
//! Size::Large => "size_large".into(),
//! }
//! }
//! }
//! ```
use ;
/// Trait for items that can be displayed in selection widgets
///
/// Implement this trait to use custom types with RadioGroup, SegmentedControl,
/// TabBar, and SidebarNav widgets.
///
/// # Required Methods
///
/// - `label()`: Display text for the item
/// - `id()`: Unique element ID for the item (used for click handling and GPUI rendering)
/// A simple string-based selection item
///
/// Use this type for simple string selections without defining a custom enum.
/// The label and id are both derived from the string value.
///
/// # Example
///
/// ```ignore
/// use ccf_gpui_widgets::widgets::{RadioGroup, StringItem};
///
/// let radio = cx.new(|cx| {
/// RadioGroup::new(
/// vec![
/// StringItem::new("small"),
/// StringItem::new("medium"),
/// StringItem::new("large"),
/// ],
/// StringItem::new("medium"),
/// cx,
/// )
/// });
/// ```