@zohodesk/dot
Version:
In this Library, we Provide Some Basic Components to Build Your Application
180 lines (149 loc) • 9.86 kB
JavaScript
;
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _defaultProps = require("./props/defaultProps");
var _propTypes = require("./props/propTypes");
var _Layout = require("@zohodesk/components/lib/Layout");
var _icons = require("@zohodesk/icons");
var _CssProvider = _interopRequireDefault(require("@zohodesk/components/lib/Provider/CssProvider"));
var _StatusListItemModule = _interopRequireDefault(require("./StatusListItem.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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var StatusListItem = /*#__PURE__*/function (_React$Component) {
_inherits(StatusListItem, _React$Component);
var _super = _createSuper(StatusListItem);
function StatusListItem(props) {
var _this;
_classCallCheck(this, StatusListItem);
_this = _super.call(this, props);
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
_this.getRef = _this.getRef.bind(_assertThisInitialized(_this));
_this.handleMouseEnter = _this.handleMouseEnter.bind(_assertThisInitialized(_this));
return _this;
}
_createClass(StatusListItem, [{
key: "getRef",
value: function getRef(ele) {
this.ele = ele;
var _this$props = this.props,
index = _this$props.index,
getRef = _this$props.getRef,
id = _this$props.id;
getRef && getRef(ele, index, id);
}
}, {
key: "handleClick",
value: function handleClick(e) {
var _this$props2 = this.props,
onClick = _this$props2.onClick,
id = _this$props2.id,
value = _this$props2.value,
index = _this$props2.index;
onClick && onClick(id, value, index, e);
}
}, {
key: "handleMouseEnter",
value: function handleMouseEnter(e) {
var _this$props3 = this.props,
onMouseEnter = _this$props3.onMouseEnter,
id = _this$props3.id,
value = _this$props3.value,
index = _this$props3.index;
onMouseEnter && onMouseEnter(id, value, index, e);
}
}, {
key: "render",
value: function render() {
var _this$props4 = this.props,
size = _this$props4.size,
active = _this$props4.active,
highlight = _this$props4.highlight,
value = _this$props4.value,
autoHover = _this$props4.autoHover,
palette = _this$props4.palette,
title = _this$props4.title,
disableTitle = _this$props4.disableTitle,
needTick = _this$props4.needTick,
isLink = _this$props4.isLink,
href = _this$props4.href,
target = _this$props4.target,
needBorder = _this$props4.needBorder,
isDisabled = _this$props4.isDisabled,
bulletColor = _this$props4.bulletColor,
a11y = _this$props4.a11y,
needMultiLineText = _this$props4.needMultiLineText,
customClass = _this$props4.customClass,
children = _this$props4.children;
var options = {};
var role = a11y.role,
ariaSelected = a11y.ariaSelected,
_a11y$ariaHidden = a11y.ariaHidden,
ariaHidden = _a11y$ariaHidden === void 0 ? true : _a11y$ariaHidden,
ariaLabel = a11y.ariaLabel,
_a11y$insetFocus = a11y.insetFocus,
insetFocus = _a11y$insetFocus === void 0 ? true : _a11y$insetFocus;
if (isLink) {
options.href = href;
options.target = "_".concat(target);
}
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
role: role,
"aria-selected": ariaSelected,
"aria-label": ariaLabel,
"data-a11y-inset-focus": insetFocus,
isCover: false,
align: "baseline",
alignBox: "row",
className: "".concat(_StatusListItemModule["default"].list, " ").concat(_StatusListItemModule["default"][size], " ").concat(_StatusListItemModule["default"][palette], " ").concat(active ? _StatusListItemModule["default"].active : highlight && !isDisabled ? _StatusListItemModule["default"].hover : '', " ").concat(autoHover && !isDisabled ? _StatusListItemModule["default"].effect : '', " ").concat(needTick ? _StatusListItemModule["default"].withTick : '', " ").concat(isDisabled ? (0, _CssProvider["default"])('isDisable') : '', " ").concat(needBorder ? _StatusListItemModule["default"].withBorder : '', " ").concat(customClass),
dataId: String(value).replace("'", '_'),
onClick: !isDisabled && this.handleClick,
onMouseEnter: this.handleMouseEnter,
eleRef: this.getRef,
tagName: isLink ? 'a' : 'li',
"data-title": isDisabled ? disableTitle : null,
tabindex: isDisabled ? '-1' : '0'
}, options, a11y), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
className: "".concat(_StatusListItemModule["default"].statusType, " ").concat(_StatusListItemModule["default"][bulletColor])
}), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
flexible: true,
shrink: true
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
alignBox: "row",
align: needMultiLineText ? 'top' : 'vertical'
}, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
"data-title": isDisabled ? null : title,
shrink: true,
className: needMultiLineText ? _StatusListItemModule["default"].multiLineValue : _StatusListItemModule["default"].value
}, value), /*#__PURE__*/_react["default"].createElement(_Layout.Box, null, children && children))), needTick && active ? /*#__PURE__*/_react["default"].createElement("div", {
className: _StatusListItemModule["default"].tickIcon,
"aria-hidden": ariaHidden
}, /*#__PURE__*/_react["default"].createElement(_icons.Icon, {
name: "ZD-ticknew",
size: "8"
})) : null);
}
}]);
return StatusListItem;
}(_react["default"].Component);
exports["default"] = StatusListItem;
StatusListItem.defaultProps = _defaultProps.defaultProps;
StatusListItem.propTypes = _propTypes.propTypes; // if (__DOCS__) {
// StatusListItem.docs = {
// componentGroup: 'StatusListItem',
// folderName: 'List'
// };
// }