{"version":3,"file":"SelectInputOptionsContainer.mjs","sources":["../../../../../src/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.tsx"],"sourcesContent":["import { forwardRef, useEffect } from 'react';\nimport { useEffectEvent } from '../../../../common/hooks/useEffectEvent';\n\nexport interface SelectInputOptionsContainerProps extends React.ComponentPropsWithRef<'div'> {\n  onAriaActiveDescendantChange: (value: React.AriaAttributes['aria-activedescendant']) => void;\n}\n\n/**\n * Container component for SelectInput options.\n * Handles keyboard navigation and accessibility features.\n */\nexport const SelectInputOptionsContainer = forwardRef(function SelectInputOptionsContainer(\n  {\n    'aria-orientation': ariaOrientation,\n    'aria-activedescendant': ariaActiveDescendant,\n    role,\n    tabIndex,\n    onAriaActiveDescendantChange,\n    onKeyDown,\n    ...restProps\n  }: SelectInputOptionsContainerProps,\n  ref: React.ForwardedRef<HTMLDivElement | null>,\n) {\n  const handleAriaActiveDescendantChange = useEffectEvent(onAriaActiveDescendantChange);\n  useEffect(() => {\n    handleAriaActiveDescendantChange(ariaActiveDescendant);\n  }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);\n\n  return (\n    <div\n      ref={ref}\n      role=\"none\"\n      onKeyDown={(event) => {\n        // Prevent confirmation close without an active item\n        if (event.key === 'Enter' && ariaActiveDescendant == null) {\n          return;\n        }\n\n        // Required to make ListBox focusable\n        if (event.key === 'Tab') {\n          return;\n        }\n\n        // Prevent absorbing Escape early\n        if (event.key === 'Escape') {\n          onKeyDown?.({\n            ...event,\n            preventDefault: () => {},\n            stopPropagation: () => {},\n          });\n          return;\n        }\n\n        onKeyDown?.(event);\n      }}\n      {...restProps}\n    />\n  );\n});\n"],"names":["SelectInputOptionsContainer","forwardRef","ariaOrientation","ariaActiveDescendant","role","tabIndex","onAriaActiveDescendantChange","onKeyDown","restProps","ref","handleAriaActiveDescendantChange","useEffectEvent","useEffect","_jsx","event","key","preventDefault","stopPropagation"],"mappings":";;;;MAWaA,2BAA2B,gBAAGC,UAAU,CAAC,SAASD,2BAA2BA,CACxF;AACE,EAAA,kBAAkB,EAAEE,eAAe;AACnC,EAAA,uBAAuB,EAAEC,oBAAoB;EAC7CC,IAAI;EACJC,QAAQ;EACRC,4BAA4B;EAC5BC,SAAS;EACT,GAAGC;AAAS,CACqB,EACnCC,GAA8C,EAAA;AAE9C,EAAA,MAAMC,gCAAgC,GAAGC,cAAc,CAACL,4BAA4B,CAAC;AACrFM,EAAAA,SAAS,CAAC,MAAK;IACbF,gCAAgC,CAACP,oBAAoB,CAAC;AACxD,EAAA,CAAC,EAAE,CAACA,oBAAoB,EAAEO,gCAAgC,CAAC,CAAC;AAE5D,EAAA,oBACEG,GAAA,CAAA,KAAA,EAAA;AACEJ,IAAAA,GAAG,EAAEA,GAAI;AACTL,IAAAA,IAAI,EAAC,MAAM;IACXG,SAAS,EAAGO,KAAK,IAAI;AACnB;MACA,IAAIA,KAAK,CAACC,GAAG,KAAK,OAAO,IAAIZ,oBAAoB,IAAI,IAAI,EAAE;AACzD,QAAA;AACF,MAAA;AAEA;AACA,MAAA,IAAIW,KAAK,CAACC,GAAG,KAAK,KAAK,EAAE;AACvB,QAAA;AACF,MAAA;AAEA;AACA,MAAA,IAAID,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;AAC1BR,QAAAA,SAAS,GAAG;AACV,UAAA,GAAGO,KAAK;AACRE,UAAAA,cAAc,EAAEA,MAAK,CAAE,CAAC;UACxBC,eAAe,EAAEA,MAAK,CAAE;AACzB,SAAA,CAAC;AACF,QAAA;AACF,MAAA;MAEAV,SAAS,GAAGO,KAAK,CAAC;IACpB,CAAE;IAAA,GACEN;AAAS,GAAC,CACd;AAEN,CAAC;;;;"}