UNPKG

@trellixio/roaster-coffee

Version:
48 lines (47 loc) 1.59 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; function handleCloseModal(modal) { var _a, _b; (_b = (_a = modal.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a); } export function modalReducer(state, action) { switch (action.type) { case 'OPEN': { return Object.assign({}, action.modal); } case 'CLOSE': { handleCloseModal(state); return null; } default: { return state; } } } export function getModalProviderFooterProps(props) { if (!props) { return { footerProps: {}, modalProps: {} }; } const { onCancel, onConfirm, closeOnConfirm, closeOnCancel, cancelProps, confirmProps, labels } = props, others = __rest(props, ["onCancel", "onConfirm", "closeOnConfirm", "closeOnCancel", "cancelProps", "confirmProps", "labels"]); return { footerProps: { onCancel, onConfirm, closeOnConfirm, closeOnCancel, cancelProps, confirmProps, labels, }, modalProps: Object.assign({}, others), }; }