UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

35 lines (34 loc) 1.26 kB
import { __rest } from "tslib"; export var flattenOptions = function (options) { var parentMap = new Map(); var flatOptions = options.reduce(function (acc, option) { if ('options' in option) { var options_1 = option.options, rest_1 = __rest(option, ["options"]); var parentDropdownOption_1 = { type: 'parent', option: option }; if (option.disabled) { parentDropdownOption_1.disabled = true; } acc.push(parentDropdownOption_1); options_1.forEach(function (child) { var childDropdownOption = { type: 'child', option: child }; if (rest_1.disabled || child.disabled) { childDropdownOption.disabled = true; } acc.push(childDropdownOption); parentMap.set(childDropdownOption, parentDropdownOption_1); }); } else { var dropdownOption = { option: option }; if (option.disabled) { dropdownOption.disabled = true; } acc.push(dropdownOption); } return acc; }, []); return { flatOptions: flatOptions, parentMap: parentMap }; };