UNPKG

2.88 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5exports.__esModule = true;
6exports.default = void 0;
7
8var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
10var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
12var _react = _interopRequireDefault(require("react"));
13
14var _propTypes = _interopRequireDefault(require("prop-types"));
15
16var _Dropdown = _interopRequireDefault(require("./Dropdown"));
17
18var _NavItem = _interopRequireDefault(require("./NavItem"));
19
20var _NavLink = _interopRequireDefault(require("./NavLink"));
21
22var propTypes = {
23 /**
24 * An html id attribute for the Toggle button, necessary for assistive technologies, such as screen readers.
25 * @type {string|number}
26 * @required
27 */
28 id: _propTypes.default.any,
29
30 /** An `onClick` handler passed to the Toggle component */
31 onClick: _propTypes.default.func,
32
33 /** The content of the non-toggle Button. */
34 title: _propTypes.default.node.isRequired,
35
36 /** Disables the toggle NavLink */
37 disabled: _propTypes.default.bool,
38
39 /** Style the toggle NavLink as active */
40 active: _propTypes.default.bool,
41
42 /** An ARIA accessible role applied to the Menu component. When set to 'menu', The dropdown */
43 menuRole: _propTypes.default.string,
44
45 /**
46 * Which event when fired outside the component will cause it to be closed.
47 *
48 * _see [DropdownMenu](#menu-props) for more details_
49 */
50 rootCloseEvent: _propTypes.default.string,
51
52 /** @ignore */
53 bsPrefix: _propTypes.default.string
54};
55
56var NavDropdown = _react.default.forwardRef(function (_ref, ref) {
57 var id = _ref.id,
58 title = _ref.title,
59 children = _ref.children,
60 bsPrefix = _ref.bsPrefix,
61 rootCloseEvent = _ref.rootCloseEvent,
62 menuRole = _ref.menuRole,
63 disabled = _ref.disabled,
64 active = _ref.active,
65 props = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["id", "title", "children", "bsPrefix", "rootCloseEvent", "menuRole", "disabled", "active"]);
66 return _react.default.createElement(_Dropdown.default, (0, _extends2.default)({
67 ref: ref
68 }, props, {
69 as: _NavItem.default
70 }), _react.default.createElement(_Dropdown.default.Toggle, {
71 id: id,
72 eventKey: null,
73 active: active,
74 disabled: disabled,
75 childBsPrefix: bsPrefix,
76 as: _NavLink.default
77 }, title), _react.default.createElement(_Dropdown.default.Menu, {
78 role: menuRole,
79 rootCloseEvent: rootCloseEvent
80 }, children));
81});
82
83NavDropdown.displayName = 'NavDropdown';
84NavDropdown.propTypes = propTypes;
85NavDropdown.Item = _Dropdown.default.Item;
86NavDropdown.Divider = _Dropdown.default.Divider;
87NavDropdown.Header = _Dropdown.default.Header;
88var _default = NavDropdown;
89exports.default = _default;
90module.exports = exports["default"];
\No newline at end of file