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