import PlainAlertDialog from 'elix/src/plain/PlainAlertDialog.js' import { template, keydown } from 'elix/src/base/internal.js' import { fragmentFrom } from 'elix/src/core/htmlLiterals.js' /** * @class SePlainAlertDialog */ export default class SePlainAlertDialog extends PlainAlertDialog { /** * @function get * @returns {PlainObject} */ get [template] () { const result = super[template] // Replace the default slot with a new default slot and a button container. const defaultSlot = result.content.querySelector('#frameContent') if (defaultSlot) { defaultSlot.replaceWith(fragmentFrom.html`
`) } result.content.append( fragmentFrom.html` ` ) return result } /** * Tracks if users wants to cancel (close dialog without any changes) with Esc * if null - seConfirm will use responce.choice */ keyChoice = null get [keydown] () { /** * Listens to Esc key to close dialog */ return (e) => { if (e.key === 'Escape') { this.keyChoice = 'Cancel' this.close() } } } } customElements.define('se-elix-alert-dialog', SePlainAlertDialog)