UNPKG

@kelvininc/ui-components

Version:
13 lines (12 loc) 699 B
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}`; };