@octopusdeploy/design-system-components
Version:
The design systems component library.
28 lines (27 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Select = Select;
const jsx_runtime_1 = require("react/jsx-runtime");
const SelectBase_1 = require("./SelectBase");
const SelectOption_1 = require("./SelectOption");
/**
* Select component
*
* @remarks Rollout currently paused — do not use in new code until further notice.
* Use `<DeprecatedSelect>` instead.
* @see <DeprecatedSelect> from @octopusdeploy/design-system-octopus-components
*
* @param props - SelectProps
* @param props.value - The current value of the select
* @param props.onChange - The action to perform when the form control field is changed.
*/
function Select(props) {
const handleOptionsSelected = (options) => {
props.onChange(options[0].value);
};
const renderOption = (option, selected) => (0, jsx_runtime_1.jsx)(SelectOption_1.SelectOption, { option: option, selected: selected });
const renderSelection = (selectedOptions) => ((0, SelectBase_1.isMissingSelectedOption)(selectedOptions[0]) ? "" : selectedOptions[0].label);
return ((0, jsx_runtime_1.jsx)(SelectBase_1.SelectBase, { ...props, isMultiSelectable: false, renderOption: renderOption, onOptionsSelected: handleOptionsSelected, renderSelection: renderSelection, clearSelection: () => {
props.onChange(undefined);
} }));
}