1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import classNames from 'classnames';
|
4 | import React, { useCallback } from 'react';
|
5 | import AbstractNavItem from './AbstractNavItem';
|
6 | import { makeEventKey } from './SelectableContext';
|
7 | import { useBootstrapPrefix } from './ThemeProvider';
|
8 | var defaultProps = {
|
9 | variant: undefined,
|
10 | active: false,
|
11 | disabled: false
|
12 | };
|
13 | var ListGroupItem = React.forwardRef(function (_ref, ref) {
|
14 | var bsPrefix = _ref.bsPrefix,
|
15 | active = _ref.active,
|
16 | disabled = _ref.disabled,
|
17 | className = _ref.className,
|
18 | variant = _ref.variant,
|
19 | action = _ref.action,
|
20 | as = _ref.as,
|
21 | eventKey = _ref.eventKey,
|
22 | onClick = _ref.onClick,
|
23 | props = _objectWithoutPropertiesLoose(_ref, ["bsPrefix", "active", "disabled", "className", "variant", "action", "as", "eventKey", "onClick"]);
|
24 |
|
25 | bsPrefix = useBootstrapPrefix(bsPrefix, 'list-group-item');
|
26 | var handleClick = useCallback(function (event) {
|
27 | if (disabled) {
|
28 | event.preventDefault();
|
29 | event.stopPropagation();
|
30 | return;
|
31 | }
|
32 |
|
33 | if (onClick) onClick(event);
|
34 | }, [disabled, onClick]);
|
35 |
|
36 | if (disabled && props.tabIndex === undefined) {
|
37 | props.tabIndex = -1;
|
38 | props['aria-disabled'] = true;
|
39 | }
|
40 |
|
41 | return React.createElement(AbstractNavItem, _extends({
|
42 | ref: ref
|
43 | }, props, {
|
44 |
|
45 | eventKey: makeEventKey(eventKey, props.href)
|
46 | ,
|
47 | as: as || (action ? props.href ? 'a' : 'button' : 'div'),
|
48 | onClick: handleClick,
|
49 | className: classNames(className, bsPrefix, active && 'active', disabled && 'disabled', variant && bsPrefix + "-" + variant, action && bsPrefix + "-action")
|
50 | }));
|
51 | });
|
52 | ListGroupItem.defaultProps = defaultProps;
|
53 | ListGroupItem.displayName = 'ListGroupItem';
|
54 | export default ListGroupItem; |
\ | No newline at end of file |