Gazebo_simulation-Frontend/node_modules/react-bootstrap/esm/NavbarToggle.js
2020-12-21 10:29:31 -05:00

47 lines
1.6 KiB
JavaScript

import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import classNames from 'classnames';
import React, { useContext } from 'react';
import useEventCallback from '@restart/hooks/useEventCallback';
import { useBootstrapPrefix } from './ThemeProvider';
import NavbarContext from './NavbarContext';
var defaultProps = {
label: 'Toggle navigation'
};
var NavbarToggle = React.forwardRef(function (_ref, ref) {
var bsPrefix = _ref.bsPrefix,
className = _ref.className,
children = _ref.children,
label = _ref.label,
_ref$as = _ref.as,
Component = _ref$as === void 0 ? 'button' : _ref$as,
onClick = _ref.onClick,
props = _objectWithoutPropertiesLoose(_ref, ["bsPrefix", "className", "children", "label", "as", "onClick"]);
bsPrefix = useBootstrapPrefix(bsPrefix, 'navbar-toggler');
var _ref2 = useContext(NavbarContext) || {},
onToggle = _ref2.onToggle,
expanded = _ref2.expanded;
var handleClick = useEventCallback(function (e) {
if (onClick) onClick(e);
if (onToggle) onToggle();
});
if (Component === 'button') {
props.type = 'button';
}
return React.createElement(Component, _extends({}, props, {
ref: ref,
onClick: handleClick,
"aria-label": label,
className: classNames(className, bsPrefix, !expanded && 'collapsed')
}), children || React.createElement("span", {
className: bsPrefix + "-icon"
}));
});
NavbarToggle.displayName = 'NavbarToggle';
NavbarToggle.defaultProps = defaultProps;
export default NavbarToggle;