1 | "use strict";
|
2 | "use client";
|
3 |
|
4 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
5 | exports.__esModule = true;
|
6 | exports.default = void 0;
|
7 | var _classnames = _interopRequireDefault(require("classnames"));
|
8 | var React = _interopRequireWildcard(require("react"));
|
9 | var _warning = _interopRequireDefault(require("warning"));
|
10 | var _useEventCallback = _interopRequireDefault(require("@restart/hooks/useEventCallback"));
|
11 | var _NavItem = require("@restart/ui/NavItem");
|
12 | var _SelectableContext = require("@restart/ui/SelectableContext");
|
13 | var _ThemeProvider = require("./ThemeProvider");
|
14 | var _jsxRuntime = require("react/jsx-runtime");
|
15 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
16 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
17 | const ListGroupItem = React.forwardRef(({
|
18 | bsPrefix,
|
19 | active,
|
20 | disabled,
|
21 | eventKey,
|
22 | className,
|
23 | variant,
|
24 | action,
|
25 | as,
|
26 | ...props
|
27 | }, ref) => {
|
28 | bsPrefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'list-group-item');
|
29 | const [navItemProps, meta] = (0, _NavItem.useNavItem)({
|
30 | key: (0, _SelectableContext.makeEventKey)(eventKey, props.href),
|
31 | active,
|
32 | ...props
|
33 | });
|
34 | const handleClick = (0, _useEventCallback.default)(event => {
|
35 | if (disabled) {
|
36 | event.preventDefault();
|
37 | event.stopPropagation();
|
38 | return;
|
39 | }
|
40 | navItemProps.onClick(event);
|
41 | });
|
42 | if (disabled && props.tabIndex === undefined) {
|
43 | props.tabIndex = -1;
|
44 | props['aria-disabled'] = true;
|
45 | }
|
46 |
|
47 |
|
48 | const Component = as || (action ? props.href ? 'a' : 'button' : 'div');
|
49 | process.env.NODE_ENV !== "production" ? (0, _warning.default)(as || !(!action && props.href), '`action=false` and `href` should not be used together.') : void 0;
|
50 | return (0, _jsxRuntime.jsx)(Component, {
|
51 | ref: ref,
|
52 | ...props,
|
53 | ...navItemProps,
|
54 | onClick: handleClick,
|
55 | className: (0, _classnames.default)(className, bsPrefix, meta.isActive && 'active', disabled && 'disabled', variant && `${bsPrefix}-${variant}`, action && `${bsPrefix}-action`)
|
56 | });
|
57 | });
|
58 | ListGroupItem.displayName = 'ListGroupItem';
|
59 | var _default = ListGroupItem;
|
60 | exports.default = _default;
|
61 | module.exports = exports.default; |
\ | No newline at end of file |