{"mappings":";;AAAA;;;;;;;;;;CAUC;AAYM,SAAS,0CACd,GAAwB;IAExB,OAAO;QACL;YACE,OAAO,IAAI,OAAO;QACpB;IACF;AACF;AAEO,SAAS,0CACd,MAA2B,EAC3B,eAAmD,MAAM;IAEzD,OAAO;QACL,GAAG,0CAAa,OAAO;QACvB;YACE,IAAI,aAAa,OAAO,EACtB,aAAa,OAAO,CAAC,KAAK;QAE9B;IACF;AACF;AAEO,SAAS,0CACd,GAAc;IAEd,IAAI,SAAS,CAAA,GAAA,aAAK,EAAK;IACvB,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAM,0CAAa;IAC5C,OAAO;AACT;AAEO,SAAS,0CACd,GAAoB,EACpB,YAAiD;IAEjD,IAAI,SAAS,CAAA,GAAA,aAAK,EAAK;IACvB,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAM,0CAAmB,QAAQ;IAC1D,OAAO;AACT;AAEO,SAAS,0CACd,GAAqC;IAErC,OAAO;QACL,IAAI,WAAU;YACZ,OAAO,IAAI,OAAO,IAAI,IAAI,OAAO,CAAC,iBAAiB;QACrD;IACF;AACF;AAEO,SAAS,0CACd,GAAqC;IAErC,OAAO,CAAA,GAAA,cAAM,EAAE,IAAM,0CAAa,MAAM;QAAC;KAAI;AAC/C","sources":["packages/@adobe/react-spectrum/src/utils/useDOMRef.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {\n  DOMRef,\n  DOMRefValue,\n  FocusableElement,\n  FocusableRef,\n  FocusableRefValue,\n  RefObject\n} from '@react-types/shared';\nimport {useImperativeHandle, useMemo, useRef} from 'react';\n\nexport function createDOMRef<T extends HTMLElement = HTMLElement>(\n  ref: RefObject<T | null>\n): DOMRefValue<T> {\n  return {\n    UNSAFE_getDOMNode() {\n      return ref.current;\n    }\n  };\n}\n\nexport function createFocusableRef<T extends HTMLElement = HTMLElement>(\n  domRef: RefObject<T | null>,\n  focusableRef: RefObject<FocusableElement | null> = domRef\n): FocusableRefValue<T> {\n  return {\n    ...createDOMRef(domRef),\n    focus() {\n      if (focusableRef.current) {\n        focusableRef.current.focus();\n      }\n    }\n  };\n}\n\nexport function useDOMRef<T extends HTMLElement = HTMLElement>(\n  ref: DOMRef<T>\n): RefObject<T | null> {\n  let domRef = useRef<T>(null);\n  useImperativeHandle(ref, () => createDOMRef(domRef));\n  return domRef;\n}\n\nexport function useFocusableRef<T extends HTMLElement = HTMLElement>(\n  ref: FocusableRef<T>,\n  focusableRef?: RefObject<FocusableElement | null>\n): RefObject<T | null> {\n  let domRef = useRef<T>(null);\n  useImperativeHandle(ref, () => createFocusableRef(domRef, focusableRef));\n  return domRef;\n}\n\nexport function unwrapDOMRef<T extends HTMLElement>(\n  ref: RefObject<DOMRefValue<T> | null>\n): RefObject<T | null> {\n  return {\n    get current() {\n      return ref.current && ref.current.UNSAFE_getDOMNode();\n    }\n  };\n}\n\nexport function useUnwrapDOMRef<T extends HTMLElement>(\n  ref: RefObject<DOMRefValue<T> | null>\n): RefObject<T | null> {\n  return useMemo(() => unwrapDOMRef(ref), [ref]);\n}\n"],"names":[],"version":3,"file":"useDOMRef.mjs.map"}