@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
30 lines (29 loc) • 893 B
JavaScript
"use client";
//#region packages/@mantine/core/src/components/Combobox/get-parsed-combobox-data/get-parsed-combobox-data.ts
function parseItem(item) {
if (typeof item === "string") return {
value: item,
label: item
};
if (typeof item === "object" && "value" in item && !("label" in item)) return {
value: item.value,
label: `${item.value}`,
disabled: item.disabled
};
if (typeof item === "object" && "group" in item) return {
group: item.group,
items: item.items.map((i) => parseItem(i))
};
if (typeof item === "number" || typeof item === "bigint" || typeof item === "boolean") return {
value: item,
label: `${item}`
};
return item;
}
function getParsedComboboxData(data) {
if (!data) return [];
return data.map((item) => parseItem(item));
}
//#endregion
exports.getParsedComboboxData = getParsedComboboxData;
//# sourceMappingURL=get-parsed-combobox-data.cjs.map