GoScrobble/web/node_modules/react-bootstrap/cjs/DropdownButton.js

124 lines
5.1 KiB
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
var _DropdownToggle = _interopRequireDefault(require("./DropdownToggle"));
var _DropdownMenu = _interopRequireWildcard(require("./DropdownMenu"));
var _excluded = ["title", "children", "bsPrefix", "rootCloseEvent", "variant", "size", "menuAlign", "menuRole", "renderMenuOnMount", "disabled", "href", "id"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var propTypes = {
/**
* An html id attribute for the Toggle button, necessary for assistive technologies, such as screen readers.
* @type {string|number}
* @required
*/
id: _propTypes.default.any,
/** An `href` passed to the Toggle component */
href: _propTypes.default.string,
/** An `onClick` handler passed to the Toggle component */
onClick: _propTypes.default.func,
/** The content of the non-toggle Button. */
title: _propTypes.default.node.isRequired,
/** Disables both Buttons */
disabled: _propTypes.default.bool,
/**
* Aligns the dropdown menu responsively.
*
* _see [DropdownMenu](#dropdown-menu-props) for more details_
*
* @type {"left"|"right"|{ sm: "left"|"right" }|{ md: "left"|"right" }|{ lg: "left"|"right" }|{ xl: "left"|"right"} }
*/
menuAlign: _DropdownMenu.alignPropType,
/** An ARIA accessible role applied to the Menu component. When set to 'menu', The dropdown */
menuRole: _propTypes.default.string,
/** Whether to render the dropdown menu in the DOM before the first time it is shown */
renderMenuOnMount: _propTypes.default.bool,
/**
* Which event when fired outside the component will cause it to be closed.
*
* _see [DropdownMenu](#dropdown-menu-props) for more details_
*/
rootCloseEvent: _propTypes.default.string,
/** @ignore */
bsPrefix: _propTypes.default.string,
/** @ignore */
variant: _propTypes.default.string,
/** @ignore */
size: _propTypes.default.string
};
/**
* A convenience component for simple or general use dropdowns. Renders a `Button` toggle and all `children`
* are passed directly to the default `Dropdown.Menu`. This component accepts all of
* [`Dropdown`'s props](#dropdown-props).
*
* _All unknown props are passed through to the `Dropdown` component._ Only
* the Button `variant`, `size` and `bsPrefix` props are passed to the toggle,
* along with menu-related props are passed to the `Dropdown.Menu`
*/
var DropdownButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
var title = _ref.title,
children = _ref.children,
bsPrefix = _ref.bsPrefix,
rootCloseEvent = _ref.rootCloseEvent,
variant = _ref.variant,
size = _ref.size,
menuAlign = _ref.menuAlign,
menuRole = _ref.menuRole,
renderMenuOnMount = _ref.renderMenuOnMount,
disabled = _ref.disabled,
href = _ref.href,
id = _ref.id,
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
return /*#__PURE__*/_react.default.createElement(_Dropdown.default, (0, _extends2.default)({
ref: ref
}, props), /*#__PURE__*/_react.default.createElement(_DropdownToggle.default, {
id: id,
href: href,
size: size,
variant: variant,
disabled: disabled,
childBsPrefix: bsPrefix
}, title), /*#__PURE__*/_react.default.createElement(_DropdownMenu.default, {
align: menuAlign,
role: menuRole,
renderOnMount: renderMenuOnMount,
rootCloseEvent: rootCloseEvent
}, children));
});
DropdownButton.displayName = 'DropdownButton';
DropdownButton.propTypes = propTypes;
var _default = DropdownButton;
exports.default = _default;
module.exports = exports["default"];