@codeperate/app-asset
Version:
Codeperate App Asset
47 lines (42 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
const index = require('./index-9f7d7390.js');
const cdpModal_store = require('./cdp-modal.store-79fc4a27.js');
require('./index-65ce289a.js');
const CdpModalStore = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.markedClear = [];
}
disconnectedCallback() {
if (this.unsubscribe)
this.unsubscribe();
}
markedClearHandler() {
if (this.markedClear.length > 0) {
for (const num of this.markedClear)
cdpModal_store.state.modals.splice(num, 1);
this.markedClear.splice(0, this.markedClear.length);
}
}
render() {
const hostClass = 'absolute block top-0 left-0 w-full' + (cdpModal_store.state.modals.length > 0 ? ' h-full' : '');
const containerClass = 'sticky w-full top-0 left-0' + (cdpModal_store.state.modals.length > 0 ? ' h-screen' : '');
return (index.h(index.Host, { class: hostClass }, index.h("div", { class: containerClass }, cdpModal_store.state.modals.map((modal, i) => {
var _a, _b;
return (index.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 index.getElement(this); }
static get watchers() { return {
"markedClear": ["markedClearHandler"]
}; }
};
exports.cdp_modal_store = CdpModalStore;