1
- import * as SelectPrimitive from "@radix -ui/react- select" ;
1
+ import { Select as SelectPrimitive } from "@base -ui-components /react/ select" ;
2
2
import { CheckIcon , ChevronDownIcon , ChevronUpIcon } from "lucide-react" ;
3
- import { forwardRef } from "react" ;
3
+
4
4
import { cn } from "../../lib/utils.js" ;
5
5
6
- const Root = ( {
6
+ const Root = < TValue , > ( {
7
7
children,
8
8
placeholder,
9
9
...props
10
- } : React . ComponentPropsWithoutRef < typeof SelectPrimitive . Root > & {
10
+ } : SelectPrimitive . Root . Props < TValue > & {
11
11
placeholder ?: string ;
12
12
} ) => (
13
13
< SelectPrimitive . Root { ...props } >
14
14
< Trigger >
15
15
< Value placeholder = { placeholder } />
16
16
</ Trigger >
17
- < Content className = "text-gray-dark" > { children } </ Content >
17
+ < Positioner className = "text-gray-dark" > { children } </ Positioner >
18
18
</ SelectPrimitive . Root >
19
19
) ;
20
- Root . displayName = SelectPrimitive . Root . displayName ;
21
20
22
21
const Group = SelectPrimitive . Group ;
23
22
24
23
const Value = SelectPrimitive . Value ;
25
24
26
- const Trigger = forwardRef <
27
- React . ComponentRef < typeof SelectPrimitive . Trigger > ,
28
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . Trigger >
29
- > ( ( { className, children, ...props } , ref ) => (
25
+ const Trigger = ( {
26
+ className,
27
+ children,
28
+ ...props
29
+ } : SelectPrimitive . Trigger . Props ) => (
30
30
< SelectPrimitive . Trigger
31
- ref = { ref }
32
31
className = { cn (
33
32
`
34
33
flex
@@ -53,91 +52,83 @@ const Trigger = forwardRef<
53
52
{ ...props }
54
53
>
55
54
{ children }
56
- < SelectPrimitive . Icon asChild >
55
+ < SelectPrimitive . Icon >
57
56
< ChevronDownIcon className = "size-4 opacity-50" />
58
57
</ SelectPrimitive . Icon >
59
58
</ SelectPrimitive . Trigger >
60
- ) ) ;
61
- Trigger . displayName = SelectPrimitive . Trigger . displayName ;
59
+ ) ;
62
60
63
- const ScrollUpButton = forwardRef <
64
- React . ComponentRef < typeof SelectPrimitive . ScrollUpButton > ,
65
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . ScrollUpButton >
66
- > ( ( { className, ...props } , ref ) => (
67
- < SelectPrimitive . ScrollUpButton
68
- ref = { ref }
61
+ const ScrollUpArrow = ( {
62
+ className,
63
+ ...props
64
+ } : SelectPrimitive . ScrollUpArrow . Props ) => (
65
+ < SelectPrimitive . ScrollUpArrow
69
66
className = { cn (
70
- "flex cursor-default items-center justify-center py-1" ,
67
+ "absolute top-0 inset-x-0 flex cursor-default items-center justify-center py-1 z-10 " ,
71
68
className ,
72
69
) }
73
70
{ ...props }
74
71
>
75
72
< ChevronUpIcon className = "size-4" />
76
- </ SelectPrimitive . ScrollUpButton >
77
- ) ) ;
78
- ScrollUpButton . displayName = SelectPrimitive . ScrollUpButton . displayName ;
73
+ </ SelectPrimitive . ScrollUpArrow >
74
+ ) ;
79
75
80
- const ScrollDownButton = forwardRef <
81
- React . ComponentRef < typeof SelectPrimitive . ScrollDownButton > ,
82
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . ScrollDownButton >
83
- > ( ( { className, ...props } , ref ) => (
84
- < SelectPrimitive . ScrollDownButton
85
- ref = { ref }
76
+ const ScrollDownArrow = ( {
77
+ className,
78
+ ...props
79
+ } : SelectPrimitive . ScrollDownArrow . Props ) => (
80
+ < SelectPrimitive . ScrollDownArrow
86
81
className = { cn (
87
- "flex cursor-default items-center justify-center py-1" ,
82
+ "absolute bottom-0 inset-x-0 flex cursor-default items-center justify-center py-1" ,
88
83
className ,
89
84
) }
90
85
{ ...props }
91
86
>
92
87
< ChevronDownIcon className = "size-4" />
93
- </ SelectPrimitive . ScrollDownButton >
94
- ) ) ;
95
- ScrollDownButton . displayName = SelectPrimitive . ScrollDownButton . displayName ;
88
+ </ SelectPrimitive . ScrollDownArrow >
89
+ ) ;
96
90
97
- const Content = forwardRef <
98
- React . ComponentRef < typeof SelectPrimitive . Content > ,
99
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . Content >
100
- > ( ( { className, children, ...props } , ref ) => (
91
+ const Positioner = ( {
92
+ className,
93
+ children,
94
+ ...props
95
+ } : SelectPrimitive . Positioner . Props ) => (
101
96
< SelectPrimitive . Portal >
102
- < SelectPrimitive . Content
103
- ref = { ref }
97
+ < SelectPrimitive . Positioner
104
98
className = { cn (
105
- "relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem ] overflow-y-auto overflow-x-hidden rounded-lg border bg-gray-100 text-popover-foreground shadow-md border-gray-300" ,
99
+ "relative z-50 min-w-[calc(var(--anchor-width)+25px-var(--spacing)*1.5) ] overflow-y-auto overflow-x-hidden rounded-lg border bg-gray-100 text-popover-foreground shadow-md border-gray-300" ,
106
100
className ,
107
101
) }
108
102
{ ...props }
109
103
>
110
- < ScrollUpButton />
111
- < SelectPrimitive . Viewport className = { cn ( "p-1.5" ) } >
104
+ < ScrollUpArrow />
105
+ < SelectPrimitive . Popup className = { cn ( "p-1.5" ) } >
112
106
{ children }
113
- </ SelectPrimitive . Viewport >
114
- < ScrollDownButton />
115
- </ SelectPrimitive . Content >
107
+ </ SelectPrimitive . Popup >
108
+ < ScrollDownArrow />
109
+ </ SelectPrimitive . Positioner >
116
110
</ SelectPrimitive . Portal >
117
- ) ) ;
118
- Content . displayName = SelectPrimitive . Content . displayName ;
111
+ ) ;
119
112
120
- const Label = forwardRef <
121
- React . ComponentRef < typeof SelectPrimitive . Label > ,
122
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . Label >
123
- > ( ( { className, ...props } , ref ) => (
124
- < SelectPrimitive . Label
125
- ref = { ref }
113
+ const GroupLabel = ( {
114
+ className,
115
+ ...props
116
+ } : SelectPrimitive . GroupLabel . Props ) => (
117
+ < SelectPrimitive . GroupLabel
126
118
className = { cn (
127
119
"px-[25px] text-sm leading-[25px] font-semibold select-none" ,
128
120
className ,
129
121
) }
130
122
{ ...props }
131
123
/>
132
- ) ) ;
133
- Label . displayName = SelectPrimitive . Label . displayName ;
124
+ ) ;
134
125
135
- const Item = forwardRef <
136
- React . ComponentRef < typeof SelectPrimitive . Item > ,
137
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . Item >
138
- > ( ( { className, children, ...props } , ref ) => (
126
+ const Item = ( {
127
+ className,
128
+ children,
129
+ ...props
130
+ } : SelectPrimitive . Item . Props ) => (
139
131
< SelectPrimitive . Item
140
- ref = { ref }
141
132
className = { cn (
142
133
"relative flex h-7 select-none items-center rounded-sm pl-[25px] pr-[35px] leading-none data-[disabled]:pointer-events-none data-[highlighted]:bg-blue-100 data-[disabled]:opacity-50 data-[highlighted]:text-blue data-[highlighted]:outline-none" ,
143
134
className ,
@@ -149,30 +140,16 @@ const Item = forwardRef<
149
140
< CheckIcon />
150
141
</ SelectPrimitive . ItemIndicator >
151
142
</ SelectPrimitive . Item >
152
- ) ) ;
153
- Item . displayName = SelectPrimitive . Item . displayName ;
143
+ ) ;
154
144
155
- const Separator = forwardRef <
156
- React . ComponentRef < typeof SelectPrimitive . Separator > ,
157
- React . ComponentPropsWithoutRef < typeof SelectPrimitive . Separator >
158
- > ( ( { className , ... props } , ref ) => (
145
+ const Separator = ( {
146
+ className ,
147
+ ... props
148
+ } : SelectPrimitive . Separator . Props ) => (
159
149
< SelectPrimitive . Separator
160
- ref = { ref }
161
150
className = { cn ( "m-[5px] h-px bg-gray-300" , className ) }
162
151
{ ...props }
163
152
/>
164
- ) ) ;
165
- Separator . displayName = SelectPrimitive . Separator . displayName ;
153
+ ) ;
166
154
167
- export {
168
- Root ,
169
- Group ,
170
- Value ,
171
- Trigger ,
172
- Content ,
173
- Label ,
174
- Item ,
175
- Separator ,
176
- ScrollUpButton ,
177
- ScrollDownButton ,
178
- } ;
155
+ export { Root , Group , Value , GroupLabel , Item , Separator } ;
0 commit comments