1 | import _Object$values from "@babel/runtime-corejs2/core-js/object/values";
|
2 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
3 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
4 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
5 | import classNames from 'classnames';
|
6 | import React, { cloneElement } from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 | import { bsClass, bsStyles, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
|
9 | import { State } from './utils/StyleConfig';
|
10 | var propTypes = {
|
11 | active: PropTypes.any,
|
12 | disabled: PropTypes.any,
|
13 | header: PropTypes.node,
|
14 | listItem: PropTypes.bool,
|
15 | onClick: PropTypes.func,
|
16 | href: PropTypes.string,
|
17 | type: PropTypes.string
|
18 | };
|
19 | var defaultProps = {
|
20 | listItem: false
|
21 | };
|
22 |
|
23 | var ListGroupItem =
|
24 |
|
25 | function (_React$Component) {
|
26 | _inheritsLoose(ListGroupItem, _React$Component);
|
27 |
|
28 | function ListGroupItem() {
|
29 | return _React$Component.apply(this, arguments) || this;
|
30 | }
|
31 |
|
32 | var _proto = ListGroupItem.prototype;
|
33 |
|
34 | _proto.renderHeader = function renderHeader(header, headingClassName) {
|
35 | if (React.isValidElement(header)) {
|
36 | return cloneElement(header, {
|
37 | className: classNames(header.props.className, headingClassName)
|
38 | });
|
39 | }
|
40 |
|
41 | return React.createElement("h4", {
|
42 | className: headingClassName
|
43 | }, header);
|
44 | };
|
45 |
|
46 | _proto.render = function render() {
|
47 | var _this$props = this.props,
|
48 | active = _this$props.active,
|
49 | disabled = _this$props.disabled,
|
50 | className = _this$props.className,
|
51 | header = _this$props.header,
|
52 | listItem = _this$props.listItem,
|
53 | children = _this$props.children,
|
54 | props = _objectWithoutPropertiesLoose(_this$props, ["active", "disabled", "className", "header", "listItem", "children"]);
|
55 |
|
56 | var _splitBsProps = splitBsProps(props),
|
57 | bsProps = _splitBsProps[0],
|
58 | elementProps = _splitBsProps[1];
|
59 |
|
60 | var classes = _extends({}, getClassSet(bsProps), {
|
61 | active: active,
|
62 | disabled: disabled
|
63 | });
|
64 |
|
65 | var Component;
|
66 |
|
67 | if (elementProps.href) {
|
68 | Component = 'a';
|
69 | } else if (elementProps.onClick) {
|
70 | Component = 'button';
|
71 | elementProps.type = elementProps.type || 'button';
|
72 | } else if (listItem) {
|
73 | Component = 'li';
|
74 | } else {
|
75 | Component = 'span';
|
76 | }
|
77 |
|
78 | elementProps.className = classNames(className, classes);
|
79 |
|
80 | if (header) {
|
81 | return React.createElement(Component, elementProps, this.renderHeader(header, prefix(bsProps, 'heading')), React.createElement("p", {
|
82 | className: prefix(bsProps, 'text')
|
83 | }, children));
|
84 | }
|
85 |
|
86 | return React.createElement(Component, elementProps, children);
|
87 | };
|
88 |
|
89 | return ListGroupItem;
|
90 | }(React.Component);
|
91 |
|
92 | ListGroupItem.propTypes = propTypes;
|
93 | ListGroupItem.defaultProps = defaultProps;
|
94 | export default bsClass('list-group-item', bsStyles(_Object$values(State), ListGroupItem)); |
\ | No newline at end of file |