import { useMemo } from 'react';
import { useDropdownTranslationContext } from '../providers';
export function useDropdownPlaceholder({ dropdownSelect, filter, shouldShowPlaceholder, isOverflow, placeholderProp, }) {
    const { select: { selectedValues }, container, } = dropdownSelect;
    const { translate } = useDropdownTranslationContext();
    const selectedValuesText = useMemo(() => {
        return selectedValues.map(({ item }) => filter.itemName(item)).join(', ');
    }, [selectedValues]);
    return useMemo(() => {
        let placeholder = '';
        if (!shouldShowPlaceholder) {
            return { selectedValuesText, placeholder };
        }
        if (selectedValues.length !== 0) {
            if ((process.env.NODE_ENV === 'test' && selectedValuesText.length > 40) ||
                isOverflow) {
                placeholder = translate('selectedItems', {
                    total: selectedValues.length,
                });
            }
            else {
                placeholder = selectedValuesText;
            }
        }
        else if (placeholderProp) {
            placeholder = placeholderProp;
        }
        else {
            placeholder = translate('placeholder');
        }
        return { selectedValuesText, placeholder };
    }, [
        selectedValues,
        shouldShowPlaceholder,
        isOverflow,
        container.initTask.status.status,
    ]);
}
//# sourceMappingURL=useDropdownPlaceholder.js.map