@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
1 lines • 2.35 kB
Source Map (JSON)
{"version":3,"file":"reset-confirmation.cjs","names":["useDashboardInternalContext","useDashboardUIContext","AlertDialog","__"],"sources":["../../../src/components/reset-confirmation/reset-confirmation.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport {\n\t// eslint-disable-next-line @wordpress/use-recommended-components\n\tAlertDialog,\n} 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":";;;;;;;;;;;;;;;;;;AAeA,SAAgB,oBAAqC;CACpD,MAAM,EAAE,eAAe,cAAc,gBAAA,GACpCA,oCAAAA,4BAAAA,CAA4B;CAC7B,MAAM,EAAE,iBAAiB,wBAAA,GAAuBC,6BAAAA,sBAAAA,CAAsB;CAEtE,IAAK,CAAE,WAAY,EAAE,WAAW,QAAQ,CAAE,GACzC,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,YAAY,MAAb;EACC,MAAO;EACP,cAAe;EACf,WAAY,YAAY;GACvB,MAAM,gBAAgB;GACtB,eAAgB,KAAM;GACtB,mBAAoB,KAAM;EAC3B;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,YAAY,OAAb;GACC,QAAO;GACP,QAAA,GAAQC,gBAAAA,GAAAA,CAAI,6BAA8B;GAC1C,cAAA,GAAcA,gBAAAA,GAAAA,CACb,8CACD;GACA,oBAAA,GAAoBA,gBAAAA,GAAAA,CAAI,OAAQ;EAChC,CAAA;CACgB,CAAA;AAEpB"}