cosmo-ui
Version:
Common React components
29 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var constants_1 = require("../constants");
exports.initiaDropdownState = {
// it's not neccessary to pre initialize dropdowns
// you can just start using them with a unique key
// or for the sake of safety you could reserve a key here
jobsSearchTypeDropdown: false,
};
exports.dropdownReducer = function (state, action) {
if (state === void 0) { state = exports.initiaDropdownState; }
switch (action.type) {
case constants_1.OPEN_DROPDOWN: {
return tslib_1.__assign({}, state, (_a = {}, _a[action.key] = true, _a));
}
case constants_1.CLOSE_DROPDOWN: {
return tslib_1.__assign({}, state, (_b = {}, _b[action.key] = false, _b));
}
case constants_1.TOGGLE_DROPDOWN: {
return tslib_1.__assign({}, state, (_c = {}, _c[action.key] = !state[action.key], _c));
}
default: {
return state;
}
}
var _a, _b, _c;
};
//# sourceMappingURL=dropdown.js.map