{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IACrC,IAAI,MAAM,YAAY;IAEtB,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,OAAO,QAAQ,IAAI,OAAO,EAAE;YAC9B,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,KAAK;QAClC;IACF,GAAG;QAAC;QAAa;QAAK;KAAI;IAE1B,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,YAAY,eACd;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,2CAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["packages/react-aria/src/virtualizer/useVirtualizerItem.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 {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from 'react-stately/useVirtualizerState';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\n\ninterface IVirtualizer {\n  updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n  layoutInfo: LayoutInfo | null,\n  virtualizer: IVirtualizer,\n  ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions): {updateSize: () => void} {\n  let {layoutInfo, virtualizer, ref} = options;\n  let key = layoutInfo?.key;\n\n  let updateSize = useCallback(() => {\n    if (key != null && ref.current) {\n      let size = getSize(ref.current);\n      virtualizer.updateItemSize(key, size);\n    }\n  }, [virtualizer, key, ref]);\n\n  useLayoutEffect(() => {\n    if (layoutInfo?.estimatedSize) {\n      updateSize();\n    }\n  });\n\n  return {updateSize};\n}\n\nfunction getSize(node: HTMLElement): Size {\n  // Reset height before measuring so we get the intrinsic size\n  let height = node.style.height;\n  node.style.height = '';\n  let size = new Size(node.scrollWidth, node.scrollHeight);\n  node.style.height = height;\n  return size;\n}\n"],"names":[],"version":3,"file":"useVirtualizerItem.cjs.map"}