UNPKG

1.52 kBJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import warning from 'warning';
4import { useUncontrolled } from 'uncontrollable';
5import BaseNav from '@restart/ui/Nav';
6import { useBootstrapPrefix } from './ThemeProvider';
7import ListGroupItem from './ListGroupItem';
8import { jsx as _jsx } from "react/jsx-runtime";
9const ListGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
10 const {
11 className,
12 bsPrefix: initialBsPrefix,
13 variant,
14 horizontal,
15 numbered,
16 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
17 as = 'div',
18 ...controlledProps
19 } = useUncontrolled(props, {
20 activeKey: 'onSelect'
21 });
22 const bsPrefix = useBootstrapPrefix(initialBsPrefix, 'list-group');
23 let horizontalVariant;
24
25 if (horizontal) {
26 horizontalVariant = horizontal === true ? 'horizontal' : `horizontal-${horizontal}`;
27 }
28
29 process.env.NODE_ENV !== "production" ? warning(!(horizontal && variant === 'flush'), '`variant="flush"` and `horizontal` should not be used together.') : void 0;
30 return /*#__PURE__*/_jsx(BaseNav, {
31 ref: ref,
32 ...controlledProps,
33 as: as,
34 className: classNames(className, bsPrefix, variant && `${bsPrefix}-${variant}`, horizontalVariant && `${bsPrefix}-${horizontalVariant}`, numbered && `${bsPrefix}-numbered`)
35 });
36});
37ListGroup.displayName = 'ListGroup';
38export default Object.assign(ListGroup, {
39 Item: ListGroupItem
40});
\No newline at end of file