import _defineProperty from '@babel/runtime/helpers/defineProperty';
import 'core-js/modules/es.array.concat.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { settings } from '../../../constants/Settings.js';
import TableViewItemPropType from './TableViewItemPropTypes.js';
import { View } from '@carbon/icons-react';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  isCompact: PropTypes.bool.isRequired,
  activeViewEdited: PropTypes.bool.isRequired,
  isSelected: PropTypes.bool.isRequired,
  item: TableViewItemPropType.isRequired,
  i18n: PropTypes.shape({
    view: PropTypes.string,
    edited: PropTypes.string
  }).isRequired,
  testID: PropTypes.string
};
var defaultProps = {
  testID: 'TableViewDropdownItem'
};
var TableViewDropdownItem = function TableViewDropdownItem(_ref) {
  var _ref$item = _ref.item,
    customAction = _ref$item.customAction,
    text = _ref$item.text,
    Icon = _ref$item.icon,
    tooltip = _ref$item.tooltip,
    isSelected = _ref.isSelected,
    activeViewEdited = _ref.activeViewEdited,
    i18n = _ref.i18n,
    isCompact = _ref.isCompact,
    testID = _ref.testID;
  var showEdited = isSelected && activeViewEdited && !customAction;
  var editedPostfix = " - ".concat(i18n.edited);
  return /*#__PURE__*/React__default.createElement("div", {
    "data-testid": testID,
    title: "".concat(tooltip || text).concat(showEdited ? editedPostfix : ''),
    className: classnames("".concat(iotPrefix, "--view-dropdown__item"), _defineProperty({}, "".concat(iotPrefix, "--view-dropdown__item-link"), customAction))
  }, isSelected && !isCompact ? /*#__PURE__*/React__default.createElement("span", {
    className: "".concat(iotPrefix, "--view-dropdown__button-prefix")
  }, /*#__PURE__*/React__default.createElement(View, {
    size: 20
  }), /*#__PURE__*/React__default.createElement("span", null, "".concat(i18n.view, ": "))) : null, /*#__PURE__*/React__default.createElement("span", null, text, showEdited ? /*#__PURE__*/React__default.createElement("span", {
    className: "".concat(iotPrefix, "--view-dropdown__edited-text")
  }, editedPostfix) : null), Icon && !isCompact ? /*#__PURE__*/React__default.createElement(Icon, {
    className: classnames(_defineProperty({}, "".concat(iotPrefix, "--view-dropdown__item-link-icon"), customAction))
  }) : null);
};
TableViewDropdownItem.propTypes = propTypes;
TableViewDropdownItem.defaultProps = defaultProps;
TableViewDropdownItem.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "TableViewDropdownItem",
  "props": {
    "testID": {
      "defaultValue": {
        "value": "'TableViewDropdownItem'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "isCompact": {
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": true
    },
    "activeViewEdited": {
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": true
    },
    "isSelected": {
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": true
    },
    "item": {
      "description": "",
      "type": {
        "name": "custom",
        "raw": "TableViewItemPropType.isRequired"
      },
      "required": false
    },
    "i18n": {
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "view": {
            "name": "string",
            "required": false
          },
          "edited": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": true
    }
  }
};
var TableViewDropdownItem$1 = TableViewDropdownItem;

export { TableViewDropdownItem$1 as default };
