@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
35 lines (34 loc) • 1.22 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_ui = require("@wordpress/ui");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/widget-dashboard/src/components/widget-actions/callback-action.tsx
/**
* A callback action as a button, disabled while its promise settles.
*
* @param {CallbackActionProps} props Component props.
*/
function CallbackAction({ action, isPending, onRun, compact = false }) {
if (compact && action.icon) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.IconButton, {
icon: action.icon,
label: action.label,
variant: "minimal",
tone: "neutral",
size: "compact",
disabled: isPending,
onClick: () => onRun(action)
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Button, {
variant: "minimal",
tone: compact ? "neutral" : "brand",
size: "compact",
disabled: isPending,
onClick: () => onRun(action),
children: [action.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Button.Icon, { icon: action.icon }), action.label]
});
}
exports.CallbackAction = CallbackAction;
//# sourceMappingURL=callback-action.cjs.map