@awsui/components-react
Version:
On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en
23 lines • 1.18 kB
JavaScript
export function getSortedOptions({ options, contentDisplay, }) {
// By using a Map, we are guaranteed to preserve insertion order on future iteration.
const optionsById = new Map();
// We insert contentDisplay first so we respect the currently selected order
for (const { id, visible } of contentDisplay) {
// If an option is provided in contentDisplay and not options, we default the label to the id
optionsById.set(id, { id, label: id, visible });
}
// We merge options data, and insert any that were not in contentDisplay as non-visible
for (const option of options) {
const existing = optionsById.get(option.id);
optionsById.set(option.id, Object.assign(Object.assign({}, option), { visible: !!(existing === null || existing === void 0 ? void 0 : existing.visible) }));
}
return Array.from(optionsById.values());
}
export function getFilteredOptions(options, filterText) {
filterText = filterText.trim().toLowerCase();
if (!filterText) {
return options;
}
return options.filter(option => option.label.toLowerCase().trim().includes(filterText));
}
//# sourceMappingURL=utils.js.map