UNPKG

@zohodesk/components

Version:

Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development

150 lines (144 loc) 4.57 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import Radio from "../Radio/Radio"; import { Box, Container } from "../Layout"; import ListContainer from "./ListContainer"; import { ListItemWithRadioDefaultProps } from "./props/defaultProps"; import { ListItemWithRadio_Props } from "./props/propTypes"; import { renderNode, isRenderable } from '@zohodesk/utils'; import style from "./ListItem.module.css"; export default class ListItemWithRadio 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, needBorder, id, dataId, dataSelectorId, title, isDisabled, disableTitle, a11y, customClass, customProps, needMultiLineText, secondaryValue, renderValueRightPlaceholderNode, lhsAlignContent, lhsJustifyContent } = this.props; let { ListItemProps = {}, ContainerProps = {} } = customProps; const listA11y = { role: 'option', ...a11y }; let { customListItem = '', customRadio = '', customRadioWrap = '', customValueRightPlaceholder = '' } = customClass; const iconBoxDataId = `${dataId}_radio`; return /*#__PURE__*/React.createElement(ListContainer, _extends({ a11y: listA11y, size: size, palette: palette, highlight: highlight, isDisabled: isDisabled, active: active, autoHover: autoHover, needBorder: needBorder, customClass: customListItem, dataId: dataId, dataSelectorId: dataSelectorId, onClick: this.onClick, onMouseOver: this.onHover, eleRef: this.getRef, disableTitle: disableTitle, title: null, customProps: ListItemProps }, ContainerProps), /*#__PURE__*/React.createElement(Box, { className: style.contentWrapper }, /*#__PURE__*/React.createElement("div", { className: `${style.iconBox} ${style[`lhsJustifyContent_${lhsJustifyContent}`]}`, "data-id": iconBoxDataId, "data-test-id": iconBoxDataId }, /*#__PURE__*/React.createElement(Box, { align: lhsAlignContent, className: lhsAlignContent !== 'center' ? style.lhsBoxInner : '' }, /*#__PURE__*/React.createElement(Radio, { checked: checked, id: id, a11y: { ariaHidden: true }, customClass: { customRadio: customRadio, customRadioWrap: customRadioWrap } }))), /*#__PURE__*/React.createElement(Box, { flexible: true, className: `${style.leftBox} ${style.selfAlign_center}` }, /*#__PURE__*/React.createElement(Box, { className: style.titleBox }, value ? /*#__PURE__*/React.createElement(Box, { shrink: true, adjust: true, "data-title": disableTitle ? null : title, className: needMultiLineText ? style.multiLineValue : style.value }, value) : null, isRenderable(renderValueRightPlaceholderNode) ? /*#__PURE__*/React.createElement(Box, { className: customValueRightPlaceholder }, renderNode(renderValueRightPlaceholderNode)) : null), secondaryValue ? /*#__PURE__*/React.createElement(Box, { "data-title": isDisabled ? null : secondaryValue, className: `${style.secondaryField} ${needMultiLineText ? style.multiLine : style.secondaryValue}` }, secondaryValue) : null))); } } ListItemWithRadio.defaultProps = ListItemWithRadioDefaultProps; ListItemWithRadio.propTypes = ListItemWithRadio_Props; // if (__DOCS__) { // ListItemWithRadio.docs = { // componentGroup: 'Molecule', // folderName: 'Style Guide' // }; // }