UNPKG

piral-modals

Version:

Plugin for the display of modal dialogs in Piral.

32 lines 904 B
import { withKey, withoutKey, prependItem, excludeOn } from 'piral-core'; export function openModal(ctx, dialog) { ctx.dispatch((state) => ({ ...state, modals: prependItem(state.modals, dialog), })); } export function closeModal(ctx, dialog) { ctx.dispatch((state) => ({ ...state, modals: excludeOn(state.modals, (modal) => modal.id === dialog.id), })); } export function registerModal(ctx, name, value) { ctx.dispatch((state) => ({ ...state, registry: { ...state.registry, modals: withKey(state.registry.modals, name, value), }, })); } export function unregisterModal(ctx, name) { ctx.dispatch((state) => ({ ...state, registry: { ...state.registry, modals: withoutKey(state.registry.modals, name), }, })); } //# sourceMappingURL=actions.js.map