UNPKG

@react-md/menu

Version:

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

46 lines 2.81 kB
"use strict"; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MenuButton = void 0; var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var button_1 = require("@react-md/button"); var icon_1 = require("@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 */ exports.MenuButton = (0, react_1.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 = (0, icon_1.useIcon)("dropdown", propIcon); var icon = propIcon; if (!disableDropdownIcon) { icon = ((0, jsx_runtime_1.jsx)(icon_1.IconRotator, __assign({}, iconRotatorProps, { rotated: visible }, { children: dropdownIcon }))); } return ((0, jsx_runtime_1.jsx)(button_1.Button, __assign({}, props, { ref: ref, theme: theme, themeType: themeType, buttonType: buttonType, floating: floating }, { children: (0, jsx_runtime_1.jsx)(icon_1.TextIconSpacing, __assign({ icon: icon, iconAfter: iconAfter }, textIconSpacingProps, { children: children })) }))); }); //# sourceMappingURL=MenuButton.js.map