Skip to content

Commit

Permalink
rogue types
Browse files Browse the repository at this point in the history
  • Loading branch information
scurker committed Aug 17, 2023
1 parent 9a940af commit 2b1aea3
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions packages/react/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classnames from 'classnames';
import ExpandCollapsePanel, {
ExpandCollapsePanelProps,
PanelTrigger
PanelTrigger,
} from '../ExpandCollapsePanel';
import { useId } from 'react-id-generator';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -57,13 +57,13 @@ const Accordion = ({
const childrenArray = React.Children.toArray(children);

const trigger = childrenArray.find(
child =>
(child) =>
typeof child === 'string' ||
(child as React.ReactElement<any>).type === AccordionTrigger
);
) as unknown as typeof AccordionTrigger;

const panelElement = childrenArray.find(
child =>
(child) =>
typeof child === 'string' ||
(child as React.ReactElement<any>).type === AccordionContent
);
Expand All @@ -78,7 +78,7 @@ const Accordion = ({
{
trigger: trigger,
panelElement: panelElement,
isValid: isValid
isValid: isValid,
}
);
return null;
Expand All @@ -96,10 +96,13 @@ const Accordion = ({
<PanelTrigger
iconCollapsed="triangle-right"
iconExpanded="triangle-down"
className={classnames('Accordion__trigger', trigger.props.className)}
className={classnames(
'Accordion__trigger',
(trigger.props as AccordionTriggerProps).className
)}
aria-controls={panelElement.props.id || `${elementId}-panel`}
heading={trigger.props.heading}
{...trigger.props}
heading={(trigger.props as AccordionTriggerProps).heading}
{...(trigger.props as AccordionTriggerProps)}
>
{trigger}
</PanelTrigger>
Expand All @@ -115,19 +118,19 @@ AccordionTrigger.displayName = 'AccordionTrigger';

Accordion.propTypes = {
children: PropTypes.node,
className: PropTypes.string
className: PropTypes.string,
};

AccordionTrigger.propTypes = {
children: PropTypes.node,
heading: PropTypes.shape({
level: PropTypes.number
})
level: PropTypes.number,
}),
};

AccordionContent.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string
className: PropTypes.string,
};

export default Accordion;
Expand Down

0 comments on commit 2b1aea3

Please sign in to comment.