{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAOM,SAAS,0CACd,GAAwB,EACxB,KAAyC,EACzC,QAAkE,EAClE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;IACjC,IAAI,aAAa,YAAY;IAE7B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,IAAI,OAAO,IAAI,MAC/B;QAGF,OAAO,CAAA,GAAA,kCAAO,EAAE,IAAI,OAAO,EAAE,OAAO,aAAa;IACnD,GAAG;QAAC;QAAK;QAAO;QAAS;KAAW;AACtC","sources":["packages/react-aria/src/utils/useEvent.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {addEvent} from './domHelpers';\nimport {EventMapType, RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useEvent<T extends EventTarget, K extends keyof EventMapType<T>>(\n  ref: RefObject<T | null>,\n  event: Extract<K, string> | (string & {}),\n  listener?: (this: T, ev: EventMapType<Exclude<T, null>>[K]) => any,\n  options?: boolean | AddEventListenerOptions\n): void {\n  let handleEvent = useEffectEvent(listener);\n  let isDisabled = listener == null;\n\n  useEffect(() => {\n    if (isDisabled || ref.current == null) {\n      return;\n    }\n\n    return addEvent(ref.current, event, handleEvent, options);\n  }, [ref, event, options, isDisabled]);\n}\n"],"names":[],"version":3,"file":"useEvent.cjs.map"}