1
- import { RadioGroup , RadioItem , Stack , Text } from 'braid-design-system' ;
1
+ import {
2
+ Dropdown ,
3
+ RadioGroup ,
4
+ RadioItem ,
5
+ Stack ,
6
+ Text ,
7
+ } from 'braid-design-system' ;
2
8
import React from 'react' ;
3
9
4
10
import { componentId } from './componentId' ;
@@ -18,7 +24,9 @@ const SingleSelect = ({
18
24
id,
19
25
title,
20
26
} : SingleSelectProps ) => {
21
- const onChange = ( event : React . FormEvent < HTMLInputElement > ) => {
27
+ const onChange = (
28
+ event : React . FormEvent < HTMLInputElement | HTMLSelectElement > ,
29
+ ) => {
22
30
setValue ( event . currentTarget . value ) ;
23
31
} ;
24
32
@@ -28,16 +36,29 @@ const SingleSelect = ({
28
36
{ title }
29
37
</ Text >
30
38
31
- < RadioGroup
32
- aria-labelledby = { componentId ( 'single-select-label' , id ) }
33
- id = { componentId ( 'single-select' , id ) }
34
- onChange = { onChange }
35
- value = { value }
36
- >
37
- { choices . map ( ( choice ) => (
38
- < RadioItem key = { choice } label = { choice } value = { choice } />
39
- ) ) }
40
- </ RadioGroup >
39
+ { choices . length > 5 ? (
40
+ < Dropdown
41
+ aria-labelledby = { componentId ( 'single-select-label' , id ) }
42
+ id = { componentId ( 'single-select' , id ) }
43
+ onChange = { onChange }
44
+ value = { value }
45
+ >
46
+ { choices . map ( ( choice ) => (
47
+ < option key = { choice } > { choice } </ option >
48
+ ) ) }
49
+ </ Dropdown >
50
+ ) : (
51
+ < RadioGroup
52
+ aria-labelledby = { componentId ( 'single-select-label' , id ) }
53
+ id = { componentId ( 'single-select' , id ) }
54
+ onChange = { onChange }
55
+ value = { value }
56
+ >
57
+ { choices . map ( ( choice ) => (
58
+ < RadioItem key = { choice } label = { choice } value = { choice } />
59
+ ) ) }
60
+ </ RadioGroup >
61
+ ) }
41
62
</ Stack >
42
63
) ;
43
64
} ;
0 commit comments