Popconfirm

Molecule

"Are you sure?" confirmation popover: trigger + absolutely-positioned alertdialog panel with title, optional description, and Cancel/Confirm buttons. Built standalone (not a Popover wrapper). Since EJS cannot take a JS closure, confirming or cancelling dispatches a `popconfirm:confirm` / `popconfirm:cancel` CustomEvent on the root element for the host page to listen for.

Default

Preview
Code
<%- include('modules/ui/Popconfirm', {
  trigger: '<button type="button">Delete item</button>',
  title: 'Delete this item?',
  description: 'This action cannot be undone.',
}) %>

Danger + custom labels

Preview
Code
<%- include('modules/ui/Popconfirm', {
  danger: true,
  trigger: '<button type="button">Remove account</button>',
  title: 'Permanently remove this account?',
  description: 'All data associated with this account will be deleted.',
  confirmLabel: 'Remove',
  cancelLabel: 'Keep account',
  confirmAction: 'removeAccount()',
}) %>

<script>
document.getElementById('my-popconfirm').addEventListener('popconfirm:confirm', function (ev) {
  // ev.detail.id === 'my-popconfirm'
});
</script>
Source modules/ui/Popconfirm.ejs