import React, { ReactNode } from 'react'; import '../../../index.scss'; import NoData from '../NoData/NoData'; import Icon from '../Icon'; import classNames from 'classnames'; export interface ListProps { /** * Data for List */ listItems: Array; /** * Icon position if added */ iconPosition?: 'left' | 'right'; /** * If list item is string then use this props to give its max length */ textMaxWidth?: string; /** * List onClick function */ onListItemClick: (data: any) => any; /** * The content that to be displayed if no data not found */ noDataContent: string | ReactNode; /** * Image that to be displayed if you don't have data */ noDataImage?: string; /** * Size of the image that to be displayed if you don't have data */ noDataImageSize?: 'x-large' | 'large' | 'medium' | 'small' | 'x-small'; } export interface ListItemProps { /** * list item text */ text: string | ReactNode; /** * Icon if needed to add in the list */ iconName?: string; /** * To disable list item set it to true */ disable?: boolean; } const List = ({ listItems, iconPosition, textMaxWidth = 'auto', onListItemClick = () => {}, noDataContent, noDataImage, noDataImageSize, }: ListProps) => { return (
{listItems.length > 0 ? ( listItems.map((listItem) => { return (
{ !listItem.disable && onListItemClick(listItem); }} >
{listItem.text}
{listItem.iconName && (
)}
); }) ) : (
)}
); }; export default List;