1 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
4 | import classNames from 'classnames';
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import { prefix } from './utils/bootstrapUtils';
|
8 | import createChainedFunction from './utils/createChainedFunction';
|
9 | var propTypes = {
|
10 | onClick: PropTypes.func,
|
11 |
|
12 | |
13 |
|
14 |
|
15 | children: PropTypes.node
|
16 | };
|
17 | var contextTypes = {
|
18 | $bs_navbar: PropTypes.shape({
|
19 | bsClass: PropTypes.string,
|
20 | expanded: PropTypes.bool,
|
21 | onToggle: PropTypes.func.isRequired
|
22 | })
|
23 | };
|
24 |
|
25 | var NavbarToggle =
|
26 |
|
27 | function (_React$Component) {
|
28 | _inheritsLoose(NavbarToggle, _React$Component);
|
29 |
|
30 | function NavbarToggle() {
|
31 | return _React$Component.apply(this, arguments) || this;
|
32 | }
|
33 |
|
34 | var _proto = NavbarToggle.prototype;
|
35 |
|
36 | _proto.render = function render() {
|
37 | var _this$props = this.props,
|
38 | onClick = _this$props.onClick,
|
39 | className = _this$props.className,
|
40 | children = _this$props.children,
|
41 | props = _objectWithoutPropertiesLoose(_this$props, ["onClick", "className", "children"]);
|
42 |
|
43 | var navbarProps = this.context.$bs_navbar || {
|
44 | bsClass: 'navbar'
|
45 | };
|
46 |
|
47 | var buttonProps = _extends({
|
48 | type: 'button'
|
49 | }, props, {
|
50 | onClick: createChainedFunction(onClick, navbarProps.onToggle),
|
51 | className: classNames(className, prefix(navbarProps, 'toggle'), !navbarProps.expanded && 'collapsed')
|
52 | });
|
53 |
|
54 | if (children) {
|
55 | return React.createElement("button", buttonProps, children);
|
56 | }
|
57 |
|
58 | return React.createElement("button", buttonProps, React.createElement("span", {
|
59 | className: "sr-only"
|
60 | }, "Toggle navigation"), React.createElement("span", {
|
61 | className: "icon-bar"
|
62 | }), React.createElement("span", {
|
63 | className: "icon-bar"
|
64 | }), React.createElement("span", {
|
65 | className: "icon-bar"
|
66 | }));
|
67 | };
|
68 |
|
69 | return NavbarToggle;
|
70 | }(React.Component);
|
71 |
|
72 | NavbarToggle.propTypes = propTypes;
|
73 | NavbarToggle.contextTypes = contextTypes;
|
74 | export default NavbarToggle; |
\ | No newline at end of file |