import * as React from 'react'; import classnames from 'classnames'; type labelAlignEnum = 'top' | 'left'; interface ListProps { className?: string; maxHeight?: boolean | string; title?: string | React.ReactNode; dataSource?: Array; labelAlign?: labelAlignEnum; labelWidth?: string; } interface ItemProps { label: string; value?: string | number | React.ReactNode; } const List: React.FC = ({ className = '', maxHeight = '', title = '', dataSource = [], labelAlign = 'top', labelWidth = '30%', }) => { return dataSource.length ? (
{title ?
{title}
: null}
{dataSource.map((item) => { const { label, value } = item; const itemLabelWidth = labelAlign === 'left' && labelWidth ? labelWidth : 'auto'; return (
{label}
{value ?
{value}
: null}
); })}
) : null; }; export default List;