import React, { ReactNode } from "react";
import { SelectStatus } from "./SelectStatus";
interface SelectChildrenWithDefaultStatusProps {
isLoading: boolean | undefined;
inputValue: string | undefined;
children: ReactNode;
}
export const SelectChildrenWithDefaultStatus = ({
isLoading,
inputValue,
children,
}: SelectChildrenWithDefaultStatusProps) => {
const childrenIsEmptyArray = Array.isArray(children) && children.length === 0;
const showDefaultNoResults = inputValue && !isLoading && childrenIsEmptyArray;
const showDefaultLoading = isLoading && childrenIsEmptyArray;
if (showDefaultLoading) {
return Loading...;
}
if (showDefaultNoResults) {
return No matches found;
}
return <>{children}>;
};