1 | import classNames from 'classnames';
|
2 | import * as React from 'react';
|
3 | import { useContext } from 'react';
|
4 | import { useDropdownToggle } from '@restart/ui/DropdownToggle';
|
5 | import DropdownContext from '@restart/ui/DropdownContext';
|
6 | import useMergedRefs from '@restart/hooks/useMergedRefs';
|
7 | import Button from './Button';
|
8 | import InputGroupContext from './InputGroupContext';
|
9 | import { useBootstrapPrefix } from './ThemeProvider';
|
10 | import useWrappedRefWithWarning from './useWrappedRefWithWarning';
|
11 | import { jsx as _jsx } from "react/jsx-runtime";
|
12 | const DropdownToggle = React.forwardRef(({
|
13 | bsPrefix,
|
14 | split,
|
15 | className,
|
16 | childBsPrefix,
|
17 |
|
18 | as: Component = Button,
|
19 | ...props
|
20 | }, ref) => {
|
21 | const prefix = useBootstrapPrefix(bsPrefix, 'dropdown-toggle');
|
22 | const dropdownContext = useContext(DropdownContext);
|
23 | const isInputGroup = useContext(InputGroupContext);
|
24 |
|
25 | if (childBsPrefix !== undefined) {
|
26 | props.bsPrefix = childBsPrefix;
|
27 | }
|
28 |
|
29 | const [toggleProps] = useDropdownToggle();
|
30 | toggleProps.ref = useMergedRefs(toggleProps.ref, useWrappedRefWithWarning(ref, 'DropdownToggle'));
|
31 |
|
32 |
|
33 | return _jsx(Component, {
|
34 | className: classNames(className, prefix, split && `${prefix}-split`, !!isInputGroup && (dropdownContext == null ? void 0 : dropdownContext.show) && 'show'),
|
35 | ...toggleProps,
|
36 | ...props
|
37 | });
|
38 | });
|
39 | DropdownToggle.displayName = 'DropdownToggle';
|
40 | export default DropdownToggle; |
\ | No newline at end of file |