@@ -3,11 +3,8 @@ import PropTypes from 'prop-types';
33import { omit } from 'ramda' ;
44import RBAccordion from 'react-bootstrap/Accordion' ;
55
6- import {
7- parseChildrenToArray ,
8- resolveChildProps ,
9- stringifyId
10- } from '../../private/util' ;
6+ import { parseChildrenToArray , resolveChildProps } from '../../private/util' ;
7+ import { AccordionContext } from '../../private/AccordionContext' ;
118
129/**
1310 * A self contained Accordion component. Build up the children using the
@@ -62,42 +59,11 @@ const Accordion = props => {
6259 children &&
6360 children . map ( ( child , idx ) => {
6461 const childProps = resolveChildProps ( child ) ;
65- const {
66- title,
67- item_id,
68- loading_state,
69- class_name,
70- className,
71- id,
72- ...otherProps
73- } = childProps ;
74- const itemID = item_id || 'item-' + idx ;
62+ const itemID = childProps . item_id || `item-${ idx } ` ;
7563 return (
76- < RBAccordion . Item
77- id = { stringifyId ( id ) }
78- key = { itemID }
79- eventKey = { itemID }
80- className = { class_name || className }
81- { ...omit (
82- [ 'setProps' , 'persistence' , 'persistence_type' , 'persisted_props' ] ,
83- otherProps
84- ) }
85- data-dash-is-loading = {
86- ( loading_state && loading_state . is_loading ) || undefined
87- }
88- >
89- < RBAccordion . Header
90- onClick = { ( ) => {
91- toggle ( itemID ) ;
92- } }
93- // .dbcd-main h2 has margins defined on it - we need to make
94- // sure to overwrite them
95- style = { { marginTop : '0rem' , marginBottom : '0rem' } }
96- >
97- { title }
98- </ RBAccordion . Header >
99- < RBAccordion . Body > { child } </ RBAccordion . Body >
100- </ RBAccordion . Item >
64+ < AccordionContext . Provider key = { itemID } value = { { toggle, idx} } >
65+ { child }
66+ </ AccordionContext . Provider >
10167 ) ;
10268 } ) ;
10369
0 commit comments