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

154 lines
5.0 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 _Button = _interopRequireDefault(require("./Button"));
var _ButtonGroup = _interopRequireDefault(require("./ButtonGroup"));
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
var _DropdownMenu = require("./DropdownMenu");
var _excluded = ["id", "bsPrefix", "size", "variant", "title", "type", "toggleLabel", "children", "onClick", "href", "target", "menuAlign", "menuRole", "renderMenuOnMount", "rootCloseEvent"];
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,
/**
* Accessible label for the toggle; the value of `title` if not specified.
*/
toggleLabel: _propTypes.default.string,
/** An `href` passed to the non-toggle Button */
href: _propTypes.default.string,
/** An anchor `target` passed to the non-toggle Button */
target: _propTypes.default.string,
/** An `onClick` handler passed to the non-toggle Button */
onClick: _propTypes.default.func,
/** The content of the non-toggle Button. */
title: _propTypes.default.node.isRequired,
/** A `type` passed to the non-toggle Button */
type: _propTypes.default.string,
/** 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
};
var defaultProps = {
toggleLabel: 'Toggle dropdown',
type: 'button'
};
/**
* A convenience component for simple or general use split button dropdowns. Renders a
* `ButtonGroup` containing a `Button` and a `Button` toggle for the `Dropdown`. 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._
* The Button `variant`, `size` and `bsPrefix` props are passed to the button and toggle,
* and menu-related props are passed to the `Dropdown.Menu`
*/
var SplitButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
var id = _ref.id,
bsPrefix = _ref.bsPrefix,
size = _ref.size,
variant = _ref.variant,
title = _ref.title,
type = _ref.type,
toggleLabel = _ref.toggleLabel,
children = _ref.children,
onClick = _ref.onClick,
href = _ref.href,
target = _ref.target,
menuAlign = _ref.menuAlign,
menuRole = _ref.menuRole,
renderMenuOnMount = _ref.renderMenuOnMount,
rootCloseEvent = _ref.rootCloseEvent,
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
return /*#__PURE__*/_react.default.createElement(_Dropdown.default, (0, _extends2.default)({
ref: ref
}, props, {
as: _ButtonGroup.default
}), /*#__PURE__*/_react.default.createElement(_Button.default, {
size: size,
variant: variant,
disabled: props.disabled,
bsPrefix: bsPrefix,
href: href,
target: target,
onClick: onClick,
type: type
}, title), /*#__PURE__*/_react.default.createElement(_Dropdown.default.Toggle, {
split: true,
id: id ? id.toString() : undefined,
size: size,
variant: variant,
disabled: props.disabled,
childBsPrefix: bsPrefix
}, /*#__PURE__*/_react.default.createElement("span", {
className: "sr-only"
}, toggleLabel)), /*#__PURE__*/_react.default.createElement(_Dropdown.default.Menu, {
align: menuAlign,
role: menuRole,
renderOnMount: renderMenuOnMount,
rootCloseEvent: rootCloseEvent
}, children));
});
SplitButton.propTypes = propTypes;
SplitButton.defaultProps = defaultProps;
SplitButton.displayName = 'SplitButton';
var _default = SplitButton;
exports.default = _default;
module.exports = exports["default"];