UNPKG

@carbon/ibm-security

Version:

Carbon for Cloud & Cognitive IBM Security UI components

78 lines (77 loc) 2.45 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["title", "count", "countLabel", "className", "titleClassName", "children", "heading"]; /** * @file Filter panel group component. * @copyright IBM Security 2020, 2021 */ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { getComponentNamespace } from '../../../globals/namespace'; import FilterPanelLabel from '../FilterPanelLabel'; var namespace = getComponentNamespace('filter-panel-group'); var FilterPanelGroup = function FilterPanelGroup(_ref) { var title = _ref.title, count = _ref.count, countLabel = _ref.countLabel, className = _ref.className, titleClassName = _ref.titleClassName, children = _ref.children, heading = _ref.heading, other = _objectWithoutProperties(_ref, _excluded); return /*#__PURE__*/React.createElement("div", _extends({ className: classnames(namespace, className) }, other), (heading || title) && /*#__PURE__*/React.createElement("h2", { className: classnames("".concat(namespace, "__title"), titleClassName) }, /*#__PURE__*/React.createElement(FilterPanelLabel, { count: count, countLabel: countLabel, title: title }, heading || title)), /*#__PURE__*/React.createElement("div", { className: "".concat(namespace, "__content") }, children)); }; FilterPanelGroup.propTypes = { /** * Group content. */ children: PropTypes.node, /** * Optional class name. */ className: PropTypes.string, /** * Optional group count. */ count: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** * Function returning a translated text labeling the count for accessibility. */ countLabel: PropTypes.func, /** * Group heading node. * If no `heading` is provided, then the `title` prop value will be used instead. */ heading: PropTypes.node, /** * Group `title` attribute. */ title: PropTypes.string, /** * Optional class name for the title. */ titleClassName: PropTypes.string }; FilterPanelGroup.defaultProps = { title: undefined, count: undefined, countLabel: function countLabel(count) { return "".concat(count, " items"); }, className: undefined, titleClassName: undefined, children: undefined, heading: undefined }; export default FilterPanelGroup;