'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var cls = require('classnames');
var List_styles = require('./List.styles.js');
var List_tokens = require('./List.tokens.js');
var base = require('./variations/_view/base.js');
var base$1 = require('./variations/_size/base.js');
var base$2 = require('./variations/_disabled/base.js');
var List_context = require('./List.context.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);
var cls__default = /*#__PURE__*/_interopDefault(cls);

var _excluded = ["size", "view", "disabled", "variant", "hasBackground", "hasItemBackground", "hasDivider", "className", "children"];
var listRoot = function listRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (_ref, outerRootRef) {
    var size = _ref.size,
      view = _ref.view,
      disabled = _ref.disabled,
      variant = _ref.variant,
      hasBackground = _ref.hasBackground,
      hasItemBackground = _ref.hasItemBackground,
      hasDivider = _ref.hasDivider,
      className = _ref.className,
      children = _ref.children,
      rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
    var contextValue = React.useMemo(function () {
      return {
        disabled: disabled,
        hasItemBackground: hasItemBackground,
        hasDivider: hasDivider
      };
    }, [disabled, hasItemBackground, hasDivider]);
    return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({
      ref: outerRootRef,
      size: size,
      view: view,
      disabled: disabled,
      className: cls__default.default(List_tokens.classes.listRoot, className, variant === 'tight' && List_tokens.classes.tightListItem, disabled && List_tokens.classes.disabledList, hasBackground && List_tokens.classes.hasListBackground)
    }, rest), /*#__PURE__*/React__default.default.createElement(List_context.ListContext.Provider, {
      value: contextValue
    }, children));
  });
};
var listConfig = {
  name: 'List',
  tag: 'ul',
  layout: listRoot,
  base: List_styles.base,
  variations: {
    view: {
      css: base.base
    },
    size: {
      css: base$1.base
    },
    disabled: {
      css: base$2.base
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

exports.listConfig = listConfig;
exports.listRoot = listRoot;
