import * as React from 'react'; import DeleteOutlined from '@ant-design/icons/DeleteOutlined'; import classNames from 'classnames'; import type { KeyWiseTransferItem } from '.'; import Checkbox from '../checkbox'; import { useLocale } from '../locale'; import defaultLocale from '../locale/en_US'; type ListItemProps = { renderedText?: string | number; renderedEl: React.ReactNode; disabled?: boolean; checked?: boolean; prefixCls: string; onClick: (item: RecordType, e: React.MouseEvent) => void; onRemove?: (item: RecordType) => void; item: RecordType; showRemove?: boolean; }; const ListItem = (props: ListItemProps) => { const { renderedText, renderedEl, item, checked, disabled, prefixCls, onClick, onRemove, showRemove, } = props; const className = classNames(`${prefixCls}-content-item`, { [`${prefixCls}-content-item-disabled`]: disabled || item.disabled, [`${prefixCls}-content-item-checked`]: checked && !item.disabled, }); let title: string | undefined; if (typeof renderedText === 'string' || typeof renderedText === 'number') { title = String(renderedText); } const [contextLocale] = useLocale('Transfer', defaultLocale.Transfer); const liProps: React.HTMLAttributes = { className, title }; const labelNode = {renderedEl}; if (showRemove) { return (
  • {labelNode}
  • ); } // Default click to select liProps.onClick = disabled || item.disabled ? undefined : (event) => onClick(item, event); return (
  • {labelNode}
  • ); }; export default React.memo(ListItem);