UNPKG

svelte-dialog

Version:

Vanilla JS dialog services and components made with Svelte.

14 lines (12 loc) 454 B
const makeFunctionAPI = (DialogComponent) => { function dialog (options) { const dialogComponent = new DialogComponent({ data: options, target: document.body }) dialogComponent.on('hidden', () => dialogComponent.destroy()) return Object.assign( new Promise(resolve => dialogComponent.on('result', resolve)), { dialog: dialogComponent } ) } return Object.assign(dialog, DialogComponent) } export default makeFunctionAPI