UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

20 lines 850 B
/** * * @param option ComboboxOption will be compared by both label and value, while a string option is checked if it matches either the label or value in the list. * @param list */ const isInList = (option, list) => { if (typeof option === "string") { return list.some((listItem) => listItem.label === option || listItem.value === option); } return list.some((listItem) => listItem.label === option.label && listItem.value === option.value); }; const toComboboxOption = (value) => ({ label: value, value, }); const mapToComboboxOptionArray = (options) => { return options === null || options === void 0 ? void 0 : options.map((option) => typeof option === "string" ? toComboboxOption(option) : option); }; export { isInList, mapToComboboxOptionArray, toComboboxOption }; //# sourceMappingURL=combobox-utils.js.map