UNPKG

1.63 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import React from 'react';
4import PropTypes from 'prop-types';
5import classNames from 'classnames';
6import { mapToCssModules, tagPropType } from './utils';
7var propTypes = {
8 tag: tagPropType,
9 flush: PropTypes.bool,
10 className: PropTypes.string,
11 cssModule: PropTypes.object,
12 horizontal: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
13};
14var defaultProps = {
15 tag: 'ul',
16 horizontal: false
17};
18
19var getHorizontalClass = function getHorizontalClass(horizontal) {
20 if (horizontal === false) {
21 return false;
22 } else if (horizontal === true || horizontal === "xs") {
23 return "list-group-horizontal";
24 }
25
26 return "list-group-horizontal-" + horizontal;
27};
28
29var ListGroup = function ListGroup(props) {
30 var className = props.className,
31 cssModule = props.cssModule,
32 Tag = props.tag,
33 flush = props.flush,
34 horizontal = props.horizontal,
35 attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "tag", "flush", "horizontal"]);
36
37 var classes = mapToCssModules(classNames(className, 'list-group', // list-group-horizontal cannot currently be mixed with list-group-flush
38 // we only try to apply horizontal classes if flush is false
39 flush ? 'list-group-flush' : getHorizontalClass(horizontal)), cssModule);
40 return React.createElement(Tag, _extends({}, attributes, {
41 className: classes
42 }));
43};
44
45ListGroup.propTypes = propTypes;
46ListGroup.defaultProps = defaultProps;
47export default ListGroup;
\No newline at end of file