/* eslint-disable */ // @ts-nocheck import { ChipGroupProps, SelectProps } from "../../../@patternfly/react-core"; import { ControllerProps, FieldPath, FieldValues, UseControllerProps, } from "react-hook-form"; import { SingleSelectControl } from "./SingleSelectControl"; import { TypeaheadSelectControl } from "./TypeaheadSelectControl"; import { ReactNode } from "react"; type Variant = `${SelectVariant}`; export enum SelectVariant { single = "single", typeahead = "typeahead", typeaheadMulti = "typeaheadMulti", } export type SelectControlOption = { key: string; value: string; description?: string; }; export type OptionType = string[] | SelectControlOption[]; export type SelectControlProps< T extends FieldValues, P extends FieldPath = FieldPath, > = Omit< SelectProps, | "name" | "toggle" | "selections" | "onSelect" | "onClear" | "isOpen" | "onFilter" | "variant" > & UseControllerProps & { name: string; label?: string; options: OptionType; selectedOptions?: OptionType; labelIcon?: string | ReactNode; controller: Omit; onFilter?: (value: string) => void; variant?: Variant; isDisabled?: boolean; isFullWidth?: boolean; menuAppendTo?: string; placeholderText?: string; chipGroupProps?: ChipGroupProps; onSelect?: ( value: string | string[], onChangeHandler: (value: string | string[]) => void, ) => void; }; export const isSelectBasedOptions = ( options: OptionType, ): options is SelectControlOption[] => typeof options[0] !== "string"; export const isString = ( option: SelectControlOption | string, ): option is string => typeof option === "string"; export const key = (option: SelectControlOption | string) => isString(option) ? option : option.key; export const SelectControl = < T extends FieldValues, P extends FieldPath = FieldPath, >({ variant = SelectVariant.single, ...rest }: SelectControlProps) => variant === SelectVariant.single ? ( ) : ( );