UNPKG

@react-md/menu

Version:

Create menus that auto-position themselves within the viewport and adhere to the accessibility guidelines

43 lines 2.63 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { Button } from "@react-md/button"; import { IconRotator, TextIconSpacing, useIcon } from "@react-md/icon"; /** * This is just an internal component that handles rendering the button for a * `DropdownMenu` with a conditional dropdown icon. * * @internal * @remarks \@since 5.0.0 */ export var MenuButton = forwardRef(function MenuButton(_a, ref) { var propIcon = _a.icon, _b = _a.iconAfter, iconAfter = _b === void 0 ? true : _b, iconRotatorProps = _a.iconRotatorProps, textIconSpacingProps = _a.textIconSpacingProps, floating = _a.floating, _c = _a.theme, theme = _c === void 0 ? floating ? "secondary" : "clear" : _c, _d = _a.themeType, themeType = _d === void 0 ? floating ? "contained" : "flat" : _d, _e = _a.buttonType, buttonType = _e === void 0 ? floating ? "icon" : "text" : _e, _f = _a.disableDropdownIcon, disableDropdownIcon = _f === void 0 ? buttonType === "icon" : _f, children = _a.children, visible = _a.visible, props = __rest(_a, ["icon", "iconAfter", "iconRotatorProps", "textIconSpacingProps", "floating", "theme", "themeType", "buttonType", "disableDropdownIcon", "children", "visible"]); var dropdownIcon = useIcon("dropdown", propIcon); var icon = propIcon; if (!disableDropdownIcon) { icon = (_jsx(IconRotator, __assign({}, iconRotatorProps, { rotated: visible }, { children: dropdownIcon }))); } return (_jsx(Button, __assign({}, props, { ref: ref, theme: theme, themeType: themeType, buttonType: buttonType, floating: floating }, { children: _jsx(TextIconSpacing, __assign({ icon: icon, iconAfter: iconAfter }, textIconSpacingProps, { children: children })) }))); }); //# sourceMappingURL=MenuButton.js.map