UNPKG

1.11 kBSource Map (JSON)View Raw
1{"version":3,"file":"useFocusLeave.js","sources":["../src/hooks/useFocusLeave.js"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\nexport function useFocusLeave(cb, _ref) {\n const fallbackRef = useRef()\n const ref = _ref || fallbackRef\n\n const handleFocusLeave = useCallback(\n event => {\n if (!ref?.current?.contains(event.relatedTarget)) {\n cb(event)\n }\n },\n [ref, cb]\n )\n\n return { ref, handleFocusLeave }\n}\n"],"names":["useFocusLeave","cb","_ref","fallbackRef","useRef","ref","handleFocusLeave","useCallback","event","current","contains","relatedTarget"],"mappings":";;;;;;;;;AAEO,SAASA,aAAT,CAAuBC,EAAvB,EAA2BC,IAA3B,EAAiC;AACtC,MAAMC,WAAW,GAAGC,YAAM,EAA1B;AACA,MAAMC,GAAG,GAAGH,IAAI,IAAIC,WAApB;AAEA,MAAMG,gBAAgB,GAAGC,iBAAW,CAClC,UAAAC,KAAK,EAAI;AAAA;;AACP,QAAI,EAACH,GAAD,aAACA,GAAD,uCAACA,GAAG,CAAEI,OAAN,iDAAC,aAAcC,QAAd,CAAuBF,KAAK,CAACG,aAA7B,CAAD,CAAJ,EAAkD;AAChDV,MAAAA,EAAE,CAACO,KAAD,CAAF;AACD;AACF,GALiC,EAMlC,CAACH,GAAD,EAAMJ,EAAN,CANkC,CAApC;AASA,SAAO;AAAEI,IAAAA,GAAG,EAAHA,GAAF;AAAOC,IAAAA,gBAAgB,EAAhBA;AAAP,GAAP;AACD;;;;"}
\No newline at end of file