import { MatPaginatorIntl } from '@angular/material';

export function PaginatorConfig() {
	const paginatorConfig = new MatPaginatorIntl();

	paginatorConfig.itemsPerPageLabel = 'Elementos por página:';

	paginatorConfig.getRangeLabel = (page: number, pageSize: number, length: number) =>  {
		if (length === 0 || pageSize === 0) {
			return `0 de ${length}`;
		}
		length = Math.max(length, 0);
		let startIndex = page * pageSize;
		let endIndex = startIndex < length ? Math.min(startIndex + pageSize, length) : startIndex + pageSize;
		return `${startIndex + 1} - ${endIndex} de ${length}`;
	}

	return paginatorConfig;
}
