import {html} from "../../../../framework/component.js" import {ModalSystem} from "../types/modal-system.js" export function prepareConfirm( popup: ModalSystem["popup"] ): ModalSystem["confirm"] { return async({ title, body = null, yes = {label: "yes", vibe: "positive"}, no = {label: "no", vibe: "neutral"}, focusNthElement = 1, blanketClickMeansNo = true, }) => new Promise(resolve => { popup({ focusNthElement, onBlanketClick: blanketClickMeansNo ? controls => { controls.close() resolve(false) } : () => {}, renderContent: controls => { const onYes = () => { controls.close() resolve(true) } const onNo = () => { controls.close() resolve(false) } return html` ${typeof title == "string" ? html`${title}` : title} ${typeof body == "string" ? html`${body}` : body} ${yes.label} ${no ? html` ${no.label} ` : null} ` }, }) }) }
${body}