1
- import { FC } from 'react' ;
1
+ import { FC , ReactNode } from 'react' ;
2
2
3
3
import {
4
+ Box ,
4
5
Button ,
5
6
ButtonProps ,
6
7
Menu ,
@@ -31,8 +32,8 @@ type CustomProps = {
31
32
size ?: 'xs' | 'sm' | 'md' ;
32
33
options ?: Array < OptionProps > ;
33
34
onChange ?( sort : SortValue ) : void ;
34
- ascIcon ?: FC < React . PropsWithChildren < unknown > > ;
35
- descIcon ?: FC < React . PropsWithChildren < unknown > > ;
35
+ ascIcon ?: ReactNode ;
36
+ descIcon ?: ReactNode ;
36
37
} ;
37
38
38
39
type SortProps = Overwrite < ButtonProps , CustomProps > ;
@@ -42,16 +43,14 @@ export const Sort: FC<React.PropsWithChildren<SortProps>> = ({
42
43
size = 'xs' ,
43
44
options = [ ] ,
44
45
onChange = ( ) => undefined ,
45
- ascIcon : AscIcon = IconSortAsc ,
46
- descIcon : DescIcon = IconSortDesc ,
46
+ ascIcon = < IconSortAsc /> ,
47
+ descIcon = < IconSortDesc /> ,
47
48
...rest
48
49
} ) => {
49
50
const { t } = useTranslation ( ) ;
50
51
51
52
const { by, order } = sort ;
52
53
53
- const Icon = order === 'asc' ? AscIcon : DescIcon ;
54
-
55
54
const handleByChange = ( value : SortValue [ 'by' ] ) => {
56
55
onChange ( { ...sort , by : value } ) ;
57
56
} ;
@@ -74,11 +73,19 @@ export const Sort: FC<React.PropsWithChildren<SortProps>> = ({
74
73
_dark = { {
75
74
color : 'gray.100' ,
76
75
} }
77
- sx = { { '> span' : { d : 'flex' , maxW : 'full' } } }
76
+ sx = { { '> span' : { display : 'flex' , maxW : 'full' } } }
78
77
{ ...rest }
79
78
>
80
- < Icon mr = "0.5" />
81
- < Text as = "span" display = "block" fontSize = { size } noOfLines = { 1 } >
79
+ < Box as = "span" mr = "0.5" >
80
+ { order === 'asc' ? ascIcon : descIcon }
81
+ </ Box >
82
+ < Text
83
+ as = "span"
84
+ display = "block"
85
+ sx = { { '&' : { display : 'block !important' } } } // Fix: text-ellipsis issue
86
+ fontSize = { size }
87
+ noOfLines = { 1 }
88
+ >
82
89
{ options . find ( ( option ) => option ?. value === by ) ?. label }
83
90
</ Text >
84
91
</ MenuButton >
0 commit comments