/** * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ // Wrapper for "react-select" component // API docs: https://react-select.com/ import "./select.scss"; import React from "react"; import type { ObservableSet } from "mobx"; import { action, computed, makeObservable } from "mobx"; import { observer } from "mobx-react"; import ReactSelect, { components, createFilter } from "react-select"; import type { Props as ReactSelectProps, GroupBase, MultiValue, OptionsOrGroups, PropsValue, SingleValue } from "react-select"; import type { ThemeStore } from "../../themes/store"; import { autoBind, cssNames } from "../../utils"; import { withInjectables } from "@ogre-tools/injectable-react"; import themeStoreInjectable from "../../themes/store.injectable"; const { Menu } = components; export interface SelectOption { value: Value; label: React.ReactNode; isDisabled?: boolean; isSelected?: boolean; id?: string; } /** * @deprecated This should not be used anymore, convert the options yourself. */ export type LegacyAutoConvertedOptions = string[]; export interface SelectProps< Value, /** * This needs to extend `object` because even though `ReactSelectProps` allows for any `T`, the * maintainers of `react-select` says that they don't support it. * * Ref: https://github.com/JedWatson/react-select/issues/5032 * * Futhermore, we mandate the option is of this shape because it is easier than requiring * `getOptionValue` and `getOptionLabel` all over the place. */ Option extends SelectOption, IsMulti extends boolean, Group extends GroupBase