import { DateRange } from 'react-day-picker'; import { PopoverProps } from '../Popover/Popover'; import { RangeDatePickerProps, SingleDatePickerProps } from '../DatePicker/DatePicker.models'; import { MinMaxRange, RangeProps } from '../RangeFilter/RangeFilter'; import { MultiSelectDataItemBase, MultiSelectProps } from '../MultiSelect/MultiSelect'; import { SearchBarProps } from '../SearchBar/SearchBar'; import { SelectProps } from '../Form/Select/Select'; import { ModalProps } from '../ComponentTypes.models'; import { TooltipProps } from '../Tooltip/Tooltip'; export type ExposedFilterNameType = { name: string; }; export type MultiSelectFilterPropsType = Omit, 'callout'>; export type DatePickerFilterPropsType = Omit | Omit; export type FilterValue = FilterType | FilterType[] | Date | DateRange | string | undefined | MinMaxRange; export type ExposedFilterProps = { /** State of filter */ stateName: string; /** Label of the filter */ labelName: string; /** Position of the popover */ position?: PopoverProps['position']; /** To disable closing the popover on scroll */ disableCloseOnScroll?: PopoverProps['disableCloseOnScroll']; /** Function to update filter values */ onChangeCallout?: (stateName: string, value?: FilterValue) => void; /** State to tell if filters are cleared */ isClearFilter?: boolean; /** State to turn off clear filter */ setIsClearFilter?: (value: boolean) => void; /** Custom text to display when no filter values are selected. Defaults to translated "none". */ placeholder?: string; } & ({ /** State to disable the filter */ disabled?: true; /** Tooltip to display when the filter is disabled */ disabledTooltip?: Omit; } | { /** state to enable the filter */ disabled?: false; /** When the filter is not disabled, we need to pass the disabledTooltip prop as undefined */ disabledTooltip?: never; }) & (MultiSelectFilterProps | DateFilterProps | SelectFilterProps | SearchFilterProps | RangeFilterProps | ModalFilterProps); export interface MultiSelectFilterProps { /** Type of filter */ type: 'multi-select'; /** Props for MultiSelect (when type is multi-select) */ multiSelectProps: MultiSelectFilterPropsType; } export interface DateFilterProps { type: 'date'; /** Props for DatePicker (when type is date) */ dateProps: DatePickerFilterPropsType; } export interface SelectFilterProps { type: 'select'; /** Props for Select (when type is select) */ selectProps: { /** Message to display when there are no options available to display */ noOptionsMessage?: string; /** Maximum selectable option popover height - Optional */ maxHeight?: number | string; /** Options for select */ options: SelectProps['options']; /** Selected option - Optional */ selectedOption?: FilterType; }; } export interface SearchFilterProps { type: 'search'; /** Props for SearchBar (when type is search) */ searchBarProps: Omit; } export interface RangeFilterProps { type: 'range'; /** Props for RangeFilter (when type is range) */ rangeProps: RangeProps; } export interface ModalFilterProps { type: 'modal'; openCallout: () => void; selectedOption?: (string | number)[]; /** Props for Modal (when type is modal) */ modalProps: ModalProps; }