@pantheon-systems/design-toolkit-react
Version:
Pantheon's React Design Toolkit
66 lines (63 loc) • 2.83 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { faSpinnerThird } from '@fortawesome/pro-solid-svg-icons';
import { MenuButton } from '@reach/menu-button';
import '@reach/menu-button/styles.css';
import PropTypes from 'prop-types';
import { FAIcon } from '../lib/customPropTypes.js';
import Icon from '../Icons/Icon.js';
import { jsx } from 'react/jsx-runtime';
var _excluded = ["ariaLabel", "disabled", "icon", "isLoading", "size"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var IconDropdownButton = function IconDropdownButton(_ref) {
var ariaLabel = _ref.ariaLabel,
disabled = _ref.disabled,
icon = _ref.icon,
isLoading = _ref.isLoading,
size = _ref.size,
rest = _objectWithoutProperties(_ref, _excluded);
var menuIcon = isLoading ? faSpinnerThird : icon;
return /*#__PURE__*/jsx(MenuButton, _objectSpread(_objectSpread({
"aria-label": ariaLabel,
className: "icon-dropdown-button",
disabled: disabled || isLoading
}, rest), {}, {
children: /*#__PURE__*/jsx(Icon, {
"aria-hidden": true,
icon: menuIcon,
size: size,
spin: isLoading
})
}));
};
IconDropdownButton.defaultProps = {
disabled: false,
isLoading: false,
size: '2x'
};
IconDropdownButton.propTypes = {
/**
* ARIA label that describes the purpose of this button
*/
ariaLabel: PropTypes.string.isRequired,
/**
* Whether the button is in a disabled state or not
*/
disabled: PropTypes.bool,
/**
* Which icon will the button be
*/
icon: FAIcon.isRequired,
/**
* Whether the button is in a loading state or not
*/
isLoading: PropTypes.bool,
/**
* Size of the icon
*/
size: PropTypes.oneOf(['xs', 'sm', 'lg', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x'])
};
var IconDropdownButton$1 = IconDropdownButton;
export { IconDropdownButton$1 as default };
//# sourceMappingURL=IconDropdownButton_DEPRECATED.js.map