import { Dropdown, } from '@wix/design-system';
import React from 'react';
import { observer } from 'mobx-react-lite';
import { useWindowFlipPopoverProps } from '../../utils/useWindowFlipPopoverProps';
function _SingleSelectFilterBase(props) {
    const { filter, dropdownSelect, placeholder, onSelect, renderItem, renderSection, clearButton, disabled, options = [], popoverProps, ...rest } = props;
    const { select: { selectedValues }, container: { translate: t }, } = dropdownSelect;
    const { windowFlipPopoverProps, inputRef } = useWindowFlipPopoverProps({
        popoverProps,
    });
    return (React.createElement(Dropdown, { inputRef: (ref) => {
            inputRef.current = ref;
        }, dataHook: `collection-filter-${filter.name}`, border: "round", closeOnSelect: true, options: options, clearButton: clearButton, onClear: clearButton ? dropdownSelect.clear : undefined, onClose: () => {
            dropdownSelect.close();
        }, selectedId: selectedValues[0]?.key, valueParser: (option) => option.label, textOverflow: "ellipsis", placeholder: placeholder ?? t('cairo.selectPlaceholder'), onSelect: (option) => {
            const keyedItem = option?.keyedItem;
            if (keyedItem) {
                dropdownSelect.setSingle(keyedItem);
            }
            onSelect?.(option, false);
        }, popoverProps: windowFlipPopoverProps, ...rest }));
}
export const SingleSelectFilterBase = observer(_SingleSelectFilterBase);
//# sourceMappingURL=SingleSelectFilterBase.js.map