UNPKG

chayns-components

Version:

A set of beautiful React components for developing chayns® applications.

65 lines (64 loc) 1.99 kB
import _extends from "@babel/runtime/helpers/extends"; /* eslint-disable react/forbid-prop-types */ import React from 'react'; import PropTypes from 'prop-types'; import AbstractExpandableListItem from '../ExpandableList/AbstractExpandableListItem'; import ExpandableListHeader from './ExpandableListHeader'; import ExpandableList from '../ExpandableList/ExpandableList'; import { isFunction } from '../../../utils/is'; const ExpandableListItem = _ref => { let { children, onClick, ...props } = _ref; const { noContentClass = false, className, headerClassName, open, style, onOpen, onClose, defaultOpen = false } = props; return /*#__PURE__*/React.createElement(AbstractExpandableListItem, { noContentClass: noContentClass, className: className, header: /*#__PURE__*/React.createElement(ExpandableList.Context.Consumer, null, c => /*#__PURE__*/React.createElement(ExpandableListHeader, _extends({ onClick: function () { if (isFunction(onClick)) { onClick(...arguments); } if (c && isFunction(c.onToggle)) { c.onToggle(...arguments); } } }, props, { open: open === null ? c.open : open, className: headerClassName }))), clickable: true, openProp: open, style: style, onOpenProp: onOpen, onCloseProp: onClose, defaultOpen: defaultOpen }, children); }; ExpandableListItem.propTypes = { children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired, noContentClass: PropTypes.bool, className: PropTypes.string, headerClassName: PropTypes.string, open: PropTypes.bool, style: PropTypes.object, onOpen: PropTypes.func, onClose: PropTypes.func, onClick: PropTypes.func, defaultOpen: PropTypes.bool, headMultiline: PropTypes.bool }; ExpandableListItem.displayName = 'ExpandableListItem'; export default ExpandableListItem; //# sourceMappingURL=ExpandableListItem.js.map