@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
8 lines (7 loc) • 2.3 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/reset-confirmation/reset-confirmation.tsx"],
"sourcesContent": ["import { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { AlertDialog } from '@wordpress/ui';\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\n\n/**\n * Confirmation prompt for resetting the dashboard to its default layout,\n * mounted by the engine and shown while `resetDialogOpen` is set in the\n * shared UI context. Confirming runs `onLayoutReset` and leaves customize\n * mode. Renders nothing while the policy denies `reset`, so no trigger can\n * reach the handler around the hidden entry points.\n */\nexport function ResetConfirmation(): React.ReactNode {\n\tconst { onLayoutReset, onEditChange, canPerform } =\n\t\tuseDashboardInternalContext();\n\tconst { resetDialogOpen, setResetDialogOpen } = useDashboardUIContext();\n\n\tif ( ! canPerform( { operation: 'reset' } ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AlertDialog.Root\n\t\t\topen={ resetDialogOpen }\n\t\t\tonOpenChange={ setResetDialogOpen }\n\t\t\tonConfirm={ async () => {\n\t\t\t\tawait onLayoutReset?.();\n\t\t\t\tonEditChange?.( false );\n\t\t\t\tsetResetDialogOpen( false );\n\t\t\t} }\n\t\t>\n\t\t\t<AlertDialog.Popup\n\t\t\t\tintent=\"irreversible\"\n\t\t\t\ttitle={ __( 'Reset dashboard to default?' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'All customizations will be permanently lost.'\n\t\t\t\t) }\n\t\t\t\tconfirmButtonText={ __( 'Reset' ) }\n\t\t\t/>\n\t\t</AlertDialog.Root>\n\t);\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AAEnB,gBAA4B;AAC5B,+BAA4C;AAC5C,wBAAsC;AA4BnC;AAnBI,SAAS,oBAAqC;AACpD,QAAM,EAAE,eAAe,cAAc,WAAW,QAC/C,sDAA4B;AAC7B,QAAM,EAAE,iBAAiB,mBAAmB,QAAI,yCAAsB;AAEtE,MAAK,CAAE,WAAY,EAAE,WAAW,QAAQ,CAAE,GAAI;AAC7C,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC,sBAAY;AAAA,IAAZ;AAAA,MACA,MAAO;AAAA,MACP,cAAe;AAAA,MACf,WAAY,YAAY;AACvB,cAAM,gBAAgB;AACtB,uBAAgB,KAAM;AACtB,2BAAoB,KAAM;AAAA,MAC3B;AAAA,MAEA;AAAA,QAAC,sBAAY;AAAA,QAAZ;AAAA,UACA,QAAO;AAAA,UACP,WAAQ,gBAAI,6BAA8B;AAAA,UAC1C,iBAAc;AAAA,YACb;AAAA,UACD;AAAA,UACA,uBAAoB,gBAAI,OAAQ;AAAA;AAAA,MACjC;AAAA;AAAA,EACD;AAEF;",
"names": []
}