UNPKG

@wordpress/widget-dashboard

Version:

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

93 lines (91 loc) • 3.72 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/widget-dashboard/src/components/actions-menu/actions-menu.tsx var actions_menu_exports = {}; __export(actions_menu_exports, { ActionsMenu: () => ActionsMenu }); module.exports = __toCommonJS(actions_menu_exports); var import_components = require("@wordpress/components"); var import_i18n = require("@wordpress/i18n"); var import_icons = require("@wordpress/icons"); var import_ui = require("@wordpress/ui"); var import_lock_unlock = require("../../lock-unlock.cjs"); var import_jsx_runtime = require("react/jsx-runtime"); var { Menu } = (0, import_lock_unlock.unlock)(import_components.privateApis); function ActionsMenuEntry({ item }) { const showDisabledTooltip = item.disabled && item.disabledTooltip; const menuItem = /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Menu.Item, { disabled: item.disabled, onClick: item.onClick, render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Button, { variant: "minimal", tone: "neutral" }), children: item.label } ); if (!showDisabledTooltip) { return menuItem; } return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Tooltip.Root, { children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_ui.Tooltip.Trigger, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Menu.Item, { disabled: item.disabled, onClick: item.onClick, render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Button, { variant: "minimal", tone: "neutral" }) } ), children: item.label } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Popup, { positioner: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Positioner, { side: "bottom" }), children: item.disabledTooltip }) ] }); } function ActionsMenu({ items }) { if (items.length === 0) { return null; } return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Menu, { children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Menu.TriggerButton, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_ui.IconButton, { icon: import_icons.moreVertical, label: (0, import_i18n.__)("More options"), variant: "minimal", tone: "brand", size: "compact" } ) } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Group, { children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionsMenuEntry, { item }, index)) }) }) }) ] }); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ActionsMenu }); //# sourceMappingURL=actions-menu.cjs.map