"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

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

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _tslib = require("tslib");

var _react = _interopRequireWildcard(require("react"));

var _mobxReact = require("mobx-react");

var _TextField = _interopRequireDefault(require("../text-field/TextField"));

var _TextArea = _interopRequireDefault(require("../text-area/TextArea"));

var _enum = require("./enum");

var _Form = _interopRequireDefault(require("../form/Form"));

var _localeContext = _interopRequireDefault(require("../locale-context"));

var IntlList = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(IntlList, _Component);

  var _super = (0, _createSuper2["default"])(IntlList);

  function IntlList() {
    (0, _classCallCheck2["default"])(this, IntlList);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(IntlList, [{
    key: "renderOptions",
    value: function renderOptions() {
      var _this$props = this.props,
          name = _this$props.name,
          lang = _this$props.lang,
          maxLengths = _this$props.maxLengths,
          type = _this$props.type,
          rows = _this$props.rows,
          cols = _this$props.cols,
          resize = _this$props.resize,
          getConfig = _this$props.getConfig;
      var supports = _localeContext["default"].supports;
      var tlsKey = getConfig('tlsKey');
      var FieldTag = type === _enum.IntlType.multipleLine ? _TextArea["default"] : _TextField["default"];
      var otherProps = type === _enum.IntlType.multipleLine ? {
        rows: rows,
        cols: cols,
        resize: resize
      } : {};
      return Object.keys(supports).map(function (key) {
        var maxLengthProps = maxLengths && maxLengths[key] ? {
          maxLength: maxLengths[key]
        } : {};
        return /*#__PURE__*/_react["default"].createElement(FieldTag, (0, _extends2["default"])({}, maxLengthProps, {
          name: name ? "".concat(tlsKey, ".").concat(name, ".").concat(key) : key,
          autoFocus: key === lang,
          key: key
        }, otherProps));
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
          record = _this$props2.record,
          disabled = _this$props2.disabled,
          readOnly = _this$props2.readOnly;
      return /*#__PURE__*/_react["default"].createElement(_Form["default"], {
        disabled: disabled,
        readOnly: readOnly,
        record: record
      }, this.renderOptions());
    }
  }]);
  return IntlList;
}(_react.Component);

IntlList = (0, _tslib.__decorate)([_mobxReact.observer], IntlList);
var _default = IntlList;
exports["default"] = _default;
//# sourceMappingURL=IntlList.js.map
