Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3481 | Autoría | Ultima modificación | Ver Log |

import React from 'react';
import { styled, Typography } from '@mui/material';

const StyledList = styled('ul')`
  display: flex;
  flex-direction: column;
  list-style: none;
  padding: 0;
  gap: 1rem;
`;

export function List({
  items = [],
  renderItem = () => {},
  emptyMessage = 'No hay elementos para mostrar',
  keyExtractor = (item) => item.id
}) {
  if (!items.length) {
    return <Typography>{emptyMessage}</Typography>;
  }

  return (
    <StyledList>
      {items.map((item, index) => {
        return <li key={keyExtractor(item)}>{renderItem(item, index)}</li>;
      })}
    </StyledList>
  );
}