import * as React from "react"; import { FastClick, ReactComponentType, PureRender } from "../../../" import { ItemProps } from './ListProps' export interface ItemComponentProps extends ItemProps { showCheckbox: boolean } function itemRenderer(props: ItemComponentProps) { const { bemBlocks, onClick, active, disabled, style, itemKey, label, count, showCount, showCheckbox} = props const block = bemBlocks.option const className = block() .state({ active, disabled }) .mix(bemBlocks.container("item")) const hasCount = showCount && (count != undefined) && (count != null) return ( {showCheckbox ? : undefined} {label} {hasCount ? < div data-qa="count" className={block("count") }>{count} : undefined} ) } @PureRender export class ItemComponent extends React.Component{ static defaultProps = { showCount: true, showCheckbox:false } render() { return itemRenderer(this.props) } } @PureRender export class CheckboxItemComponent extends React.Component{ static defaultProps = { showCount: true, showCheckbox:true } render() { return itemRenderer(this.props) } }