@codeperate/app-asset
Version:
Codeperate App Asset
44 lines (41 loc) • 1.3 kB
JavaScript
import { c as createStore } from './index-d7fb7133.js';
let cdpModalStore;
const cdpModalStore$1 = cdpModalStore;
let state;
function init() {
cdpModalStore = createStore({
modals: [],
});
state = cdpModalStore.state;
}
function clear(payload) {
for (const num of payload)
state.modals.splice(num, 1);
state.modals = [...state.modals];
}
function pushModal(payload) {
state.modals = [...state.modals, payload];
}
function popModal() {
state.modals = state.modals.filter((_, i) => i != state.modals.length - 1);
}
function popAllModal() {
state.modals = [];
}
function closeModal() {
if (state.modals[state.modals.length - 1])
state.modals[state.modals.length - 1].close = true;
state.modals = [...state.modals];
}
function closeAllModal() {
for (const modal of state.modals)
modal.close = true;
state.modals = [...state.modals];
}
function popModalByTag(payload) {
for (let i = 0; i < state.modals.length; i++)
if (Object.values(state.modals[i].content).includes(payload))
state.modals.splice(i, 1);
state.modals = [...state.modals];
}
export { clear as a, popAllModal as b, cdpModalStore$1 as c, popModal as d, popModalByTag as e, closeAllModal as f, closeModal as g, init as i, pushModal as p, state as s };