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

127 lines (102 loc) • 7.12 kB
"use strict"; 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 _propTypes = require("./props/propTypes"); var _defaultProps = require("./props/defaultProps"); var _DropDownItemModule = _interopRequireDefault(require("./DropDownItem.module.css")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 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 DropDownItem = /*#__PURE__*/function (_React$Component) { _inherits(DropDownItem, _React$Component); var _super = _createSuper(DropDownItem); function DropDownItem(props) { var _this; _classCallCheck(this, DropDownItem); _this = _super.call(this, props); _this.onClick = _this.onClick.bind(_assertThisInitialized(_this)); _this.getRef = _this.getRef.bind(_assertThisInitialized(_this)); _this.getSelectedElement = _this.getSelectedElement.bind(_assertThisInitialized(_this)); _this.onHover = _this.onHover.bind(_assertThisInitialized(_this)); return _this; } _createClass(DropDownItem, [{ key: "getRef", value: function getRef(ele) { this.ele = ele; var _this$props = this.props, index = _this$props.index, getRef = _this$props.getRef; getRef && getRef(ele, index); } }, { key: "getSelectedElement", value: function getSelectedElement() { return this.ele ? this.ele : null; } }, { key: "onClick", value: function onClick(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: "onHover", value: function onHover(e) { var _this$props3 = this.props, onHover = _this$props3.onHover, id = _this$props3.id, value = _this$props3.value, index = _this$props3.index; onHover && onHover(id, value, index, e); } }, { key: "render", value: function render() { var _this$props4 = this.props, value = _this$props4.value, active = _this$props4.active, children = _this$props4.children, hightlight = _this$props4.hightlight, dataId = _this$props4.dataId, _this$props4$customCl = _this$props4.customClass, customClass = _this$props4$customCl === void 0 ? '' : _this$props4$customCl; return /*#__PURE__*/_react["default"].createElement("div", { className: "".concat(_DropDownItemModule["default"].list, " ").concat(active ? _DropDownItemModule["default"].listActive : hightlight ? _DropDownItemModule["default"].listHover : '', " ").concat(children && children[1] ? _DropDownItemModule["default"].padding : '', " ").concat(customClass), onClick: this.onClick, onMouseOver: this.onHover, ref: this.getRef, "data-id": dataId, "data-test-id": dataId }, children && children[0] ? /*#__PURE__*/_react["default"].createElement("span", { className: _DropDownItemModule["default"].children }, " ", children[0], " ") : children !== undefined ? /*#__PURE__*/_react["default"].createElement("span", { className: _DropDownItemModule["default"].children }, " ", children, " ") : null, value ? /*#__PURE__*/_react["default"].createElement("span", { className: _DropDownItemModule["default"].value }, value) : '', children && children[1] ? /*#__PURE__*/_react["default"].createElement("span", { className: _DropDownItemModule["default"].user }, " ", children[1], " ") : ''); } }]); return DropDownItem; }(_react["default"].Component); exports["default"] = DropDownItem; DropDownItem.propTypes = _propTypes.DropDownItem_propTypes; DropDownItem.defaultProps = _defaultProps.DropDownItem_defaultProps;