@codeperate/app-asset
Version:
Codeperate App Asset
48 lines (45 loc) • 1.85 kB
JavaScript
import { r as registerInstance, h, H as Host, a as getElement } from './index-6dae2149.js';
import { m as mapStateToProps } from './map-state-to-props-86878b16.js';
const CdpModalRematch = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.modals = [];
this.markedClear = [];
}
componentWillLoad() {
this.unsubscribe = mapStateToProps(this.config.store, this, (state) => ({
modals: state.CdpModalModel.modals,
}));
}
disconnectedCallback() {
if (this.unsubscribe)
this.unsubscribe();
}
markedClearHandler() {
if (this.markedClear.length > 0) {
this.config.store.dispatch.CdpModalModel.clear(this.markedClear);
this.markedClear.splice(0, this.markedClear.length);
}
}
async componentDidUpdate() { }
render() {
const hostClass = 'absolute block top-0 left-0 w-full' + (this.modals.length > 0 ? ' h-full' : '');
const containerClass = 'sticky w-full top-0 left-0' + (this.modals.length > 0 ? ' h-screen' : '');
return (h(Host, { class: hostClass }, h("div", { class: containerClass }, this.modals.map((modal, i) => {
var _a, _b;
return (h("cdp-modal", { 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 { CdpModalRematch as cdp_modal_rematch };