UNPKG

@wordpress/widget-dashboard

Version:

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

41 lines (40 loc) • 1.9 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let _wordpress_i18n = require("@wordpress/i18n"); let _wordpress_ui = require("@wordpress/ui"); let ______context_dashboard_context_tsx = require("../../context/dashboard-context.cjs"); let ______context_ui_context_tsx = require("../../context/ui-context.cjs"); let react_jsx_runtime = require("react/jsx-runtime"); // packages/widget-dashboard/src/components/reset-confirmation/reset-confirmation.tsx /** * Confirmation prompt for resetting the dashboard to its default layout, * mounted by the engine and shown while `resetDialogOpen` is set in the * shared UI context. Confirming runs `onLayoutReset` and leaves customize * mode. Renders nothing while the policy denies `reset`, so no trigger can * reach the handler around the hidden entry points. */ function ResetConfirmation() { const { onLayoutReset, onEditChange, canPerform } = (0, ______context_dashboard_context_tsx.useDashboardInternalContext)(); const { resetDialogOpen, setResetDialogOpen } = (0, ______context_ui_context_tsx.useDashboardUIContext)(); if (!canPerform({ operation: "reset" })) return null; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.AlertDialog.Root, { open: resetDialogOpen, onOpenChange: setResetDialogOpen, onConfirm: async () => { await onLayoutReset?.(); onEditChange?.(false); setResetDialogOpen(false); }, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.AlertDialog.Popup, { intent: "irreversible", title: (0, _wordpress_i18n.__)("Reset dashboard to default?"), description: (0, _wordpress_i18n.__)("All customizations will be permanently lost."), confirmButtonText: (0, _wordpress_i18n.__)("Reset") }) }); } exports.ResetConfirmation = ResetConfirmation; //# sourceMappingURL=reset-confirmation.cjs.map