The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/components/GenericTable/hooks/useShowingResultsLabel.ts

15 lines
668 B

import type { Pagination } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ComponentProps } from 'react';
import { useCallback } from 'react';
type Props<T extends ComponentProps<typeof Pagination>['showingResultsLabel'] = ComponentProps<typeof Pagination>['showingResultsLabel']> =
T extends (...args: any[]) => any ? Parameters<T> : never;
export const useShowingResultsLabel = (): ((...params: Props) => string) => {
const t = useTranslation();
return useCallback(
({ count, current, itemsPerPage }) => t('Showing_results_of', current + 1, Math.min(current + itemsPerPage, count), count),
[t],
);
};