UNPKG

@zohodesk/components

Version:

In this Package, we Provide Some Basic Components to Build Web App

134 lines (129 loc) 3.68 kB
import React from 'react'; import ListContainer from "./ListContainer"; import { ListItemWithCheckBoxDefaultProps } from "./props/defaultProps"; import { ListItemWithCheckBox_Props } from "./props/propTypes"; import CheckBox from "../CheckBox/CheckBox"; import { Box, Container } from "../Layout"; import style from "./ListItem.module.css"; export default class ListItemWithCheckBox extends React.Component { constructor(props) { super(props); this.onClick = this.onClick.bind(this); this.getRef = this.getRef.bind(this); this.onHover = this.onHover.bind(this); } getRef(ele) { this.ele = ele; let { index, getRef } = this.props; getRef && getRef(ele, index); } onClick(e) { let { onClick, id, value, index } = this.props; onClick && onClick(id, value, index, e); } onHover(e) { let { onHover, id, value, index } = this.props; onHover && onHover(id, value, index, e); } render() { let { size, active, highlight, value, checked, autoHover, palette, dataId, dataSelectorId, title, isDisabled, disableTitle, a11y, customClass, customProps, needMultiLineText, secondaryValue, lhsAlignContent, lhsJustifyContent } = this.props; const listA11y = { role: 'option', ...a11y }; let { ListItemProps = {}, ContainerProps = {} } = customProps; let { customListItem = '', customCheckBox = '', customLabel = '' } = customClass; return /*#__PURE__*/React.createElement(ListContainer, { a11y: listA11y, size: size, palette: palette, highlight: highlight, isDisabled: isDisabled, active: active, autoHover: autoHover, customClass: customListItem, dataId: `${dataId ? dataId : value}_ListItemWithCheckBox`, dataSelectorId: dataSelectorId, onClick: this.onClick, onMouseOver: this.onHover, eleRef: this.getRef, disableTitle: disableTitle, title: null, customProps: ListItemProps, ...ContainerProps }, /*#__PURE__*/React.createElement(Box, { className: `${style.iconBox} ${style.lhsBox} ${style[`lhsJustifyContent_${lhsJustifyContent}`]}`, dataId: `${dataId ? dataId : value}_checkBox` }, /*#__PURE__*/React.createElement(Box, { align: lhsAlignContent, className: lhsAlignContent !== 'center' ? style[`lhsBox_${size}`] : '' }, /*#__PURE__*/React.createElement(CheckBox, { checked: checked, a11y: { ariaHidden: true }, customClass: { customCheckBox: customCheckBox, customLabel: customLabel } }))), /*#__PURE__*/React.createElement(Box, { flexible: true, shrink: true }, /*#__PURE__*/React.createElement(Container, { alignBox: "column" }, value ? /*#__PURE__*/React.createElement(Box, { "data-title": isDisabled ? null : title, className: needMultiLineText ? style.multiLineValue : style.value }, value) : null, secondaryValue ? /*#__PURE__*/React.createElement(Box, { "data-title": isDisabled ? null : secondaryValue, className: `${style.secondaryField} ${needMultiLineText ? style.multiLine : style.secondaryValue}` }, secondaryValue) : null))); } } ListItemWithCheckBox.defaultProps = ListItemWithCheckBoxDefaultProps; ListItemWithCheckBox.propTypes = ListItemWithCheckBox_Props; // if (__DOCS__) { // ListItemWithCheckBox.docs = { // componentGroup: 'Molecule', // folderName: 'Style Guide' // }; // }