Liferay.Loader.define("dynamic-data-mapping-form-report-web@1.0.20/js/components/list/List.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', 'dynamic-data-mapping-form-report-web$moment', 'frontend-js-react-web$react', '../../utils/data.es', '../color/Color.es', '../sidebar/SidebarContext.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports["default"] = void 0;

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _moment = _interopRequireDefault(require("dynamic-data-mapping-form-report-web$moment"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _data = require("../../utils/data.es");

    var _Color = _interopRequireDefault(require("../color/Color.es"));

    var _SidebarContext = require("../sidebar/SidebarContext.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { "default": obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj["default"] = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { "default": obj };
    }

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var _default = function _default(_ref) {
      var data = _ref.data,
          field = _ref.field,
          summary = _ref.summary,
          totalEntries = _ref.totalEntries,
          type = _ref.type;

      var _useContext = (0, _react.useContext)(_SidebarContext.SidebarContext),
          portletNamespace = _useContext.portletNamespace,
          toggleSidebar = _useContext.toggleSidebar;

      var checkType = function checkType(field, type) {
        switch (type) {
          case 'color':
            return _react["default"].createElement(_Color["default"], {
              hexColor: field
            });

          case 'date':
            return formatDate(field);

          default:
            return field;
        }
      };

      var formatDate = function formatDate(field) {
        var locale = themeDisplay.getLanguageId().split('_', 1).join('');
        return (0, _moment["default"])(field).locale(locale).format('L');
      };

      data = (0, _data.removeEmptyValues)(data);
      return _react["default"].createElement("div", {
        className: "field-list"
      }, _react["default"].createElement("ul", {
        className: "entries-list"
      }, Array.isArray(data) && data.map(function (field, index) {
        return _react["default"].createElement("li", {
          key: index
        }, checkType(field, type));
      }), data.length == 5 && totalEntries > 5 ? _react["default"].createElement("li", {
        id: "".concat(portletNamespace, "-see-more"),
        key: 'see-more'
      }, _react["default"].createElement(_button["default"], {
        displayType: "link",
        onClick: function onClick() {
          return toggleSidebar(field, summary, totalEntries, type);
        }
      }, Liferay.Language.get('see-all-entries'))) : null));
    };

    exports["default"] = _default;
    //# sourceMappingURL=List.es.js.map
  }
});
//# sourceMappingURL=List.es.js.map