UNPKG

3.13 kBJavaScriptView Raw
1var _excluded = ["className", "cssModule", "tag", "flush", "horizontal", "numbered"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5import React from 'react';
6import PropTypes from 'prop-types';
7import classNames from 'classnames';
8import { mapToCssModules, tagPropType } from './utils';
9var propTypes = {
10 /** Add custom class */
11 className: PropTypes.string,
12 /** Change underlying component's CSS base class name */
13 cssModule: PropTypes.object,
14 /** Remove borders to make the list appear flush */
15 flush: PropTypes.bool,
16 /** Make the list horizontal instead of vertical */
17 horizontal: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
18 /** Add number to the ListItems */
19 numbered: PropTypes.bool,
20 /** Set a custom element for this component */
21 tag: tagPropType
22};
23var getHorizontalClass = function getHorizontalClass(horizontal) {
24 if (horizontal === false) {
25 return false;
26 }
27 if (horizontal === true || horizontal === 'xs') {
28 return 'list-group-horizontal';
29 }
30 return "list-group-horizontal-".concat(horizontal);
31};
32function ListGroup(props) {
33 var className = props.className,
34 cssModule = props.cssModule,
35 _props$tag = props.tag,
36 Tag = _props$tag === void 0 ? 'ul' : _props$tag,
37 flush = props.flush,
38 _props$horizontal = props.horizontal,
39 horizontal = _props$horizontal === void 0 ? false : _props$horizontal,
40 _props$numbered = props.numbered,
41 numbered = _props$numbered === void 0 ? false : _props$numbered,
42 attributes = _objectWithoutProperties(props, _excluded);
43 var classes = mapToCssModules(classNames(className, 'list-group',
44 // list-group-horizontal cannot currently be mixed with list-group-flush
45 // we only try to apply horizontal classes if flush is false
46 flush ? 'list-group-flush' : getHorizontalClass(horizontal), {
47 'list-group-numbered': numbered
48 }), cssModule);
49 return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
50 className: classes
51 }));
52}
53ListGroup.propTypes = propTypes;
54export default ListGroup;
\No newline at end of file