import React, { HTMLAttributes, useEffect } from "react"; import { UseSelectReturnValue } from "downshift"; import classNames from "classnames"; import { useCunningham } from ":/components/Provider"; import { Field } from ":/components/Forms/Field"; import { LabelledBox } from ":/components/Forms/LabelledBox"; import { Button } from ":/components/Button"; import { Option, SelectProps } from ":/components/Forms/Select/mono"; export function getOptionsFilter(inputValue?: string) { return (option: Option) => { return ( !inputValue || option.label.toLowerCase().includes(inputValue.toLowerCase()) || option.value?.toLowerCase().includes(inputValue.toLowerCase()) ); }; } export const optionToString = (option: Option | null) => { return option ? option.label : ""; }; export const optionToValue = (option: Option) => { return option.value ?? option.label; }; export interface SubProps extends SelectProps { defaultSelectedItem?: Option; downshiftProps: { initialSelectedItem?: Option; onSelectedItemChange?: any; }; } export interface SelectAuxProps extends SubProps { options: Option[]; labelAsPlaceholder: boolean; downshiftReturn: { isOpen: boolean; wrapperProps?: HTMLAttributes; selectedItem?: Option | null; getLabelProps: any; toggleButtonProps: any; getMenuProps: any; getItemProps: any; highlightedIndex: number; selectItem: UseSelectReturnValue