@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
30 lines (29 loc) • 968 B
JavaScript
import { Button, IconButton } from "@wordpress/ui";
import { jsx, jsxs } from "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__ */ jsx(IconButton, {
icon: action.icon,
label: action.label,
variant: "minimal",
tone: "neutral",
size: "compact",
disabled: isPending,
onClick: () => onRun(action)
});
return /* @__PURE__ */ jsxs(Button, {
variant: "minimal",
tone: compact ? "neutral" : "brand",
size: "compact",
disabled: isPending,
onClick: () => onRun(action),
children: [action.icon && /* @__PURE__ */ jsx(Button.Icon, { icon: action.icon }), action.label]
});
}
export { CallbackAction };
//# sourceMappingURL=callback-action.mjs.map