baseui
Version:
A React Component library implementing the Base design language
39 lines (36 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFilteredMonthItems = exports.filterMonthItems = void 0;
var _constants = require("../constants");
/*
Copyright (c) Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
const getDefaultMonthItems = formatMonthLabel => _constants.DEFAULT_MONTHS.map(month => ({
id: month.toString(),
label: formatMonthLabel(month)
}));
const filterMonthItems = (monthItems, filterList) => monthItems.map(month => {
if (!filterList.includes(Number(month.id))) {
return {
...month,
disabled: true
};
}
return month;
});
exports.filterMonthItems = filterMonthItems;
const getFilteredMonthItems = ({
filterMonthsList,
formatMonthLabel
}) => {
let monthItems = getDefaultMonthItems(formatMonthLabel);
if (filterMonthsList) {
monthItems = filterMonthItems(monthItems, filterMonthsList);
}
return monthItems;
};
exports.getFilteredMonthItems = getFilteredMonthItems;