3
3
useMutableCallback ,
4
4
useResizeObserver ,
5
5
} from '@rocket.chat/fuselage-hooks' ;
6
- import type { SyntheticEvent , ComponentProps , Ref , ElementType } from 'react' ;
7
- import React , { useState , useRef , forwardRef , useMemo , useEffect } from 'react' ;
6
+ import type { SyntheticEvent , ElementType } from 'react' ;
7
+ import React , { useState , useRef , useMemo , useEffect } from 'react' ;
8
8
9
9
import type { SelectProps } from '..' ;
10
10
import AnimatedVisibility from '../AnimatedVisibility' ;
@@ -13,6 +13,9 @@ import { Icon } from '../Icon';
13
13
import { useVisible } from '../Options/useVisible' ;
14
14
import { OptionsPaginated } from '../OptionsPaginated' ;
15
15
import PositionAnimated from '../PositionAnimated' ;
16
+ import PaginatedSelectAddon from './PaginatedSelectAddon' ;
17
+ import PaginatedSelectFocus from './PaginatedSelectFocus' ;
18
+ import PaginatedSelectWrapper from './PaginatedSelectWrapper' ;
16
19
17
20
type PaginatedOptionType = {
18
21
value : string | number ;
@@ -23,35 +26,9 @@ export type PaginatedSelectProps = Omit<SelectProps, 'options'> & {
23
26
options : PaginatedOptionType [ ] ;
24
27
withTitle ?: boolean ;
25
28
endReached : ( index : number ) => void ;
26
- setFilter : ( value : string | undefined | number ) => void ;
29
+ setFilter ? : ( value : string | undefined | number ) => void ;
27
30
} ;
28
31
29
- type AddonProps = ComponentProps < typeof Box > ;
30
-
31
- const Addon = forwardRef ( ( props : AddonProps , ref : Ref < HTMLDivElement > ) => (
32
- < Box is = 'div' rcx-select__addon ref = { ref } { ...props } />
33
- ) ) ;
34
-
35
- type WrapperProps = ComponentProps < typeof Box > ;
36
-
37
- const Wrapper = forwardRef ( ( props : WrapperProps , ref : Ref < HTMLDivElement > ) => (
38
- < Box is = 'div' rcx-select__wrapper ref = { ref } { ...props } />
39
- ) ) ;
40
-
41
- type FocusProps = ComponentProps < typeof Box > ;
42
-
43
- const Focus = forwardRef ( ( props : FocusProps , ref : Ref < HTMLButtonElement > ) => (
44
- < Box
45
- ref = { ref }
46
- fontScale = 'p2m'
47
- color = 'hint'
48
- rcx-select__focus
49
- is = 'button'
50
- type = 'button'
51
- { ...props }
52
- />
53
- ) ) ;
54
-
55
32
const prevent = ( e : SyntheticEvent ) => {
56
33
e . preventDefault ( ) ;
57
34
e . stopPropagation ( ) ;
@@ -78,7 +55,7 @@ export const PaginatedSelect = ({
78
55
error,
79
56
disabled,
80
57
options = [ ] ,
81
- anchor : Anchor = Focus ,
58
+ anchor : Anchor = PaginatedSelectFocus ,
82
59
onChange = ( ) => { } ,
83
60
placeholder = '' ,
84
61
renderOptions : _Options = OptionsPaginated ,
@@ -133,7 +110,7 @@ export const PaginatedSelect = ({
133
110
) }
134
111
{ ...props }
135
112
>
136
- < Wrapper
113
+ < PaginatedSelectWrapper
137
114
display = 'flex'
138
115
mi = 'neg-x4'
139
116
rcx-select__wrapper--hidden = { ! ! visibleText }
@@ -159,20 +136,15 @@ export const PaginatedSelect = ({
159
136
onClick = { show }
160
137
onBlur = { hide }
161
138
/>
162
- < Addon
163
- mi = 'x4'
164
- children = {
165
- < Icon
166
- name = {
167
- visible === AnimatedVisibility . VISIBLE
168
- ? 'cross'
169
- : 'chevron-down'
170
- }
171
- size = 'x20'
172
- />
173
- }
174
- />
175
- </ Wrapper >
139
+ < PaginatedSelectAddon mi = 'x4' >
140
+ < Icon
141
+ name = {
142
+ visible === AnimatedVisibility . VISIBLE ? 'cross' : 'chevron-down'
143
+ }
144
+ size = 'x20'
145
+ />
146
+ </ PaginatedSelectAddon >
147
+ </ PaginatedSelectWrapper >
176
148
< PositionAnimated visible = { visible } anchor = { containerRef } >
177
149
< _Options
178
150
{ ...( withTitle && { title : withTitle } ) }
0 commit comments