import type { FC, TeactNode } from '../../lib/teact/teact'; import React, { memo } from '../../lib/teact/teact'; import type { CustomPeer } from '../../types'; import buildClassName from '../../util/buildClassName'; import Checkbox from './Checkbox'; import ListItem from './ListItem'; import Radio from './Radio'; type OwnProps = { key: string; isChecked?: boolean; disabled?: boolean; inactive?: boolean; isChatItem?: boolean; ripple?: boolean; shouldRenderLockIcon?: boolean; category?: CustomPeer; handleItemClick: (id: string) => void; renderCategory?: (category: CustomPeer) => TeactNode; renderChatInfo?: (id: string) => TeactNode; allowDisabledClick?: boolean; label?: TeactNode; subLabel?: string; type?: 'checkbox' | 'radio'; }; const ListItemWithOptions: FC = ({ key, isChecked, disabled, inactive, isChatItem, shouldRenderLockIcon, category, handleItemClick, ripple, renderCategory, renderChatInfo, allowDisabledClick, label, subLabel, type, }) => { function renderInput() { if (inactive || disabled) { return undefined; } return type === 'checkbox' ? ( ) : ( ); } return ( handleItemClick(key)} ripple={ripple} > {!isChatItem ? renderInput() : undefined} {category ? renderCategory?.(category) : renderChatInfo?.(key)} {isChatItem ? renderInput() : undefined} ); }; export default memo(ListItemWithOptions);