UNPKG

react-simple-modal-controller

Version:
37 lines (36 loc) 1.25 kB
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; export var modalReducer = function (state, action) { switch (action.type) { case "OPEN": return __spreadArray(__spreadArray([], state, true), [ { id: action.id, Component: action.Component, props: action.props, }, ], false); case "OPEN_ASYNC": return __spreadArray(__spreadArray([], state, true), [ { id: action.id, Component: action.Component, props: action.props, resolve: function (value) { return action.resolver(value); }, }, ], false); case "CLOSE": return state.slice(0, -1); case "CLEAR": return []; default: return state; } };