UNPKG

@codeperate/app-asset

Version:

Codeperate App Asset

43 lines (40 loc) 1.67 kB
import { r as registerInstance, h, H as Host, a as getElement } from './index-6dae2149.js'; import { s as state } from './cdp-modal.store-520f16b7.js'; import './index-d7fb7133.js'; const CdpModalStore = class { constructor(hostRef) { registerInstance(this, hostRef); this.markedClear = []; } disconnectedCallback() { if (this.unsubscribe) this.unsubscribe(); } markedClearHandler() { if (this.markedClear.length > 0) { for (const num of this.markedClear) state.modals.splice(num, 1); this.markedClear.splice(0, this.markedClear.length); } } render() { const hostClass = 'absolute block top-0 left-0 w-full' + (state.modals.length > 0 ? ' h-full' : ''); const containerClass = 'sticky w-full top-0 left-0' + (state.modals.length > 0 ? ' h-screen' : ''); return (h(Host, { class: hostClass }, h("div", { class: containerClass }, state.modals.map((modal, i) => { var _a, _b; return (h("cdp-modal", { key: i, props: { display: modal.close ? false : true }, config: (_a = modal.config) !== null && _a !== void 0 ? _a : (_b = this.config) === null || _b === void 0 ? void 0 : _b.defaultModalConfig, onClosed: e => { this.markedClear = [...this.markedClear, i]; if (modal.onClosed) modal.onClosed(e); }, onOpened: e => { if (modal.onOpened) modal.onOpened(e); } }, (() => modal.content)())); })))); } get rootEl() { return getElement(this); } static get watchers() { return { "markedClear": ["markedClearHandler"] }; } }; export { CdpModalStore as cdp_modal_store };