import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';

var _excluded = ["items", "index", "autoscroll", "onIndexChange"],
  _excluded2 = ["label"];
/**
 * @deprecated
 * Используйте Tabs, TabItem, указав параметры index, itemIndex, onIndexChange
 *
 * Функция для создания `TabController`, которая дает возможность
 * кастомизировать стили, при этом сохраняя единый интерфейс и функционал.
 */
function createTabsController(ListComponent, ItemComponent) {
  // eslint-disable-next-line prefer-arrow-callback
  return /*#__PURE__*/forwardRef(function TabsController(_ref, ref) {
    var items = _ref.items,
      index = _ref.index,
      onIndexChange = _ref.onIndexChange,
      rest = _objectWithoutProperties(_ref, _excluded);
    var disabled = rest.disabled;
    return /*#__PURE__*/React__default.createElement(ListComponent, _extends({
      ref: ref,
      index: index
    }, rest), items.map(function (_ref2, i) {
      var label = _ref2.label,
        restItem = _objectWithoutProperties(_ref2, _excluded2);
      return /*#__PURE__*/React__default.createElement(ItemComponent, _extends({
        key: i,
        selected: i === index,
        itemIndex: i,
        onIndexChange: onIndexChange,
        tabIndex: !disabled && i === index ? 0 : -1,
        disabled: disabled
      }, restItem), label);
    }));
  });
}

export { createTabsController };
