1
- ' use client' ;
2
- import React from ' react' ;
3
- import { createAccordion } from ' @gluestack-ui/accordion' ;
4
- import { View , Pressable , Text , Platform , TextProps } from ' react-native' ;
5
- import { tva } from ' @gluestack-ui/nativewind-utils/tva' ;
6
- import type { VariantProps } from ' @gluestack-ui/nativewind-utils' ;
1
+ " use client" ;
2
+ import React from " react" ;
3
+ import { createAccordion } from " @gluestack-ui/accordion" ;
4
+ import { View , Pressable , Text , Platform , TextProps } from " react-native" ;
5
+ import { tva } from " @gluestack-ui/nativewind-utils/tva" ;
6
+ import type { VariantProps } from " @gluestack-ui/nativewind-utils" ;
7
7
import {
8
8
withStyleContext ,
9
9
useStyleContext ,
10
- } from ' @gluestack-ui/nativewind-utils/withStyleContext' ;
11
- import { H3 } from ' @expo/html-elements' ;
12
- import { cssInterop } from ' nativewind' ;
13
- import { PrimitiveIcon , UIIcon } from ' @gluestack-ui/icon' ;
10
+ } from " @gluestack-ui/nativewind-utils/withStyleContext" ;
11
+ import { H3 } from " @expo/html-elements" ;
12
+ import { cssInterop } from " nativewind" ;
13
+ import { PrimitiveIcon , UIIcon } from " @gluestack-ui/icon" ;
14
14
15
- const SCOPE = ' ACCORDION' ;
15
+ const SCOPE = " ACCORDION" ;
16
16
/** Styles */
17
17
18
18
const accordionStyle = tva ( {
19
- base : ' w-full' ,
19
+ base : " w-full" ,
20
20
variants : {
21
21
variant : {
22
- filled : ' bg-white shadow-hard-2' ,
23
- unfilled : '' ,
22
+ filled : " bg-white shadow-hard-2" ,
23
+ unfilled : "" ,
24
24
} ,
25
25
size : {
26
- sm : '' ,
27
- md : '' ,
28
- lg : '' ,
26
+ sm : "" ,
27
+ md : "" ,
28
+ lg : "" ,
29
29
} ,
30
30
} ,
31
31
} ) ;
32
32
33
33
const accordionItemStyle = tva ( {
34
- base : '' ,
34
+ base : "" ,
35
35
parentVariants : {
36
36
variant : {
37
- filled : ' bg-background-0' ,
38
- unfilled : ' bg-transparent' ,
37
+ filled : " bg-background-0" ,
38
+ unfilled : " bg-transparent" ,
39
39
} ,
40
40
} ,
41
41
} ) ;
42
42
const accordionTitleTextStyle = tva ( {
43
- base : ' text-typography-900 font-bold flex-1 text-left' ,
43
+ base : " text-typography-900 font-bold flex-1 text-left" ,
44
44
parentVariants : {
45
45
size : {
46
- sm : ' text-sm' ,
47
- md : ' text-base' ,
48
- lg : ' text-lg' ,
46
+ sm : " text-sm" ,
47
+ md : " text-base" ,
48
+ lg : " text-lg" ,
49
49
} ,
50
50
} ,
51
51
} ) ;
52
52
const accordionIconStyle = tva ( {
53
- base : ' text-typography-900 fill-none' ,
53
+ base : " text-typography-900 fill-none" ,
54
54
parentVariants : {
55
55
size : {
56
- ' 2xs' : ' h-3 w-3' ,
57
- 'xs' : ' h-3.5 w-3.5' ,
58
- 'sm' : ' h-4 w-4' ,
59
- 'md' : ' h-[18px] w-[18px]' ,
60
- 'lg' : ' h-5 w-5' ,
61
- 'xl' : ' h-6 w-6' ,
56
+ " 2xs" : " h-3 w-3" ,
57
+ xs : " h-3.5 w-3.5" ,
58
+ sm : " h-4 w-4" ,
59
+ md : " h-[18px] w-[18px]" ,
60
+ lg : " h-5 w-5" ,
61
+ xl : " h-6 w-6" ,
62
62
} ,
63
63
} ,
64
64
} ) ;
65
65
const accordionContentTextStyle = tva ( {
66
- base : ' text-typography-700 font-normal' ,
66
+ base : " text-typography-700 font-normal" ,
67
67
parentVariants : {
68
68
size : {
69
- sm : ' text-sm' ,
70
- md : ' text-base' ,
71
- lg : ' text-lg' ,
69
+ sm : " text-sm" ,
70
+ md : " text-base" ,
71
+ lg : " text-lg" ,
72
72
} ,
73
73
} ,
74
74
} ) ;
75
75
const accordionHeaderStyle = tva ( {
76
- base : ' mx-0 my-0' ,
76
+ base : " mx-0 my-0" ,
77
77
} ) ;
78
78
const accordionContentStyle = tva ( {
79
- base : ' pt-1 pb-3 px-4' ,
79
+ base : " pt-1 pb-3 px-4" ,
80
80
} ) ;
81
81
const accordionTriggerStyle = tva ( {
82
- base : ' w-full flex-row justify-between items-center web:outline-none focus:outline-none data-[disabled=true]:opacity-40 data-[disabled=true]:cursor-not-allowed data-[focus-visible=true]:bg-background-50 py-3 px-4' ,
82
+ base : " w-full flex-row justify-between items-center web:outline-none focus:outline-none data-[disabled=true]:opacity-40 data-[disabled=true]:cursor-not-allowed data-[focus-visible=true]:bg-background-50 py-3 px-4" ,
83
83
} ) ;
84
84
85
85
const Root = withStyleContext ( View , SCOPE ) ;
86
86
87
87
const Header = (
88
- Platform . OS === ' web' ? H3 : View
88
+ Platform . OS === " web" ? H3 : View
89
89
) as React . ComponentType < TextProps > ;
90
90
91
91
/** Creator */
@@ -102,20 +102,20 @@ const UIAccordion = createAccordion({
102
102
103
103
cssInterop ( PrimitiveIcon , {
104
104
className : {
105
- target : ' style' ,
105
+ target : " style" ,
106
106
nativeStyleToProp : {
107
107
height : true ,
108
108
width : true ,
109
109
fill : true ,
110
- color : ' classNameColor' ,
110
+ color : " classNameColor" ,
111
111
stroke : true ,
112
112
} ,
113
113
} ,
114
114
} ) ;
115
115
116
116
cssInterop ( H3 , {
117
117
className : {
118
- target : ' style' ,
118
+ target : " style" ,
119
119
} ,
120
120
} ) ;
121
121
@@ -162,9 +162,9 @@ type IAccordionTitleTextProps = React.ComponentPropsWithoutRef<
162
162
/** Components */
163
163
164
164
const Accordion = React . forwardRef <
165
- React . ElementRef < typeof UIAccordion > ,
165
+ React . ComponentRef < typeof UIAccordion > ,
166
166
IAccordionProps
167
- > ( ( { className, variant = ' filled' , size = 'md' , ...props } , ref ) => {
167
+ > ( ( { className, variant = " filled" , size = "md" , ...props } , ref ) => {
168
168
return (
169
169
< UIAccordion
170
170
ref = { ref }
@@ -176,7 +176,7 @@ const Accordion = React.forwardRef<
176
176
} ) ;
177
177
178
178
const AccordionItem = React . forwardRef <
179
- React . ElementRef < typeof UIAccordion . Item > ,
179
+ React . ComponentRef < typeof UIAccordion . Item > ,
180
180
IAccordionItemProps
181
181
> ( ( { className, ...props } , ref ) => {
182
182
const { variant } = useStyleContext ( SCOPE ) ;
@@ -193,9 +193,9 @@ const AccordionItem = React.forwardRef<
193
193
} ) ;
194
194
195
195
const AccordionContent = React . forwardRef <
196
- React . ElementRef < typeof UIAccordion . Content > ,
196
+ React . ComponentRef < typeof UIAccordion . Content > ,
197
197
IAccordionContentProps
198
- > ( ( { className, ...props } , ref ) => {
198
+ > ( function AccordionContent ( { className, ...props } , ref ) {
199
199
return (
200
200
< UIAccordion . Content
201
201
ref = { ref }
@@ -208,9 +208,9 @@ const AccordionContent = React.forwardRef<
208
208
} ) ;
209
209
210
210
const AccordionContentText = React . forwardRef <
211
- React . ElementRef < typeof UIAccordion . ContentText > ,
211
+ React . ComponentRef < typeof UIAccordion . ContentText > ,
212
212
IAccordionContentTextProps
213
- > ( ( { className, ...props } , ref ) => {
213
+ > ( function AccordionContentText ( { className, ...props } , ref ) {
214
214
const { size } = useStyleContext ( SCOPE ) ;
215
215
return (
216
216
< UIAccordion . ContentText
@@ -225,12 +225,12 @@ const AccordionContentText = React.forwardRef<
225
225
} ) ;
226
226
227
227
const AccordionIcon = React . forwardRef <
228
- React . ElementRef < typeof UIAccordion . Icon > ,
228
+ React . ComponentRef < typeof UIAccordion . Icon > ,
229
229
IAccordionIconProps
230
- > ( ( { size, className, ...props } , ref ) => {
230
+ > ( function AccordionIcon ( { size, className, ...props } , ref ) {
231
231
const { size : parentSize } = useStyleContext ( SCOPE ) ;
232
232
233
- if ( typeof size === ' number' ) {
233
+ if ( typeof size === " number" ) {
234
234
return (
235
235
< UIAccordion . Icon
236
236
ref = { ref }
@@ -265,9 +265,9 @@ const AccordionIcon = React.forwardRef<
265
265
} ) ;
266
266
267
267
const AccordionHeader = React . forwardRef <
268
- React . ElementRef < typeof UIAccordion . Header > ,
268
+ React . ComponentRef < typeof UIAccordion . Header > ,
269
269
IAccordionHeaderProps
270
- > ( ( { className, ...props } , ref ) => {
270
+ > ( function AccordionHeader ( { className, ...props } , ref ) {
271
271
return (
272
272
< UIAccordion . Header
273
273
ref = { ref }
@@ -280,9 +280,9 @@ const AccordionHeader = React.forwardRef<
280
280
} ) ;
281
281
282
282
const AccordionTrigger = React . forwardRef <
283
- React . ElementRef < typeof UIAccordion . Trigger > ,
283
+ React . ComponentRef < typeof UIAccordion . Trigger > ,
284
284
IAccordionTriggerProps
285
- > ( ( { className, ...props } , ref ) => {
285
+ > ( function AccordionTrigger ( { className, ...props } , ref ) {
286
286
return (
287
287
< UIAccordion . Trigger
288
288
ref = { ref }
@@ -294,9 +294,9 @@ const AccordionTrigger = React.forwardRef<
294
294
) ;
295
295
} ) ;
296
296
const AccordionTitleText = React . forwardRef <
297
- React . ElementRef < typeof UIAccordion . TitleText > ,
297
+ React . ComponentRef < typeof UIAccordion . TitleText > ,
298
298
IAccordionTitleTextProps
299
- > ( ( { className, ...props } , ref ) => {
299
+ > ( function AccordionTitleText ( { className, ...props } , ref ) {
300
300
const { size } = useStyleContext ( SCOPE ) ;
301
301
return (
302
302
< UIAccordion . TitleText
@@ -310,14 +310,14 @@ const AccordionTitleText = React.forwardRef<
310
310
) ;
311
311
} ) ;
312
312
313
- Accordion . displayName = ' Accordion' ;
314
- AccordionItem . displayName = ' AccordionItem' ;
315
- AccordionHeader . displayName = ' AccordionHeader' ;
316
- AccordionTrigger . displayName = ' AccordionTrigger' ;
317
- AccordionTitleText . displayName = ' AccordionTitleText' ;
318
- AccordionContentText . displayName = ' AccordionContentText' ;
319
- AccordionIcon . displayName = ' AccordionIcon' ;
320
- AccordionContent . displayName = ' AccordionContent' ;
313
+ Accordion . displayName = " Accordion" ;
314
+ AccordionItem . displayName = " AccordionItem" ;
315
+ AccordionHeader . displayName = " AccordionHeader" ;
316
+ AccordionTrigger . displayName = " AccordionTrigger" ;
317
+ AccordionTitleText . displayName = " AccordionTitleText" ;
318
+ AccordionContentText . displayName = " AccordionContentText" ;
319
+ AccordionIcon . displayName = " AccordionIcon" ;
320
+ AccordionContent . displayName = " AccordionContent" ;
321
321
322
322
export {
323
323
Accordion ,
0 commit comments