@kelvininc/ui-components
Version:
Kelvin UI Components
13 lines (12 loc) • 699 B
JavaScript
import { getSelectedSelectableOptions } from "../../utils/select.helper";
import { BADGE_MINIMUM_OPTIONS } from "./multi-select-dropdown.config";
export const getDropdownDisplayValue = (options = {}, selectedOptions = {}) => {
const [firstOption] = Object.values(getSelectedSelectableOptions(options, selectedOptions));
return firstOption === null || firstOption === void 0 ? void 0 : firstOption.label;
};
export const getBadgeLabelValue = (selectedOptions = {}) => {
const selectedOptionsCount = Object.keys(selectedOptions).filter(key => selectedOptions[key]).length;
if (selectedOptionsCount < BADGE_MINIMUM_OPTIONS)
return;
return `+${selectedOptionsCount - 1}`;
};