UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

51 lines (50 loc) • 2.6 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let _wordpress_i18n = require("@wordpress/i18n"); let _wordpress_icons = require("@wordpress/icons"); let _wordpress_ui = require("@wordpress/ui"); let react_jsx_runtime = require("react/jsx-runtime"); // packages/widget-dashboard/src/components/actions-menu/actions-menu.tsx function ActionsMenuEntry({ item }) { const showDisabledTooltip = item.disabled && item.disabledTooltip; const menuItem = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Item, { disabled: item.disabled, onClick: item.onClick, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.ItemLabel, { children: item.label }) }); if (!showDisabledTooltip) return menuItem; return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Tooltip.Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Item, { nativeButton: true, disabled: item.disabled, onClick: item.onClick, render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Trigger, {}), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.ItemLabel, { children: item.label }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Popup, { positioner: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Positioner, { side: "bottom" }), children: item.disabledTooltip })] }); } /** * Renders the dashboard's overflow menu: a three-dots trigger surfacing * secondary actions. Returns `null` when there are no items. * * @param {ActionsMenuProps} props Component props. */ function ActionsMenu({ items }) { if (items.length === 0) return null; return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Menu.Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Trigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.IconButton, { icon: _wordpress_icons.moreVertical, label: (0, _wordpress_i18n.__)("More options"), variant: "minimal", tone: "brand", size: "compact" }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Popup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Provider, { delay: 0, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Group, { children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionsMenuEntry, { item }, index)) }) }) })] }); } exports.ActionsMenu = ActionsMenu; //# sourceMappingURL=actions-menu.cjs.map