mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
137 lines
4.3 KiB
JavaScript
137 lines
4.3 KiB
JavaScript
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
||
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||
|
var _excluded = ["id", "bsPrefix", "size", "variant", "title", "type", "toggleLabel", "children", "onClick", "href", "target", "menuAlign", "menuRole", "renderMenuOnMount", "rootCloseEvent"];
|
||
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import Button from './Button';
|
||
|
import ButtonGroup from './ButtonGroup';
|
||
|
import Dropdown from './Dropdown';
|
||
|
import { alignPropType } from './DropdownMenu';
|
||
|
var propTypes = {
|
||
|
/**
|
||
|
* An html id attribute for the Toggle button, necessary for assistive technologies, such as screen readers.
|
||
|
* @type {string|number}
|
||
|
* @required
|
||
|
*/
|
||
|
id: PropTypes.any,
|
||
|
|
||
|
/**
|
||
|
* Accessible label for the toggle; the value of `title` if not specified.
|
||
|
*/
|
||
|
toggleLabel: PropTypes.string,
|
||
|
|
||
|
/** An `href` passed to the non-toggle Button */
|
||
|
href: PropTypes.string,
|
||
|
|
||
|
/** An anchor `target` passed to the non-toggle Button */
|
||
|
target: PropTypes.string,
|
||
|
|
||
|
/** An `onClick` handler passed to the non-toggle Button */
|
||
|
onClick: PropTypes.func,
|
||
|
|
||
|
/** The content of the non-toggle Button. */
|
||
|
title: PropTypes.node.isRequired,
|
||
|
|
||
|
/** A `type` passed to the non-toggle Button */
|
||
|
type: PropTypes.string,
|
||
|
|
||
|
/** Disables both Buttons */
|
||
|
disabled: PropTypes.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: alignPropType,
|
||
|
|
||
|
/** An ARIA accessible role applied to the Menu component. When set to 'menu', The dropdown */
|
||
|
menuRole: PropTypes.string,
|
||
|
|
||
|
/** Whether to render the dropdown menu in the DOM before the first time it is shown */
|
||
|
renderMenuOnMount: PropTypes.bool,
|
||
|
|
||
|
/**
|
||
|
* Which event when fired outside the component will cause it to be closed.
|
||
|
*
|
||
|
* _see [DropdownMenu](#dropdown-menu-props) for more details_
|
||
|
*/
|
||
|
rootCloseEvent: PropTypes.string,
|
||
|
|
||
|
/** @ignore */
|
||
|
bsPrefix: PropTypes.string,
|
||
|
|
||
|
/** @ignore */
|
||
|
variant: PropTypes.string,
|
||
|
|
||
|
/** @ignore */
|
||
|
size: PropTypes.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.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 = _objectWithoutPropertiesLoose(_ref, _excluded);
|
||
|
|
||
|
return /*#__PURE__*/React.createElement(Dropdown, _extends({
|
||
|
ref: ref
|
||
|
}, props, {
|
||
|
as: ButtonGroup
|
||
|
}), /*#__PURE__*/React.createElement(Button, {
|
||
|
size: size,
|
||
|
variant: variant,
|
||
|
disabled: props.disabled,
|
||
|
bsPrefix: bsPrefix,
|
||
|
href: href,
|
||
|
target: target,
|
||
|
onClick: onClick,
|
||
|
type: type
|
||
|
}, title), /*#__PURE__*/React.createElement(Dropdown.Toggle, {
|
||
|
split: true,
|
||
|
id: id ? id.toString() : undefined,
|
||
|
size: size,
|
||
|
variant: variant,
|
||
|
disabled: props.disabled,
|
||
|
childBsPrefix: bsPrefix
|
||
|
}, /*#__PURE__*/React.createElement("span", {
|
||
|
className: "sr-only"
|
||
|
}, toggleLabel)), /*#__PURE__*/React.createElement(Dropdown.Menu, {
|
||
|
align: menuAlign,
|
||
|
role: menuRole,
|
||
|
renderOnMount: renderMenuOnMount,
|
||
|
rootCloseEvent: rootCloseEvent
|
||
|
}, children));
|
||
|
});
|
||
|
SplitButton.propTypes = propTypes;
|
||
|
SplitButton.defaultProps = defaultProps;
|
||
|
SplitButton.displayName = 'SplitButton';
|
||
|
export default SplitButton;
|