@react-md/menu
Version:
Create menus that auto-position themselves within the viewport and adhere to the accessibility guidelines
60 lines • 2.38 kB
JavaScript
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 { KeyboardMovementProvider } from "@react-md/utils";
import { MenuBarProvider } from "./MenuBarProvider";
import { MenuBarWidget } from "./MenuBarWidget";
/**
* The `MenuBar` component is used to link child `DropdownGroup`s' visibility
* together and following the specs for a
* [menubar](https://www.w3.org/TR/wai-aria-practices/#menu).
*
* @example
* Simple Example
* ```tsx
* import type { ReactElement } from "react";
* import { MenuBar, DropdownMenu, MenuItem } from "@react-md/menu";
*
* function Example(): ReactElement {
* return (
* <MenuBar aria-label="Example">
* <DropdownMenu id="menubar-item-1" buttonChildren="Item 1">
* <MenuItem>Sub-item 1</MenuItem>
* <MenuItem>Sub-item 2</MenuItem>
* </DropdownMenu>
* <DropdownMenu id="menubar-item-2" buttonChildren="Item 2">
* <MenuItem>Sub-item 1</MenuItem>
* <MenuItem>Sub-item 2</MenuItem>
* </DropdownMenu>
* </MenuBar>
* );
* }
* ```
*
* @remarks \@since 5.0.0
*/
export function MenuBar(_a) {
var hoverTimeout = _a.hoverTimeout, props = __rest(_a, ["hoverTimeout"]);
return (_jsx(MenuBarProvider, __assign({ hoverTimeout: hoverTimeout }, { children: _jsx(KeyboardMovementProvider, __assign({ loopable: true, searchable: true, incrementKeys: ["ArrowRight"], decrementKeys: ["ArrowLeft"] }, { children: _jsx(MenuBarWidget, __assign({}, props)) })) })));
}
//# sourceMappingURL=MenuBar.js.map