import DeleteOutlined from '@ant-design/icons/DeleteOutlined'; import classNames from 'classnames'; import * as React from 'react'; import type { KeyWiseTransferItem } from '.'; import Checkbox from '../checkbox'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import defaultLocale from '../locale/en_US'; import TransButton from '../_util/transButton'; type ListItemProps = { renderedText?: string | number; renderedEl: React.ReactNode; disabled?: boolean; checked?: boolean; prefixCls: string; onClick: (item: RecordType) => 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`]: true, [`${prefixCls}-content-item-disabled`]: disabled || item.disabled, [`${prefixCls}-content-item-checked`]: checked, }); let title: string | undefined; if (typeof renderedText === 'string' || typeof renderedText === 'number') { title = String(renderedText); } return ( {contextLocale => { const liProps: React.HTMLAttributes = { className, title }; const labelNode = {renderedEl}; // Show remove if (showRemove) { return (
  • {labelNode} { onRemove?.(item); }} >
  • ); } // Default click to select liProps.onClick = disabled || item.disabled ? undefined : () => onClick(item); return (
  • {labelNode}
  • ); }}
    ); }; export default React.memo(ListItem);