'use strict';

var clsx = require('clsx');
var React = require('react');
var Header = require('../../../../header/Header.js');
var Section = require('../../../../section/Section.js');
var SelectInputItemView = require('../SelectInputItemView.js');
var jsxRuntime = require('react/jsx-runtime');

function SelectInputGroupItemView({
  item,
  renderValue,
  needle
}) {
  const headerId = React.useId();
  const header = /*#__PURE__*/jsxRuntime.jsx(Header.default, {
    as: "header",
    role: "none",
    id: headerId,
    title: item.label
    // @ts-expect-error when we migrate ActionButton to new Button this should be sorted
    ,
    action: item.action && {
      text: item.action.label,
      onClick: item.action.onClick
    },
    className: "np-select-input-group-item-header p-x-1"
  });
  return (
    /*#__PURE__*/
    // An empty container may be rendered when no options match `needle`
    // However, pre-filtering would result in worse performance overall
    jsxRuntime.jsxs(Section.default, {
      as: "section",
      role: "group",
      "aria-labelledby": headerId,
      className: clsx.clsx('m-y-0', needle === null && 'np-select-input-group-item--without-needle'),
      children: [needle == null ? header : null, item.options.map((option, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView.SelectInputItemView
      // eslint-disable-next-line react/no-array-index-key
      , {
        item: option,
        renderValue: renderValue,
        needle: needle
      }, index))]
    })
  );
}

exports.SelectInputGroupItemView = SelectInputGroupItemView;
//# sourceMappingURL=SelectInputGroupItemView.js.map
