@@ -9,21 +9,20 @@ interface SelectTriggerProps extends ChakraSelect.ControlProps {
9
9
clearable ?: boolean ;
10
10
}
11
11
12
- export const SelectTrigger = React . forwardRef < HTMLButtonElement , SelectTriggerProps > ( function SelectTrigger (
13
- props ,
14
- ref
15
- ) {
16
- const { children, clearable, ...rest } = props ;
17
- return (
18
- < ChakraSelect . Control { ...rest } >
19
- < ChakraSelect . Trigger ref = { ref } > { children } </ ChakraSelect . Trigger >
20
- < ChakraSelect . IndicatorGroup >
21
- { clearable && < SelectClearTrigger /> }
22
- < ChakraSelect . Indicator />
23
- </ ChakraSelect . IndicatorGroup >
24
- </ ChakraSelect . Control >
25
- ) ;
26
- } ) ;
12
+ export const SelectTrigger = React . forwardRef < HTMLButtonElement , SelectTriggerProps > (
13
+ function SelectTrigger ( props , ref ) {
14
+ const { children, clearable, ...rest } = props ;
15
+ return (
16
+ < ChakraSelect . Control { ...rest } >
17
+ < ChakraSelect . Trigger ref = { ref } > { children } </ ChakraSelect . Trigger >
18
+ < ChakraSelect . IndicatorGroup >
19
+ { clearable && < SelectClearTrigger /> }
20
+ < ChakraSelect . Indicator />
21
+ </ ChakraSelect . IndicatorGroup >
22
+ </ ChakraSelect . Control >
23
+ ) ;
24
+ } ,
25
+ ) ;
27
26
28
27
const SelectClearTrigger = React . forwardRef < HTMLButtonElement , ChakraSelect . ClearTriggerProps > (
29
28
function SelectClearTrigger ( props , ref ) {
@@ -32,7 +31,7 @@ const SelectClearTrigger = React.forwardRef<HTMLButtonElement, ChakraSelect.Clea
32
31
< CloseButton size = 'xs' variant = 'plain' focusVisibleRing = 'inside' focusRingWidth = '2px' pointerEvents = 'auto' />
33
32
</ ChakraSelect . ClearTrigger >
34
33
) ;
35
- }
34
+ } ,
36
35
) ;
37
36
38
37
interface SelectContentProps extends ChakraSelect . ContentProps {
@@ -65,31 +64,30 @@ interface SelectValueTextProps extends Omit<ChakraSelect.ValueTextProps, 'childr
65
64
children ?( items : CollectionItem [ ] ) : React . ReactNode ;
66
65
}
67
66
68
- export const SelectValueText = React . forwardRef < HTMLSpanElement , SelectValueTextProps > ( function SelectValueText (
69
- props ,
70
- ref
71
- ) {
72
- const { children, ...rest } = props ;
73
- return (
74
- < ChakraSelect . ValueText { ...rest } ref = { ref } >
75
- < ChakraSelect . Context >
76
- { ( select ) => {
77
- const items = select . selectedItems ;
78
- if ( items . length === 0 ) {
79
- return props . placeholder ;
80
- }
81
- if ( children ) {
82
- return children ( items ) ;
83
- }
84
- if ( items . length === 1 ) {
85
- return select . collection . stringifyItem ( items [ 0 ] ) ;
86
- }
87
- return `${ items . length } selected` ;
88
- } }
89
- </ ChakraSelect . Context >
90
- </ ChakraSelect . ValueText >
91
- ) ;
92
- } ) ;
67
+ export const SelectValueText = React . forwardRef < HTMLSpanElement , SelectValueTextProps > (
68
+ function SelectValueText ( props , ref ) {
69
+ const { children, ...rest } = props ;
70
+ return (
71
+ < ChakraSelect . ValueText { ...rest } ref = { ref } >
72
+ < ChakraSelect . Context >
73
+ { ( select ) => {
74
+ const items = select . selectedItems ;
75
+ if ( items . length === 0 ) {
76
+ return props . placeholder ;
77
+ }
78
+ if ( children ) {
79
+ return children ( items ) ;
80
+ }
81
+ if ( items . length === 1 ) {
82
+ return select . collection . stringifyItem ( items [ 0 ] ) ;
83
+ }
84
+ return `${ items . length } selected` ;
85
+ } }
86
+ </ ChakraSelect . Context >
87
+ </ ChakraSelect . ValueText >
88
+ ) ;
89
+ } ,
90
+ ) ;
93
91
94
92
export const SelectRoot = React . forwardRef < HTMLDivElement , ChakraSelect . RootProps > ( function SelectRoot ( props , ref ) {
95
93
return (
@@ -110,18 +108,17 @@ interface SelectItemGroupProps extends ChakraSelect.ItemGroupProps {
110
108
label : React . ReactNode ;
111
109
}
112
110
113
- export const SelectItemGroup = React . forwardRef < HTMLDivElement , SelectItemGroupProps > ( function SelectItemGroup (
114
- props ,
115
- ref
116
- ) {
117
- const { children, label, ...rest } = props ;
118
- return (
119
- < ChakraSelect . ItemGroup { ...rest } ref = { ref } >
120
- < ChakraSelect . ItemGroupLabel > { label } </ ChakraSelect . ItemGroupLabel >
121
- { children }
122
- </ ChakraSelect . ItemGroup >
123
- ) ;
124
- } ) ;
111
+ export const SelectItemGroup = React . forwardRef < HTMLDivElement , SelectItemGroupProps > (
112
+ function SelectItemGroup ( props , ref ) {
113
+ const { children, label, ...rest } = props ;
114
+ return (
115
+ < ChakraSelect . ItemGroup { ...rest } ref = { ref } >
116
+ < ChakraSelect . ItemGroupLabel > { label } </ ChakraSelect . ItemGroupLabel >
117
+ { children }
118
+ </ ChakraSelect . ItemGroup >
119
+ ) ;
120
+ } ,
121
+ ) ;
125
122
126
123
export const SelectLabel = ChakraSelect . Label ;
127
124
export const SelectItemText = ChakraSelect . ItemText ;
0 commit comments