"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.getComponentsFromPropsList = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _react = _interopRequireDefault(require("react"));

var _Checkbox = require("../../components/Checkbox");

var getComponentsFromPropsList = exports.getComponentsFromPropsList = function getComponentsFromPropsList(
component,
propsList)
{
  return propsList.reduce(function (result, props, index) {
    // NOTE: все это ради чекбокса с фокусом, т.к. нет ни focused, ни autofocus; а ref+focus() снаружи нестабилен
    var isCheckbox = component.type === _Checkbox.Checkbox;
    if (isCheckbox) {
      var checkboxProps = props;
      if (checkboxProps.focused) {
        checkboxProps.ref = function (el) {
          if (el) {
            el.setState({ focusedByTab: true });
          }
        };
        delete checkboxProps.focused;
      }
    }

    var elementWithProps = /*#__PURE__*/_react.default.cloneElement(component, (0, _extends2.default)({}, props, { key: index }));

    return [].concat(result, [elementWithProps]);
  }, []);
};