) => ReactElement;
}
export interface ReferenceArrayFieldViewProps {
children?: ReactNode;
className?: string;
empty?: ReactNode;
error?: ReactNode;
loading?: ReactNode;
pagination?: ReactNode;
}
export const ReferenceArrayFieldView = (
props: ReferenceArrayFieldViewProps,
) => {
const {
children = defaultChildren,
className,
empty,
error: errorElement,
loading,
pagination,
} = props;
const {
isPending,
error,
total,
hasPreviousPage,
hasNextPage,
data,
filterValues,
} = useListContext();
return (
{isPending && loading !== false ? (
loading
) : error && errorElement !== false ? (
errorElement
) : (total === 0 ||
(total == null &&
hasPreviousPage === false &&
hasNextPage === false &&
// @ts-expect-error FIXME total may be undefined when using partial pagination but the ListControllerResult type is wrong about it
data.length === 0 &&
// the user didn't set any filters
!Object.keys(filterValues).length)) &&
empty !== false ? (
empty
) : (
{children}
{pagination && total !== undefined ? pagination : null}
)}
);
};
const defaultChildren = ;
const PureReferenceArrayFieldView = memo(ReferenceArrayFieldView);