var _excluded = ["children"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { ListItem } from './ListItem';
import { StyledList } from './partials/StyledList';
import { useListItem } from './useListItem';
import { warnIfOverwriting } from '../../helpers';
export var List = function List(_ref) {
  var children = _ref.children,
    rest = _objectWithoutProperties(_ref, _excluded);
  var _useListItem = useListItem(),
    isActive = _useListItem.isActive,
    setActiveIndex = _useListItem.setActiveIndex;
  var mapped = React.Children.map(children, function (child, index) {
    warnIfOverwriting(child.props, 'isActive', ListItem.name);
    warnIfOverwriting(child.props, 'onMouseEnter', ListItem.name);
    warnIfOverwriting(child.props, 'onMouseLeave', ListItem.name);
    return /*#__PURE__*/React.cloneElement(child, {
      isActive: isActive(index),
      onMouseEnter: function onMouseEnter() {
        return setActiveIndex(index);
      },
      onMouseLeave: function onMouseLeave() {
        return setActiveIndex(null);
      }
    });
  });
  return /*#__PURE__*/React.createElement(StyledList, rest, mapped);
};
List.displayName = 'List';