@@ -17,7 +17,7 @@ export default {
1717 decorators : [ paperDecorator , muiDecorator ] ,
1818} ;
1919
20- export const Default = ( ) : React . Node => {
20+ export const MultiSelect = ( ) : React . Node => {
2121 const [ value , setValue ] = React . useState < boolean > ( false ) ;
2222 const [ value1 , setValue1 ] = React . useState < boolean > ( true ) ;
2323 const [ value2 , setValue2 ] = React . useState < boolean > ( false ) ;
@@ -150,3 +150,111 @@ export const Default = (): React.Node => {
150150 </ ElementHighlighterProvider >
151151 ) ;
152152} ;
153+
154+ /**
155+ * Preferred usage pattern: exclusive selection (radio-like).
156+ * Only one option can be active at a time, and clicking the active option
157+ * does not deselect it. This prevents the component from acting as an on/off
158+ * toggle on a single element, which goes against standardized UI patterns
159+ * for segmented controls.
160+ */
161+ export const ExclusiveSelection = ( ) : React . Node => {
162+ const [ selectedTwo , setSelectedTwo ] = React . useState < string > ( 'button1' ) ;
163+ const [ selectedThree , setSelectedThree ] = React . useState < string > ( 'button1' ) ;
164+ return (
165+ < ElementHighlighterProvider
166+ elements = { [
167+ { label : '2 items exclusive' , id : 'two-items-exclusive' } ,
168+ { label : '3 items exclusive' , id : 'three-items-exclusive' } ,
169+ {
170+ label : '3 items exclusive, no separator' ,
171+ id : 'three-items-exclusive-no-sep' ,
172+ } ,
173+ ] }
174+ >
175+ < ColumnStackLayout expand >
176+ < Text size = "sub-title" > Two items (exclusive)</ Text >
177+ < CompactToggleButtons
178+ expand
179+ id = "two-items-exclusive"
180+ buttons = { [
181+ {
182+ id : 'button1' ,
183+ renderIcon : className => < Layers className = { className } /> ,
184+ tooltip : 'Layer 1' ,
185+ onClick : ( ) => setSelectedTwo ( 'button1' ) ,
186+ isActive : selectedTwo === 'button1' ,
187+ } ,
188+ {
189+ id : 'button2' ,
190+ renderIcon : className => < Layers className = { className } /> ,
191+ tooltip : 'Layer 2' ,
192+ onClick : ( ) => setSelectedTwo ( 'button2' ) ,
193+ isActive : selectedTwo === 'button2' ,
194+ } ,
195+ ] }
196+ />
197+ < Text size = "sub-title" > Three items (exclusive)</ Text >
198+ < CompactToggleButtons
199+ expand
200+ id = "three-items-exclusive"
201+ buttons = { [
202+ {
203+ id : 'button1' ,
204+ renderIcon : className => < Layers className = { className } /> ,
205+ tooltip : 'Layer 1' ,
206+ onClick : ( ) => setSelectedThree ( 'button1' ) ,
207+ isActive : selectedThree === 'button1' ,
208+ } ,
209+ {
210+ id : 'button2' ,
211+ renderIcon : className => < Layers className = { className } /> ,
212+ tooltip : 'Layer 2' ,
213+ onClick : ( ) => setSelectedThree ( 'button2' ) ,
214+ isActive : selectedThree === 'button2' ,
215+ } ,
216+ {
217+ id : 'button3' ,
218+ renderIcon : className => < Layers className = { className } /> ,
219+ tooltip : 'Layer 3' ,
220+ onClick : ( ) => setSelectedThree ( 'button3' ) ,
221+ isActive : selectedThree === 'button3' ,
222+ } ,
223+ ] }
224+ />
225+ < Text size = "sub-title" >
226+ Three items, exclusive, not expanded and no separators
227+ </ Text >
228+ < Line expand noMargin >
229+ < CompactToggleButtons
230+ noSeparator
231+ id = "three-items-exclusive-no-sep"
232+ buttons = { [
233+ {
234+ id : 'button1' ,
235+ renderIcon : className => < Layers className = { className } /> ,
236+ tooltip : 'Layer 1' ,
237+ onClick : ( ) => setSelectedThree ( 'button1' ) ,
238+ isActive : selectedThree === 'button1' ,
239+ } ,
240+ {
241+ id : 'button2' ,
242+ renderIcon : className => < Layers className = { className } /> ,
243+ tooltip : 'Layer 2' ,
244+ onClick : ( ) => setSelectedThree ( 'button2' ) ,
245+ isActive : selectedThree === 'button2' ,
246+ } ,
247+ {
248+ id : 'button3' ,
249+ renderIcon : className => < Layers className = { className } /> ,
250+ tooltip : 'Layer 3' ,
251+ onClick : ( ) => setSelectedThree ( 'button3' ) ,
252+ isActive : selectedThree === 'button3' ,
253+ } ,
254+ ] }
255+ />
256+ </ Line >
257+ </ ColumnStackLayout >
258+ </ ElementHighlighterProvider >
259+ ) ;
260+ } ;
0 commit comments