1
1
import { Component , JSXNode , PropsOf , QRL , Signal } from '@builder.io/qwik' ;
2
- import { HAccordionItem } from './accordion-item' ;
3
2
import { HAccordionRootImpl } from './accordion-root' ;
3
+ import { Accordion } from '@qwik-ui/headless' ;
4
4
5
5
export type AccordionRootProps = PropsOf < 'div' > & {
6
6
/** If true, multiple items can be open at the same time. */
@@ -34,17 +34,20 @@ export type AccordionRootProps = PropsOf<'div'> & {
34
34
35
35
/** If true, the accordion is animated. */
36
36
animated ?: boolean ;
37
+
38
+ accordionItemComponent : typeof Accordion . Item ;
37
39
} ;
38
40
39
41
export const HAccordionRoot : Component < AccordionRootProps > = (
40
42
props : AccordionRootProps ,
41
43
) => {
42
- const { children : accordionChildren , ...rest } = props ;
44
+ const { children : accordionChildren , accordionItemComponent , ...rest } = props ;
43
45
44
46
let currItemIndex = 0 ;
45
47
let initialIndex = null ;
46
48
const itemsMap = new Map ( ) ;
47
49
50
+ const InternalItemComponent = accordionItemComponent || Accordion . Item ;
48
51
const childrenToProcess = (
49
52
Array . isArray ( accordionChildren ) ? [ ...accordionChildren ] : [ accordionChildren ]
50
53
) as Array < JSXNode > ;
@@ -62,7 +65,7 @@ export const HAccordionRoot: Component<AccordionRootProps> = (
62
65
}
63
66
64
67
switch ( child . type ) {
65
- case HAccordionItem : {
68
+ case InternalItemComponent : {
66
69
child . props . _index = currItemIndex ;
67
70
if ( props . value !== undefined && props . value === child . props . value ) {
68
71
initialIndex = currItemIndex ;
0 commit comments