@zohodesk/components
Version:
In this Package, we Provide Some Basic Components to Build Web App
126 lines (106 loc) • 5.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _ListContainer = _interopRequireDefault(require("./ListContainer"));
var _defaultProps = require("./props/defaultProps");
var _propTypes = require("./props/propTypes");
var _CheckBox = _interopRequireDefault(require("../CheckBox/CheckBox"));
var _Layout = require("../Layout");
var _ListItemModule = _interopRequireDefault(require("../../ListItem/ListItem.module.css"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var ListItemWithCheckBox = function ListItemWithCheckBox(props) {
var size = props.size,
active = props.active,
highlight = props.highlight,
value = props.value,
checked = props.checked,
autoHover = props.autoHover,
palette = props.palette,
dataId = props.dataId,
dataSelectorId = props.dataSelectorId,
title = props.title,
isDisabled = props.isDisabled,
disableTitle = props.disableTitle,
a11y = props.a11y,
customClass = props.customClass,
customProps = props.customProps,
needMultiLineText = props.needMultiLineText,
id = props.id,
index = props.index,
onHover = props.onHover,
onClick = props.onClick,
getRef = props.getRef;
function handleRef(ele) {
getRef && getRef(ele, index);
}
function handleClick(e) {
onClick && onClick(id, value, index, e);
}
function handleHover(e) {
onHover && onHover(id, value, index, e);
}
var listA11y = _objectSpread({
role: 'option'
}, a11y);
var _customProps$ListItem = customProps.ListItemProps,
ListItemProps = _customProps$ListItem === void 0 ? {} : _customProps$ListItem,
_customProps$Containe = customProps.ContainerProps,
ContainerProps = _customProps$Containe === void 0 ? {} : _customProps$Containe;
var _customClass$customLi = customClass.customListItem,
customListItem = _customClass$customLi === void 0 ? '' : _customClass$customLi,
_customClass$customCh = customClass.customCheckBox,
customCheckBox = _customClass$customCh === void 0 ? '' : _customClass$customCh,
_customClass$customLa = customClass.customLabel,
customLabel = _customClass$customLa === void 0 ? '' : _customClass$customLa;
return /*#__PURE__*/_react["default"].createElement(_ListContainer["default"], _extends({
a11y: listA11y,
size: size,
palette: palette,
highlight: highlight,
isDisabled: isDisabled,
active: active,
autoHover: autoHover,
customClass: customListItem,
dataId: "".concat(dataId ? dataId : value, "_ListItemWithCheckBox"),
dataSelectorId: dataSelectorId,
onClick: handleClick,
onMouseOver: handleHover,
eleRef: handleRef,
disableTitle: disableTitle,
title: null,
customProps: ListItemProps
}, ContainerProps), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
className: _ListItemModule["default"].iconBox,
dataId: "".concat(dataId ? dataId : value, "_checkBox")
}, /*#__PURE__*/_react["default"].createElement(_CheckBox["default"], {
checked: checked,
a11y: {
ariaHidden: true
},
customClass: {
customCheckBox: customCheckBox,
customLabel: customLabel
}
})), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
flexible: true,
shrink: true,
"data-title": isDisabled ? null : title,
className: needMultiLineText ? _ListItemModule["default"].multiLineValue : _ListItemModule["default"].value
}, value));
};
var _default = ListItemWithCheckBox;
exports["default"] = _default;
ListItemWithCheckBox.defaultProps = _defaultProps.ListItemWithCheckBoxDefaultProps;
ListItemWithCheckBox.propTypes = _propTypes.ListItemWithCheckBox_Props; // if (__DOCS__) {
// ListItemWithCheckBox.docs = {
// componentGroup: 'Molecule',
// folderName: 'Style Guide'
// };
// }