import { Controller } from '@hotwired/stimulus'; export default class ModalController extends Controller { static values = { rootSelector: String, contentSelector: String, title: String, size: String, }; async closeModal() { const { render } = await import('preact'); const modalRoot = document.querySelector(this.rootSelectorValue); render(null, modalRoot); } async toggleModal() { const [{ Modal }, { render, h }] = await Promise.all([ import('@crayons/Modal'), import('preact'), ]); const modalRoot = document.querySelector(this.rootSelectorValue); render( this.closeModal()} size={this.sizeValue} >
, modalRoot, ); } }