UNPKG

3.25 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _react = _interopRequireDefault(require("react"));
8var _propTypes = _interopRequireDefault(require("prop-types"));
9var _classnames = _interopRequireDefault(require("classnames"));
10var _utils = require("./utils");
11const _excluded = ["className", "cssModule", "tag", "flush", "horizontal", "numbered"];
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13function _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); }
14function _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; }
15function _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; }
16const propTypes = {
17 /** Add custom class */
18 className: _propTypes.default.string,
19 /** Change underlying component's CSS base class name */
20 cssModule: _propTypes.default.object,
21 /** Remove borders to make the list appear flush */
22 flush: _propTypes.default.bool,
23 /** Make the list horizontal instead of vertical */
24 horizontal: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
25 /** Add number to the ListItems */
26 numbered: _propTypes.default.bool,
27 /** Set a custom element for this component */
28 tag: _utils.tagPropType
29};
30const getHorizontalClass = horizontal => {
31 if (horizontal === false) {
32 return false;
33 }
34 if (horizontal === true || horizontal === 'xs') {
35 return 'list-group-horizontal';
36 }
37 return `list-group-horizontal-${horizontal}`;
38};
39function ListGroup(props) {
40 const {
41 className,
42 cssModule,
43 tag: Tag = 'ul',
44 flush,
45 horizontal = false,
46 numbered = false
47 } = props,
48 attributes = _objectWithoutProperties(props, _excluded);
49 const classes = (0, _utils.mapToCssModules)((0, _classnames.default)(className, 'list-group',
50 // list-group-horizontal cannot currently be mixed with list-group-flush
51 // we only try to apply horizontal classes if flush is false
52 flush ? 'list-group-flush' : getHorizontalClass(horizontal), {
53 'list-group-numbered': numbered
54 }), cssModule);
55 return /*#__PURE__*/_react.default.createElement(Tag, _extends({}, attributes, {
56 className: classes
57 }));
58}
59ListGroup.propTypes = propTypes;
60var _default = ListGroup;
61exports.default = _default;
\No newline at end of file