mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
103 lines
3.4 KiB
JavaScript
103 lines
3.4 KiB
JavaScript
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
||
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||
|
var _excluded = ["title", "children", "bsPrefix", "rootCloseEvent", "variant", "size", "menuAlign", "menuRole", "renderMenuOnMount", "disabled", "href", "id"];
|
||
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import Dropdown from './Dropdown';
|
||
|
import DropdownToggle from './DropdownToggle';
|
||
|
import DropdownMenu, { 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,
|
||
|
|
||
|
/** An `href` passed to the Toggle component */
|
||
|
href: PropTypes.string,
|
||
|
|
||
|
/** An `onClick` handler passed to the Toggle component */
|
||
|
onClick: PropTypes.func,
|
||
|
|
||
|
/** The content of the non-toggle Button. */
|
||
|
title: PropTypes.node.isRequired,
|
||
|
|
||
|
/** 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
|
||
|
};
|
||
|
/**
|
||
|
* 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.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 = _objectWithoutPropertiesLoose(_ref, _excluded);
|
||
|
|
||
|
return /*#__PURE__*/React.createElement(Dropdown, _extends({
|
||
|
ref: ref
|
||
|
}, props), /*#__PURE__*/React.createElement(DropdownToggle, {
|
||
|
id: id,
|
||
|
href: href,
|
||
|
size: size,
|
||
|
variant: variant,
|
||
|
disabled: disabled,
|
||
|
childBsPrefix: bsPrefix
|
||
|
}, title), /*#__PURE__*/React.createElement(DropdownMenu, {
|
||
|
align: menuAlign,
|
||
|
role: menuRole,
|
||
|
renderOnMount: renderMenuOnMount,
|
||
|
rootCloseEvent: rootCloseEvent
|
||
|
}, children));
|
||
|
});
|
||
|
DropdownButton.displayName = 'DropdownButton';
|
||
|
DropdownButton.propTypes = propTypes;
|
||
|
export default DropdownButton;
|