import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef, useMemo } from 'react';
import cls from 'classnames';
import { base } from './List.styles.js';
import { classes } from './List.tokens.js';
import { base as base$1 } from './variations/_view/base.js';
import { base as base$2 } from './variations/_size/base.js';
import { base as base$3 } from './variations/_disabled/base.js';
import { ListContext } from './List.context.js';

var _excluded = ["size", "view", "disabled", "variant", "hasBackground", "hasItemBackground", "hasDivider", "className", "children"];
var listRoot = function listRoot(Root) {
  return /*#__PURE__*/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 = _objectWithoutProperties(_ref, _excluded);
    var contextValue = useMemo(function () {
      return {
        disabled: disabled,
        hasItemBackground: hasItemBackground,
        hasDivider: hasDivider
      };
    }, [disabled, hasItemBackground, hasDivider]);
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      ref: outerRootRef,
      size: size,
      view: view,
      disabled: disabled,
      className: cls(classes.listRoot, className, variant === 'tight' && classes.tightListItem, disabled && classes.disabledList, hasBackground && classes.hasListBackground)
    }, rest), /*#__PURE__*/React__default.createElement(ListContext.Provider, {
      value: contextValue
    }, children));
  });
};
var listConfig = {
  name: 'List',
  tag: 'ul',
  layout: listRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    },
    size: {
      css: base$2
    },
    disabled: {
      css: base$3
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

export { listConfig, listRoot };
