{"version":3,"file":"SelectInputGroupItemView.mjs","sources":["../../../../../src/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId } from 'react';\nimport Header from '../../../../header';\nimport Section from '../../../../section';\nimport { SelectInputGroupItem } from '../../SelectInput.types';\nimport { SelectInputItemView, SelectInputItemViewProps } from '..';\n\nexport interface SelectInputGroupItemViewProps<T = string> extends SelectInputItemViewProps<\n  T,\n  SelectInputGroupItem<T | undefined>\n> {}\n\n/**\n * Component that renders a group of SelectInput options with a header.\n */\nexport function SelectInputGroupItemView<T = string>({\n  item,\n  renderValue,\n  needle,\n}: SelectInputGroupItemViewProps<T>) {\n  const headerId = useId();\n\n  const header = (\n    <Header\n      as=\"header\"\n      role=\"none\"\n      id={headerId}\n      title={item.label}\n      // @ts-expect-error when we migrate ActionButton to new Button this should be sorted\n      action={\n        item.action && {\n          text: item.action.label,\n          onClick: item.action.onClick,\n        }\n      }\n      className=\"np-select-input-group-item-header p-x-1\"\n    />\n  );\n\n  return (\n    // An empty container may be rendered when no options match `needle`\n    // However, pre-filtering would result in worse performance overall\n    <Section\n      as=\"section\"\n      role=\"group\"\n      aria-labelledby={headerId}\n      className={clsx('m-y-0', needle === null && 'np-select-input-group-item--without-needle')}\n    >\n      {needle == null ? header : null}\n      {item.options.map((option, index) => (\n        <SelectInputItemView\n          // eslint-disable-next-line react/no-array-index-key\n          key={index}\n          item={option}\n          renderValue={renderValue}\n          needle={needle}\n        />\n      ))}\n    </Section>\n  );\n}\n"],"names":["SelectInputGroupItemView","item","renderValue","needle","headerId","useId","header","_jsx","Header","as","role","id","title","label","action","text","onClick","className","_jsxs","Section","clsx","children","options","map","option","index","SelectInputItemView"],"mappings":";;;;;;;AAeM,SAAUA,wBAAwBA,CAAa;EACnDC,IAAI;EACJC,WAAW;AACXC,EAAAA;AAAM,CAC2B,EAAA;AACjC,EAAA,MAAMC,QAAQ,GAAGC,KAAK,EAAE;AAExB,EAAA,MAAMC,MAAM,gBACVC,GAAA,CAACC,MAAM,EAAA;AACLC,IAAAA,EAAE,EAAC,QAAQ;AACXC,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,EAAE,EAAEP,QAAS;IACbQ,KAAK,EAAEX,IAAI,CAACY;AACZ;AAAA;AACAC,IAAAA,MAAM,EACJb,IAAI,CAACa,MAAM,IAAI;AACbC,MAAAA,IAAI,EAAEd,IAAI,CAACa,MAAM,CAACD,KAAK;AACvBG,MAAAA,OAAO,EAAEf,IAAI,CAACa,MAAM,CAACE;KAExB;AACDC,IAAAA,SAAS,EAAC;AAAyC,GAAA,CAEtD;AAED,EAAA;AAAA;AACE;AACA;AACAC,IAAAA,IAAA,CAACC,OAAO,EAAA;AACNV,MAAAA,EAAE,EAAC,SAAS;AACZC,MAAAA,IAAI,EAAC,OAAO;AACZ,MAAA,iBAAA,EAAiBN,QAAS;MAC1Ba,SAAS,EAAEG,IAAI,CAAC,OAAO,EAAEjB,MAAM,KAAK,IAAI,IAAI,4CAA4C,CAAE;MAAAkB,QAAA,EAAA,CAEzFlB,MAAM,IAAI,IAAI,GAAGG,MAAM,GAAG,IAAI,EAC9BL,IAAI,CAACqB,OAAO,CAACC,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK,kBAC9BlB,GAAA,CAACmB;AACC;AAAA,QAAA;AAEAzB,QAAAA,IAAI,EAAEuB,MAAO;AACbtB,QAAAA,WAAW,EAAEA,WAAY;AACzBC,QAAAA,MAAM,EAAEA;OAAO,EAHVsB,KAGU,CAElB,CAAC;KACK;AAAC;AAEd;;;;"}