1
- import {
2
- h ,
3
- defineComponent ,
4
- PropType ,
5
- computed ,
6
- ComputedRef ,
7
- ref ,
8
- onMounted ,
9
- Fragment ,
10
- onBeforeMount ,
11
- watchEffect ,
12
- } from "vue"
1
+ import { h , defineComponent , PropType , computed , ComputedRef , ref } from "vue"
13
2
import * as accordion from "@zag-js/accordion"
14
3
import { normalizeProps , useMachine , useSetup } from "@zag-js/vue"
15
4
import {
@@ -24,7 +13,13 @@ import {
24
13
DeepPartial ,
25
14
} from "@chakra-ui/vue-system"
26
15
import { useIds , useId } from "@chakra-ui/vue-composables"
27
- import { createContext , genId , vueThemingProps } from "@chakra-ui/vue-utils"
16
+ import {
17
+ createContext ,
18
+ genId ,
19
+ SNAO ,
20
+ getValidChildren ,
21
+ vueThemingProps ,
22
+ } from "@chakra-ui/vue-utils"
28
23
import { filterUndefined , mergeWith } from "@chakra-ui/utils"
29
24
import { SystemStyleObject } from "@chakra-ui/styled-system"
30
25
import { CCollapse } from "@chakra-ui/c-motion"
@@ -47,6 +42,7 @@ export interface CAccordionProps
47
42
* The index(es) of the expanded accordion item
48
43
*/
49
44
index ?: ExpandedValues
45
+ defaultIndex ?: ExpandedValues
50
46
/**
51
47
* The initial index(es) of the expanded accordion item
52
48
*/
@@ -78,8 +74,8 @@ export const CAccordion: ComponentWithProps<DeepPartial<CAccordionProps>> =
78
74
} ,
79
75
allowMultiple : Boolean as PropType < CAccordionProps [ "allowMultiple" ] > ,
80
76
allowToggle : Boolean as PropType < CAccordionProps [ "allowToggle" ] > ,
81
- index : Number as PropType < CAccordionProps [ "index" ] > ,
82
- defaultIndex : Number as PropType < CAccordionProps [ "defaultIndex" ] > ,
77
+ index : SNAO as PropType < CAccordionProps [ "index" ] > ,
78
+ defaultIndex : SNAO as PropType < CAccordionProps [ "defaultIndex" ] > ,
83
79
reduceMotion : {
84
80
type : Boolean as PropType < CAccordionProps [ "reduceMotion" ] > ,
85
81
default : false ,
@@ -134,11 +130,9 @@ export const CAccordion: ComponentWithProps<DeepPartial<CAccordionProps>> =
134
130
} }
135
131
>
136
132
{ ( ) => (
137
- < >
138
- < div ref = { accordionRef } { ...api . rootProps } >
139
- { slots }
140
- </ div >
141
- </ >
133
+ < div ref = { accordionRef } { ...api . rootProps } >
134
+ { getValidChildren ( slots ) }
135
+ </ div >
142
136
) }
143
137
</ chakra . div >
144
138
)
@@ -202,7 +196,7 @@ export const CAccordionItem: ComponentWithProps<CAccordionItemProps> =
202
196
} ) }
203
197
{ ...attrs }
204
198
>
205
- { slots }
199
+ { getValidChildren ( slots ) }
206
200
</ chakra . div >
207
201
)
208
202
} ,
@@ -239,7 +233,7 @@ export const CAccordionButton: ComponentWithProps<CAccordionButtonProps> =
239
233
__css = { buttonStyles . value }
240
234
{ ...attrs }
241
235
>
242
- { slots }
236
+ { getValidChildren ( slots ) }
243
237
</ chakra . button >
244
238
)
245
239
} ,
@@ -266,15 +260,9 @@ export const CAccordionPanel: ComponentWithProps<CAccordionPanelProps> =
266
260
} )
267
261
return (
268
262
< CCollapse isOpen = { isOpen . value } >
269
- { ( ) => (
270
- < chakra . div
271
- { ...contentProps }
272
- __css = { styles . value . panel }
273
- { ...attrs }
274
- >
275
- { slots }
276
- </ chakra . div >
277
- ) }
263
+ < chakra . div { ...contentProps } __css = { styles . value . panel } { ...attrs } >
264
+ { getValidChildren ( slots ) }
265
+ </ chakra . div >
278
266
</ CCollapse >
279
267
)
280
268
}
@@ -305,14 +293,10 @@ export const CAccordionIcon: ComponentWithProps<CAccordionIconProps> =
305
293
__css = { iconStyles . value }
306
294
{ ...attrs }
307
295
>
308
- { ( ) => (
309
- < >
310
- < path
311
- fill = "currentColor"
312
- d = "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"
313
- />
314
- </ >
315
- ) }
296
+ < path
297
+ fill = "currentColor"
298
+ d = "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"
299
+ />
316
300
</ CIcon >
317
301
)
318
302
} ,
0 commit comments