UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

118 lines (117 loc) 4.15 kB
import PropTypes from 'prop-types'; import { AnimationEventHandler, AriaAttributes, KeyboardEvent, MouseEventHandler, PropsWithChildren, ReactElement, ReactNode } from 'react'; interface AccordionItemProps { /** * Specify an optional className to be * applied to the container node. */ className?: string; headingClassName?: string; titleClassName?: string; contentClassName?: string; /** * Specify whether an individual `AccordionItem` should * be disabled (overrides the parent accordion state). If undefined, * this value will be managed by the parent Accordion. */ disabled?: boolean; /** * The handler of the massaged `click` event. */ onClick?: MouseEventHandler<HTMLLIElement>; /** * The handler of the massaged `click` event on * the heading. */ onHeadingClick?: ({ isOpen, event, }: { isOpen: boolean; event: Parameters<MouseEventHandler<HTMLButtonElement>>[0]; }) => void; /** * `true` to open the expand. */ open?: boolean; /** * @deprecated This prop has been deprecated and will be * removed in the next major release of Carbon. Use the * `renderToggle` prop instead. */ renderExpando?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement; /** * The callback function to render the expand button. * Can be a React component class. */ renderToggle?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement; /** * The accordion title. */ title?: ReactNode; /** * The callback function to run on the `onAnimationEnd` * event for the list item. */ handleAnimationEnd?: AnimationEventHandler<HTMLLIElement>; /** * custom icon when open */ openIcon?: ReactNode; /** * custom icon when close */ closeIcon?: ReactNode; /** * toggle open and close with just the icon */ iconOnlyToggle?: boolean; } interface AccordionToggleProps { 'aria-controls'?: AriaAttributes['aria-controls']; 'aria-expanded'?: AriaAttributes['aria-expanded']; className?: string; disabled?: boolean; onClick?: MouseEventHandler<HTMLButtonElement>; onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void; type?: 'button'; } declare function AccordionItem({ children, className: customClassName, open, onHeadingClick, renderToggle, title, disabled: controlledDisabled, handleAnimationEnd, openIcon, closeIcon, iconOnlyToggle, headingClassName, titleClassName, contentClassName, ...rest }: PropsWithChildren<AccordionItemProps>): JSX.Element; declare namespace AccordionItem { var propTypes: { /** * Provide the contents of your AccordionItem */ children: PropTypes.Requireable<PropTypes.ReactNodeLike>; headingClassName: PropTypes.Requireable<PropTypes.ReactNodeLike>; titleClassName: PropTypes.Requireable<PropTypes.ReactNodeLike>; contentClassName: PropTypes.Requireable<PropTypes.ReactNodeLike>; /** * Specify an optional className to be applied to the container node */ className: PropTypes.Requireable<string>; /** * Specify whether an individual AccordionItem should be disabled */ disabled: PropTypes.Requireable<boolean>; /** * The handler of the massaged `click` event. */ onClick: PropTypes.Requireable<(...args: any[]) => any>; /** * The handler of the massaged `click` event on the heading. */ onHeadingClick: PropTypes.Requireable<(...args: any[]) => any>; /** * `true` to open the expand. */ open: PropTypes.Requireable<boolean>; /** * The callback function to render the expand button. * Can be a React component class. */ renderToggle: PropTypes.Requireable<(...args: any[]) => any>; /** * The accordion title. */ title: PropTypes.Requireable<PropTypes.ReactNodeLike>; }; } export default AccordionItem;