{"version":3,"sources":["../../src/use-focus-within/index.ts"],"sourcesContent":["import { useActiveElement } from '../use-active-element'\nimport { useEventListener } from '../use-event-listener'\nimport { useSafeState } from '../use-safe-state'\nimport { useTargetElement } from '../use-target-element'\n\nimport type { ElementTarget } from '../use-target-element'\n\n/**\n * A React Hook that returns a boolean value indicating whether the component is focused or any of its children are focused.\n */\nexport function useFocusWithin(target: ElementTarget): boolean {\n  const el = useTargetElement(target)\n  const activeElement = useActiveElement()\n  const [focused, setFocused] = useSafeState(false)\n\n  useEventListener(el, 'focusin', () => setFocused(true))\n\n  useEventListener(el, 'focusout', () => setFocused(false))\n\n  return activeElement ? focused : false\n}\n"],"names":["useFocusWithin","target","el","useTargetElement","activeElement","useActiveElement","useSafeState","focused","setFocused","useEventListener"],"mappings":";;;;+BAUgBA;;;eAAAA;;;gCAViB;gCACA;4BACJ;gCACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO1B,SAASA,eAAeC,MAAqB;IAClD,IAAMC,KAAKC,IAAAA,kCAAgB,EAACF;IAC5B,IAAMG,gBAAgBC,IAAAA,kCAAgB;IACtC,IAA8BC,iCAAAA,IAAAA,0BAAY,EAAC,YAApCC,UAAuBD,kBAAdE,aAAcF;IAE9BG,IAAAA,kCAAgB,EAACP,IAAI,WAAW;eAAMM,WAAW;;IAEjDC,IAAAA,kCAAgB,EAACP,IAAI,YAAY;eAAMM,WAAW;;IAElD,OAAOJ,gBAAgBG,UAAU;AACnC"}