'use strict';

require('core-js/modules/es.symbol.js');
require('core-js/modules/es.array.filter.js');
require('core-js/modules/es.object.get-own-property-descriptor.js');
require('core-js/modules/es.object.get-own-property-descriptors.js');
require('core-js/modules/es.object.to-string.js');
require('core-js/modules/web.dom-collections.for-each.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
require('core-js/modules/es.array.map.js');
require('core-js/modules/es.object.keys.js');
var React = require('react');
var PropTypes = require('prop-types');
var SimpleList = require('../../List/SimpleList/SimpleList.js');
var Settings = require('../../../constants/Settings.js');
var LayoutConstants = require('../../../constants/LayoutConstants.js');
var LineGraphIcon = require('../../../icons/components/LineGraphIcon.js');
var SimpleBarGraphIcon = require('../../../icons/components/SimpleBarGraphIcon.js');
var BarGroupedGraphIcon = require('../../../icons/components/BarGroupedGraphIcon.js');
var BarStackGraphIcon = require('../../../icons/components/BarStackGraphIcon.js');
var ValueKpiIcon = require('../../../icons/components/ValueKpiIcon.js');
var ImageIcon = require('../../../icons/components/ImageIcon.js');
var DataTableIcon = require('../../../icons/components/DataTableIcon.js');
var ListIcon = require('../../../icons/components/ListIcon.js');
var CustomCardIcon = require('../../../icons/components/CustomCardIcon.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var React__default = /*#__PURE__*/_interopDefault(React);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var iotPrefix = Settings.settings.iotPrefix;
var propTypes = {
  supportedCardTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
  onAddCard: PropTypes__default.default.func.isRequired,
  icons: PropTypes__default.default.objectOf(PropTypes__default.default.node),
  i18n: PropTypes__default.default.shape({
    galleryHeader: PropTypes__default.default.string,
    searchPlaceHolderText: PropTypes__default.default.string,
    TIMESERIES: PropTypes__default.default.string,
    SIMPLE_BAR: PropTypes__default.default.string,
    GROUPED_BAR: PropTypes__default.default.string,
    STACKED_BAR: PropTypes__default.default.string,
    VALUE: PropTypes__default.default.string,
    IMAGE: PropTypes__default.default.string,
    TABLE: PropTypes__default.default.string,
    LIST: PropTypes__default.default.string,
    CUSTOM: PropTypes__default.default.string
  }),
  testId: PropTypes__default.default.string
};
var defaultProps = {
  supportedCardTypes: Object.keys(LayoutConstants.DASHBOARD_EDITOR_CARD_TYPES),
  i18n: {
    galleryHeader: 'Gallery',
    searchPlaceHolderText: 'Enter a search',
    TIMESERIES: 'Time series line',
    SIMPLE_BAR: 'Simple bar',
    GROUPED_BAR: 'Grouped bar',
    STACKED_BAR: 'Stacked bar',
    VALUE: 'Value / KPI',
    IMAGE: 'Image',
    TABLE: 'Data table',
    LIST: 'List',
    CUSTOM: 'Custom'
    // additional card type names can be provided using the convention of `TYPE` in supportedCardTypes
  },
  icons: {
    TIMESERIES: /*#__PURE__*/React__default.default.createElement(LineGraphIcon, null),
    SIMPLE_BAR: /*#__PURE__*/React__default.default.createElement(SimpleBarGraphIcon, null),
    GROUPED_BAR: /*#__PURE__*/React__default.default.createElement(BarGroupedGraphIcon, null),
    STACKED_BAR: /*#__PURE__*/React__default.default.createElement(BarStackGraphIcon, null),
    VALUE: /*#__PURE__*/React__default.default.createElement(ValueKpiIcon, null),
    IMAGE: /*#__PURE__*/React__default.default.createElement(ImageIcon, null),
    TABLE: /*#__PURE__*/React__default.default.createElement(DataTableIcon, null),
    LIST: /*#__PURE__*/React__default.default.createElement(ListIcon, null),
    CUSTOM: /*#__PURE__*/React__default.default.createElement(CustomCardIcon, null)
  },
  testId: 'card-gallery-list'
};
var CardGalleryList = function CardGalleryList(_ref) {
  var supportedCardTypes = _ref.supportedCardTypes,
    onAddCard = _ref.onAddCard,
    icons = _ref.icons,
    i18n = _ref.i18n,
    testId = _ref.testId;
  var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
  var mergedIcons = _objectSpread(_objectSpread({}, defaultProps.icons), icons);
  return /*#__PURE__*/React__default.default.createElement(SimpleList, {
    testId: testId,
    title: "",
    isFullHeight: true,
    hasSearch: true,
    hasPagination: false,
    items: supportedCardTypes.map(function (cardType) {
      return {
        id: cardType,
        content: {
          value: mergedI18n[cardType] || cardType,
          icon: /*#__PURE__*/React__default.default.createElement("div", {
            className: "".concat(iotPrefix, "--card-gallery-list__icon")
          }, mergedIcons[cardType])
        },
        isSelectable: true
      };
    }),
    onSelect: function onSelect(cardType) {
      onAddCard(cardType);
    },
    i18n: {
      searchPlaceHolderText: mergedI18n.searchPlaceHolderText
    }
  });
};
CardGalleryList.defaultProps = defaultProps;
CardGalleryList.propTypes = propTypes;
CardGalleryList.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "CardGalleryList",
  "props": {
    "supportedCardTypes": {
      "defaultValue": {
        "value": "Object.keys(DASHBOARD_EDITOR_CARD_TYPES)",
        "computed": true
      },
      "description": "",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "string"
        }
      },
      "required": false
    },
    "i18n": {
      "defaultValue": {
        "value": "{\n  galleryHeader: 'Gallery',\n  searchPlaceHolderText: 'Enter a search',\n  TIMESERIES: 'Time series line',\n  SIMPLE_BAR: 'Simple bar',\n  GROUPED_BAR: 'Grouped bar',\n  STACKED_BAR: 'Stacked bar',\n  VALUE: 'Value / KPI',\n  IMAGE: 'Image',\n  TABLE: 'Data table',\n  LIST: 'List',\n  CUSTOM: 'Custom',\n  // additional card type names can be provided using the convention of `TYPE` in supportedCardTypes\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "galleryHeader": {
            "name": "string",
            "required": false
          },
          "searchPlaceHolderText": {
            "name": "string",
            "required": false
          },
          "TIMESERIES": {
            "name": "string",
            "required": false
          },
          "SIMPLE_BAR": {
            "name": "string",
            "required": false
          },
          "GROUPED_BAR": {
            "name": "string",
            "required": false
          },
          "STACKED_BAR": {
            "name": "string",
            "required": false
          },
          "VALUE": {
            "name": "string",
            "required": false
          },
          "IMAGE": {
            "name": "string",
            "required": false
          },
          "TABLE": {
            "name": "string",
            "required": false
          },
          "LIST": {
            "name": "string",
            "required": false
          },
          "CUSTOM": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "icons": {
      "defaultValue": {
        "value": "{\n  TIMESERIES: <LineGraphIcon />,\n  SIMPLE_BAR: <SimpleBarGraphIcon />,\n  GROUPED_BAR: <BarGroupedGraphIcon />,\n  STACKED_BAR: <BarStackGraphIcon />,\n  VALUE: <ValueKpiIcon />,\n  IMAGE: <ImageIcon />,\n  TABLE: <DataTableIcon />,\n  LIST: <ListIcon />,\n  CUSTOM: <CustomCardIcon />,\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "objectOf",
        "value": {
          "name": "node"
        }
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'card-gallery-list'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "onAddCard": {
      "description": "",
      "type": {
        "name": "func"
      },
      "required": true
    }
  }
};
var CardGalleryList$1 = CardGalleryList;

module.exports = CardGalleryList$1;
