@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
64 lines (60 loc) • 1.85 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import cx from 'classnames';
import { usePrefix } from '../../internal/usePrefix.js';
import PropTypes from 'prop-types';
import React__default from 'react';
import { AccordionProvider } from './AccordionProvider.js';
function Accordion(_ref) {
let {
align = 'end',
children,
className: customClassName,
disabled = false,
isFlush = false,
size,
...rest
} = _ref;
const prefix = usePrefix();
const className = cx(`${prefix}--accordion`, customClassName, {
[`${prefix}--accordion--${align}`]: align,
[`${prefix}--accordion--${size}`]: size,
// TODO: V12 - Remove this class
[`${prefix}--layout--size-${size}`]: size,
[`${prefix}--accordion--flush`]: isFlush && align !== 'start'
});
return /*#__PURE__*/React__default.createElement(AccordionProvider, {
disabled: disabled
}, /*#__PURE__*/React__default.createElement("ul", _extends({
className: className
}, rest), children));
}
Accordion.propTypes = {
/**
* Specify the alignment of the accordion heading title and chevron.
*/
align: PropTypes.oneOf(['start', 'end']),
/**
* Pass in the children that will be rendered within the Accordion
*/
children: PropTypes.node,
/**
* Specify an optional className to be applied to the container node
*/
className: PropTypes.string,
/**
* Specify whether an individual AccordionItem should be disabled
*/
disabled: PropTypes.bool,
/**
* Specify whether Accordion text should be flush, default is false, does not work with align="start"
*/
isFlush: PropTypes.bool,
/**
* Specify the size of the Accordion. Currently supports the following:
*/
size: PropTypes.oneOf(['sm', 'md', 'lg'])
};
export { Accordion as default };