@react-aria/utils 3.28.0 → 3.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/DOMFunctions.main.js.map +1 -1
  2. package/dist/DOMFunctions.module.js.map +1 -1
  3. package/dist/ShadowTreeWalker.main.js.map +1 -1
  4. package/dist/ShadowTreeWalker.module.js.map +1 -1
  5. package/dist/animation.main.js.map +1 -1
  6. package/dist/animation.module.js.map +1 -1
  7. package/dist/focusWithoutScrolling.main.js.map +1 -1
  8. package/dist/focusWithoutScrolling.module.js.map +1 -1
  9. package/dist/getOffset.main.js.map +1 -1
  10. package/dist/getOffset.module.js.map +1 -1
  11. package/dist/inertValue.main.js.map +1 -1
  12. package/dist/inertValue.module.js.map +1 -1
  13. package/dist/isFocusable.main.js.map +1 -1
  14. package/dist/isFocusable.module.js.map +1 -1
  15. package/dist/isVirtualEvent.main.js.map +1 -1
  16. package/dist/isVirtualEvent.module.js.map +1 -1
  17. package/dist/keyboard.main.js.map +1 -1
  18. package/dist/keyboard.module.js.map +1 -1
  19. package/dist/openLink.main.js +1 -1
  20. package/dist/openLink.main.js.map +1 -1
  21. package/dist/openLink.mjs +1 -1
  22. package/dist/openLink.module.js +1 -1
  23. package/dist/openLink.module.js.map +1 -1
  24. package/dist/platform.main.js +1 -0
  25. package/dist/platform.main.js.map +1 -1
  26. package/dist/platform.mjs +1 -0
  27. package/dist/platform.module.js +1 -0
  28. package/dist/platform.module.js.map +1 -1
  29. package/dist/runAfterTransition.main.js.map +1 -1
  30. package/dist/runAfterTransition.module.js.map +1 -1
  31. package/dist/scrollIntoView.main.js.map +1 -1
  32. package/dist/scrollIntoView.module.js.map +1 -1
  33. package/dist/types.d.ts +9 -30
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/useEvent.main.js.map +1 -1
  36. package/dist/useEvent.module.js.map +1 -1
  37. package/dist/useFormReset.main.js.map +1 -1
  38. package/dist/useFormReset.module.js.map +1 -1
  39. package/dist/useId.main.js +4 -3
  40. package/dist/useId.main.js.map +1 -1
  41. package/dist/useId.mjs +4 -3
  42. package/dist/useId.module.js +4 -3
  43. package/dist/useId.module.js.map +1 -1
  44. package/dist/useLoadMore.main.js.map +1 -1
  45. package/dist/useLoadMore.module.js.map +1 -1
  46. package/dist/useResizeObserver.main.js.map +1 -1
  47. package/dist/useResizeObserver.module.js.map +1 -1
  48. package/dist/useSyncRef.main.js.map +1 -1
  49. package/dist/useSyncRef.module.js.map +1 -1
  50. package/dist/useUpdateLayoutEffect.main.js.map +1 -1
  51. package/dist/useUpdateLayoutEffect.module.js.map +1 -1
  52. package/package.json +6 -6
  53. package/src/animation.ts +6 -6
  54. package/src/focusWithoutScrolling.ts +1 -1
  55. package/src/getOffset.ts +3 -1
  56. package/src/inertValue.ts +1 -1
  57. package/src/isFocusable.ts +2 -2
  58. package/src/isVirtualEvent.ts +1 -1
  59. package/src/keyboard.tsx +1 -1
  60. package/src/openLink.tsx +9 -9
  61. package/src/runAfterTransition.ts +1 -1
  62. package/src/scrollIntoView.ts +2 -2
  63. package/src/shadowdom/DOMFunctions.ts +5 -5
  64. package/src/shadowdom/ShadowTreeWalker.ts +1 -1
  65. package/src/useEvent.ts +1 -1
  66. package/src/useFormReset.ts +1 -1
  67. package/src/useId.ts +12 -5
  68. package/src/useLoadMore.ts +2 -2
  69. package/src/useResizeObserver.ts +1 -1
  70. package/src/useSyncRef.ts +1 -1
  71. package/src/useUpdateLayoutEffect.ts +1 -1
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAwBM,SAAS,0CAAY,KAAoB,EAAE,GAAkC;IAClF,IAAI,aAAC,SAAS,cAAE,UAAU,gBAAE,eAAe,UAAG,KAAK,EAAC,GAAG;IAEvD,iEAAiE;IACjE,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QACzB,IAAI,IAAI,OAAO,IAAI,CAAC,aAAa,OAAO,IAAI,YAAY;YACtD,IAAI,iBAAiB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG;YAE9H,IAAI,gBAAgB;gBAClB,aAAa,OAAO,GAAG;gBACvB;YACF;QACF;IACF,GAAG;QAAC;QAAY;QAAK;KAAa;IAElC,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,CAAA,GAAA,yCAAc,EAAE;QACd,6DAA6D;QAC7D,wCAAwC;QACxC,IAAI,UAAU,UAAU,OAAO,EAAE;YAC/B,aAAa,OAAO,GAAG;YACvB,UAAU,OAAO,GAAG;QACtB;QAEA,0HAA0H;QAC1H,4HAA4H;QAC5H,gFAAgF;QAChF,IAAI,iBAAiB,CAAA,gBAAA,0BAAA,IAAK,OAAO,KAC5B,CAAC,aAAa,OAAO,IACrB,cACC,CAAA,CAAC,SAAS,UAAU,UAAU,OAAO,AAAD,KACrC,IAAI,OAAO,CAAC,YAAY,KAAK,IAAI,OAAO,CAAC,YAAY;QAE1D,IAAI,gBAAgB;YAClB,aAAa,OAAO,GAAG;YACvB,uBAAA,iCAAA;QACF;QAEA,UAAU,OAAO,GAAG;IACtB,GAAG;QAAC;QAAW;QAAY;QAAO;QAAK;KAAM;IAE7C,0DAA0D;IAC1D,oEAAoE;IACpE,kHAAkH;IAClH,CAAA,GAAA,yCAAO,EAAE,KAAK,UAAU;AAC1B","sources":["packages/@react-aria/utils/src/useLoadMore.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {RefObject, useCallback, useRef} from 'react';\nimport {useEvent} from './useEvent';\n \nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport interface LoadMoreProps {\n /** Whether data is currently being loaded. */\n isLoading?: boolean,\n /** Handler that is called when more items should be loaded, e.g. while scrolling near the bottom. */\n onLoadMore?: () => void,\n /**\n * The amount of offset from the bottom of your scrollable region that should trigger load more.\n * Uses a percentage value relative to the scroll body's client height. Load more is then triggered\n * when your current scroll position's distance from the bottom of the currently loaded list of items is less than\n * or equal to the provided value. (e.g. 1 = 100% of the scroll region's height).\n * @default 1\n */\n scrollOffset?: number,\n /** The data currently loaded. */\n items?: any\n}\n\nexport function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>) {\n let {isLoading, onLoadMore, scrollOffset = 1, items} = props;\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let isLoadingRef = useRef(isLoading);\n let prevProps = useRef(props);\n let onScroll = useCallback(() => {\n if (ref.current && !isLoadingRef.current && onLoadMore) {\n let shouldLoadMore = ref.current.scrollHeight - ref.current.scrollTop - ref.current.clientHeight < ref.current.clientHeight * scrollOffset;\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n }\n }, [onLoadMore, ref, scrollOffset]);\n\n let lastItems = useRef(items);\n useLayoutEffect(() => {\n // Only update isLoadingRef if props object actually changed,\n // not if a local state change occurred.\n if (props !== prevProps.current) {\n isLoadingRef.current = isLoading;\n prevProps.current = props;\n }\n\n // TODO: Eventually this hook will move back into RAC during which we will accept the collection as a option to this hook.\n // We will only load more if the collection has changed after the last load to prevent multiple onLoadMore from being called\n // while the data from the last onLoadMore is being processed by RAC collection.\n let shouldLoadMore = ref?.current\n && !isLoadingRef.current\n && onLoadMore\n && (!items || items !== lastItems.current)\n && ref.current.clientHeight === ref.current.scrollHeight;\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore?.();\n }\n\n lastItems.current = items;\n }, [isLoading, onLoadMore, props, ref, items]);\n\n // TODO: maybe this should still just return scroll props?\n // Test against case where the ref isn't defined when this is called\n // Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll\n useEvent(ref, 'scroll', onScroll);\n}\n"],"names":[],"version":3,"file":"useLoadMore.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAwBM,SAAS,0CAAY,KAAoB,EAAE,GAAkC;IAClF,IAAI,aAAC,SAAS,cAAE,UAAU,gBAAE,eAAe,UAAG,KAAK,EAAC,GAAG;IAEvD,iEAAiE;IACjE,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QACzB,IAAI,IAAI,OAAO,IAAI,CAAC,aAAa,OAAO,IAAI,YAAY;YACtD,IAAI,iBAAiB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG;YAE9H,IAAI,gBAAgB;gBAClB,aAAa,OAAO,GAAG;gBACvB;YACF;QACF;IACF,GAAG;QAAC;QAAY;QAAK;KAAa;IAElC,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,CAAA,GAAA,yCAAc,EAAE;QACd,6DAA6D;QAC7D,wCAAwC;QACxC,IAAI,UAAU,UAAU,OAAO,EAAE;YAC/B,aAAa,OAAO,GAAG;YACvB,UAAU,OAAO,GAAG;QACtB;QAEA,0HAA0H;QAC1H,4HAA4H;QAC5H,gFAAgF;QAChF,IAAI,iBAAiB,CAAA,gBAAA,0BAAA,IAAK,OAAO,KAC5B,CAAC,aAAa,OAAO,IACrB,cACC,CAAA,CAAC,SAAS,UAAU,UAAU,OAAO,AAAD,KACrC,IAAI,OAAO,CAAC,YAAY,KAAK,IAAI,OAAO,CAAC,YAAY;QAE1D,IAAI,gBAAgB;YAClB,aAAa,OAAO,GAAG;YACvB,uBAAA,iCAAA;QACF;QAEA,UAAU,OAAO,GAAG;IACtB,GAAG;QAAC;QAAW;QAAY;QAAO;QAAK;KAAM;IAE7C,0DAA0D;IAC1D,oEAAoE;IACpE,kHAAkH;IAClH,CAAA,GAAA,yCAAO,EAAE,KAAK,UAAU;AAC1B","sources":["packages/@react-aria/utils/src/useLoadMore.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {RefObject, useCallback, useRef} from 'react';\nimport {useEvent} from './useEvent';\n\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport interface LoadMoreProps {\n /** Whether data is currently being loaded. */\n isLoading?: boolean,\n /** Handler that is called when more items should be loaded, e.g. while scrolling near the bottom. */\n onLoadMore?: () => void,\n /**\n * The amount of offset from the bottom of your scrollable region that should trigger load more.\n * Uses a percentage value relative to the scroll body's client height. Load more is then triggered\n * when your current scroll position's distance from the bottom of the currently loaded list of items is less than\n * or equal to the provided value. (e.g. 1 = 100% of the scroll region's height).\n * @default 1\n */\n scrollOffset?: number,\n /** The data currently loaded. */\n items?: any\n}\n\nexport function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>): void {\n let {isLoading, onLoadMore, scrollOffset = 1, items} = props;\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let isLoadingRef = useRef(isLoading);\n let prevProps = useRef(props);\n let onScroll = useCallback(() => {\n if (ref.current && !isLoadingRef.current && onLoadMore) {\n let shouldLoadMore = ref.current.scrollHeight - ref.current.scrollTop - ref.current.clientHeight < ref.current.clientHeight * scrollOffset;\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n }\n }, [onLoadMore, ref, scrollOffset]);\n\n let lastItems = useRef(items);\n useLayoutEffect(() => {\n // Only update isLoadingRef if props object actually changed,\n // not if a local state change occurred.\n if (props !== prevProps.current) {\n isLoadingRef.current = isLoading;\n prevProps.current = props;\n }\n\n // TODO: Eventually this hook will move back into RAC during which we will accept the collection as a option to this hook.\n // We will only load more if the collection has changed after the last load to prevent multiple onLoadMore from being called\n // while the data from the last onLoadMore is being processed by RAC collection.\n let shouldLoadMore = ref?.current\n && !isLoadingRef.current\n && onLoadMore\n && (!items || items !== lastItems.current)\n && ref.current.clientHeight === ref.current.scrollHeight;\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore?.();\n }\n\n lastItems.current = items;\n }, [isLoading, onLoadMore, props, ref, items]);\n\n // TODO: maybe this should still just return scroll props?\n // Test against case where the ref isn't defined when this is called\n // Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll\n useEvent(ref, 'scroll', onScroll);\n}\n"],"names":[],"version":3,"file":"useLoadMore.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAIA,SAAS;IACP,OAAO,OAAO,OAAO,cAAc,KAAK;AAC1C;AAQO,SAAS,0CAAqC,OAAwC;IAC3F,MAAM,OAAC,GAAG,OAAE,GAAG,YAAE,QAAQ,EAAC,GAAG;IAE7B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,UAAU,gBAAA,0BAAA,IAAK,OAAO;QAC1B,IAAI,CAAC,SACH;QAGF,IAAI,CAAC,2CAAqB;YACxB,OAAO,gBAAgB,CAAC,UAAU,UAAU;YAC5C,OAAO;gBACL,OAAO,mBAAmB,CAAC,UAAU,UAAU;YACjD;QACF,OAAO;YAEL,MAAM,yBAAyB,IAAI,OAAO,cAAc,CAAC,CAAC;gBACxD,IAAI,CAAC,QAAQ,MAAM,EACjB;gBAGF;YACF;YACA,uBAAuB,OAAO,CAAC,SAAS;qBAAC;YAAG;YAE5C,OAAO;gBACL,IAAI,SACF,uBAAuB,SAAS,CAAC;YAErC;QACF;IAEF,GAAG;QAAC;QAAU;QAAK;KAAI;AACzB","sources":["packages/@react-aria/utils/src/useResizeObserver.ts"],"sourcesContent":["\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\n\nfunction hasResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n}\n\ntype useResizeObserverOptionsType<T> = {\n ref: RefObject<T | undefined | null> | undefined,\n box?: ResizeObserverBoxOptions,\n onResize: () => void\n}\n\nexport function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>) {\n const {ref, box, onResize} = options;\n\n useEffect(() => {\n let element = ref?.current;\n if (!element) {\n return;\n }\n\n if (!hasResizeObserver()) {\n window.addEventListener('resize', onResize, false);\n return () => {\n window.removeEventListener('resize', onResize, false);\n };\n } else {\n\n const resizeObserverInstance = new window.ResizeObserver((entries) => {\n if (!entries.length) {\n return;\n }\n\n onResize();\n });\n resizeObserverInstance.observe(element, {box});\n\n return () => {\n if (element) {\n resizeObserverInstance.unobserve(element);\n }\n };\n }\n\n }, [onResize, ref, box]);\n}\n"],"names":[],"version":3,"file":"useResizeObserver.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAIA,SAAS;IACP,OAAO,OAAO,OAAO,cAAc,KAAK;AAC1C;AAQO,SAAS,0CAAqC,OAAwC;IAC3F,MAAM,OAAC,GAAG,OAAE,GAAG,YAAE,QAAQ,EAAC,GAAG;IAE7B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,UAAU,gBAAA,0BAAA,IAAK,OAAO;QAC1B,IAAI,CAAC,SACH;QAGF,IAAI,CAAC,2CAAqB;YACxB,OAAO,gBAAgB,CAAC,UAAU,UAAU;YAC5C,OAAO;gBACL,OAAO,mBAAmB,CAAC,UAAU,UAAU;YACjD;QACF,OAAO;YAEL,MAAM,yBAAyB,IAAI,OAAO,cAAc,CAAC,CAAC;gBACxD,IAAI,CAAC,QAAQ,MAAM,EACjB;gBAGF;YACF;YACA,uBAAuB,OAAO,CAAC,SAAS;qBAAC;YAAG;YAE5C,OAAO;gBACL,IAAI,SACF,uBAAuB,SAAS,CAAC;YAErC;QACF;IAEF,GAAG;QAAC;QAAU;QAAK;KAAI;AACzB","sources":["packages/@react-aria/utils/src/useResizeObserver.ts"],"sourcesContent":["\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\n\nfunction hasResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n}\n\ntype useResizeObserverOptionsType<T> = {\n ref: RefObject<T | undefined | null> | undefined,\n box?: ResizeObserverBoxOptions,\n onResize: () => void\n}\n\nexport function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void {\n const {ref, box, onResize} = options;\n\n useEffect(() => {\n let element = ref?.current;\n if (!element) {\n return;\n }\n\n if (!hasResizeObserver()) {\n window.addEventListener('resize', onResize, false);\n return () => {\n window.removeEventListener('resize', onResize, false);\n };\n } else {\n\n const resizeObserverInstance = new window.ResizeObserver((entries) => {\n if (!entries.length) {\n return;\n }\n\n onResize();\n });\n resizeObserverInstance.observe(element, {box});\n\n return () => {\n if (element) {\n resizeObserverInstance.unobserve(element);\n }\n };\n }\n\n }, [onResize, ref, box]);\n}\n"],"names":[],"version":3,"file":"useResizeObserver.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAIA,SAAS;IACP,OAAO,OAAO,OAAO,cAAc,KAAK;AAC1C;AAQO,SAAS,0CAAqC,OAAwC;IAC3F,MAAM,OAAC,GAAG,OAAE,GAAG,YAAE,QAAQ,EAAC,GAAG;IAE7B,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,gBAAA,0BAAA,IAAK,OAAO;QAC1B,IAAI,CAAC,SACH;QAGF,IAAI,CAAC,2CAAqB;YACxB,OAAO,gBAAgB,CAAC,UAAU,UAAU;YAC5C,OAAO;gBACL,OAAO,mBAAmB,CAAC,UAAU,UAAU;YACjD;QACF,OAAO;YAEL,MAAM,yBAAyB,IAAI,OAAO,cAAc,CAAC,CAAC;gBACxD,IAAI,CAAC,QAAQ,MAAM,EACjB;gBAGF;YACF;YACA,uBAAuB,OAAO,CAAC,SAAS;qBAAC;YAAG;YAE5C,OAAO;gBACL,IAAI,SACF,uBAAuB,SAAS,CAAC;YAErC;QACF;IAEF,GAAG;QAAC;QAAU;QAAK;KAAI;AACzB","sources":["packages/@react-aria/utils/src/useResizeObserver.ts"],"sourcesContent":["\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\n\nfunction hasResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n}\n\ntype useResizeObserverOptionsType<T> = {\n ref: RefObject<T | undefined | null> | undefined,\n box?: ResizeObserverBoxOptions,\n onResize: () => void\n}\n\nexport function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>) {\n const {ref, box, onResize} = options;\n\n useEffect(() => {\n let element = ref?.current;\n if (!element) {\n return;\n }\n\n if (!hasResizeObserver()) {\n window.addEventListener('resize', onResize, false);\n return () => {\n window.removeEventListener('resize', onResize, false);\n };\n } else {\n\n const resizeObserverInstance = new window.ResizeObserver((entries) => {\n if (!entries.length) {\n return;\n }\n\n onResize();\n });\n resizeObserverInstance.observe(element, {box});\n\n return () => {\n if (element) {\n resizeObserverInstance.unobserve(element);\n }\n };\n }\n\n }, [onResize, ref, box]);\n}\n"],"names":[],"version":3,"file":"useResizeObserver.module.js.map"}
1
+ {"mappings":";;;AAIA,SAAS;IACP,OAAO,OAAO,OAAO,cAAc,KAAK;AAC1C;AAQO,SAAS,0CAAqC,OAAwC;IAC3F,MAAM,OAAC,GAAG,OAAE,GAAG,YAAE,QAAQ,EAAC,GAAG;IAE7B,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,gBAAA,0BAAA,IAAK,OAAO;QAC1B,IAAI,CAAC,SACH;QAGF,IAAI,CAAC,2CAAqB;YACxB,OAAO,gBAAgB,CAAC,UAAU,UAAU;YAC5C,OAAO;gBACL,OAAO,mBAAmB,CAAC,UAAU,UAAU;YACjD;QACF,OAAO;YAEL,MAAM,yBAAyB,IAAI,OAAO,cAAc,CAAC,CAAC;gBACxD,IAAI,CAAC,QAAQ,MAAM,EACjB;gBAGF;YACF;YACA,uBAAuB,OAAO,CAAC,SAAS;qBAAC;YAAG;YAE5C,OAAO;gBACL,IAAI,SACF,uBAAuB,SAAS,CAAC;YAErC;QACF;IAEF,GAAG;QAAC;QAAU;QAAK;KAAI;AACzB","sources":["packages/@react-aria/utils/src/useResizeObserver.ts"],"sourcesContent":["\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\n\nfunction hasResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n}\n\ntype useResizeObserverOptionsType<T> = {\n ref: RefObject<T | undefined | null> | undefined,\n box?: ResizeObserverBoxOptions,\n onResize: () => void\n}\n\nexport function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void {\n const {ref, box, onResize} = options;\n\n useEffect(() => {\n let element = ref?.current;\n if (!element) {\n return;\n }\n\n if (!hasResizeObserver()) {\n window.addEventListener('resize', onResize, false);\n return () => {\n window.removeEventListener('resize', onResize, false);\n };\n } else {\n\n const resizeObserverInstance = new window.ResizeObserver((entries) => {\n if (!entries.length) {\n return;\n }\n\n onResize();\n });\n resizeObserverInstance.observe(element, {box});\n\n return () => {\n if (element) {\n resizeObserverInstance.unobserve(element);\n }\n };\n }\n\n }, [onResize, ref, box]);\n}\n"],"names":[],"version":3,"file":"useResizeObserver.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAWM,SAAS,0CAAc,OAAgC,EAAE,GAAyB;IACvF,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,WAAW,QAAQ,GAAG,IAAI,KAAK;YACjC,QAAQ,GAAG,CAAC,OAAO,GAAG,IAAI,OAAO;YACjC,OAAO;gBACL,IAAI,QAAQ,GAAG,EACb,QAAQ,GAAG,CAAC,OAAO,GAAG;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/utils/src/useSyncRef.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 {MutableRefObject} from 'react';\nimport {RefObject} from '@react-types/shared';\nimport {useLayoutEffect} from './';\n\ninterface ContextValue<T> {\n ref?: MutableRefObject<T | null>\n}\n\n// Syncs ref from context with ref passed to hook\nexport function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>) {\n useLayoutEffect(() => {\n if (context && context.ref && ref) {\n context.ref.current = ref.current;\n return () => {\n if (context.ref) {\n context.ref.current = null;\n }\n };\n }\n });\n}\n"],"names":[],"version":3,"file":"useSyncRef.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAWM,SAAS,0CAAc,OAAgC,EAAE,GAAyB;IACvF,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,WAAW,QAAQ,GAAG,IAAI,KAAK;YACjC,QAAQ,GAAG,CAAC,OAAO,GAAG,IAAI,OAAO;YACjC,OAAO;gBACL,IAAI,QAAQ,GAAG,EACb,QAAQ,GAAG,CAAC,OAAO,GAAG;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/utils/src/useSyncRef.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 {MutableRefObject} from 'react';\nimport {RefObject} from '@react-types/shared';\nimport {useLayoutEffect} from './';\n\ninterface ContextValue<T> {\n ref?: MutableRefObject<T | null>\n}\n\n// Syncs ref from context with ref passed to hook\nexport function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>): void {\n useLayoutEffect(() => {\n if (context && context.ref && ref) {\n context.ref.current = ref.current;\n return () => {\n if (context.ref) {\n context.ref.current = null;\n }\n };\n }\n });\n}\n"],"names":[],"version":3,"file":"useSyncRef.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAWM,SAAS,0CAAc,OAAgC,EAAE,GAAyB;IACvF,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,WAAW,QAAQ,GAAG,IAAI,KAAK;YACjC,QAAQ,GAAG,CAAC,OAAO,GAAG,IAAI,OAAO;YACjC,OAAO;gBACL,IAAI,QAAQ,GAAG,EACb,QAAQ,GAAG,CAAC,OAAO,GAAG;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/utils/src/useSyncRef.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 {MutableRefObject} from 'react';\nimport {RefObject} from '@react-types/shared';\nimport {useLayoutEffect} from './';\n\ninterface ContextValue<T> {\n ref?: MutableRefObject<T | null>\n}\n\n// Syncs ref from context with ref passed to hook\nexport function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>) {\n useLayoutEffect(() => {\n if (context && context.ref && ref) {\n context.ref.current = ref.current;\n return () => {\n if (context.ref) {\n context.ref.current = null;\n }\n };\n }\n });\n}\n"],"names":[],"version":3,"file":"useSyncRef.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAWM,SAAS,0CAAc,OAAgC,EAAE,GAAyB;IACvF,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,WAAW,QAAQ,GAAG,IAAI,KAAK;YACjC,QAAQ,GAAG,CAAC,OAAO,GAAG,IAAI,OAAO;YACjC,OAAO;gBACL,IAAI,QAAQ,GAAG,EACb,QAAQ,GAAG,CAAC,OAAO,GAAG;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/utils/src/useSyncRef.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 {MutableRefObject} from 'react';\nimport {RefObject} from '@react-types/shared';\nimport {useLayoutEffect} from './';\n\ninterface ContextValue<T> {\n ref?: MutableRefObject<T | null>\n}\n\n// Syncs ref from context with ref passed to hook\nexport function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>): void {\n useLayoutEffect(() => {\n if (context && context.ref && ref) {\n context.ref.current = ref.current;\n return () => {\n if (context.ref) {\n context.ref.current = null;\n }\n };\n }\n });\n}\n"],"names":[],"version":3,"file":"useSyncRef.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CAAsB,MAAsB,EAAE,YAAmB;IAC/E,MAAM,iBAAiB,CAAA,GAAA,mBAAK,EAAE;IAC9B,MAAM,WAAW,CAAA,GAAA,mBAAK,EAAgB;IAEtC,CAAA,GAAA,yCAAc,EAAE;QACd,eAAe,OAAO,GAAG;QACzB,OAAO;YACL,eAAe,OAAO,GAAG;QAC3B;IACF,GAAG,EAAE;IAEL,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,GAAG;aACpB,IAAI,CAAC,SAAS,OAAO,IAAI,aAAa,IAAI,CAAC,CAAC,KAAK,IAAM,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,IACvF;QAEF,SAAS,OAAO,GAAG;IACnB,uDAAuD;IACzD,GAAG;AACL","sources":["packages/@react-aria/utils/src/useUpdateLayoutEffect.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {EffectCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\n// Like useLayoutEffect, but only called for updates after the initial render.\nexport function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]) {\n const isInitialMount = useRef(true);\n const lastDeps = useRef<any[] | null>(null);\n\n useLayoutEffect(() => {\n isInitialMount.current = true;\n return () => {\n isInitialMount.current = false;\n };\n }, []);\n\n useLayoutEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n } else if (!lastDeps.current || dependencies.some((dep, i) => !Object.is(dep, lastDeps[i]))) {\n effect();\n }\n lastDeps.current = dependencies;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n}\n"],"names":[],"version":3,"file":"useUpdateLayoutEffect.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CAAsB,MAAsB,EAAE,YAAmB;IAC/E,MAAM,iBAAiB,CAAA,GAAA,mBAAK,EAAE;IAC9B,MAAM,WAAW,CAAA,GAAA,mBAAK,EAAgB;IAEtC,CAAA,GAAA,yCAAc,EAAE;QACd,eAAe,OAAO,GAAG;QACzB,OAAO;YACL,eAAe,OAAO,GAAG;QAC3B;IACF,GAAG,EAAE;IAEL,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,GAAG;aACpB,IAAI,CAAC,SAAS,OAAO,IAAI,aAAa,IAAI,CAAC,CAAC,KAAK,IAAM,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,IACvF;QAEF,SAAS,OAAO,GAAG;IACnB,uDAAuD;IACzD,GAAG;AACL","sources":["packages/@react-aria/utils/src/useUpdateLayoutEffect.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {EffectCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\n// Like useLayoutEffect, but only called for updates after the initial render.\nexport function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void {\n const isInitialMount = useRef(true);\n const lastDeps = useRef<any[] | null>(null);\n\n useLayoutEffect(() => {\n isInitialMount.current = true;\n return () => {\n isInitialMount.current = false;\n };\n }, []);\n\n useLayoutEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n } else if (!lastDeps.current || dependencies.some((dep, i) => !Object.is(dep, lastDeps[i]))) {\n effect();\n }\n lastDeps.current = dependencies;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n}\n"],"names":[],"version":3,"file":"useUpdateLayoutEffect.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CAAsB,MAAsB,EAAE,YAAmB;IAC/E,MAAM,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAC9B,MAAM,WAAW,CAAA,GAAA,aAAK,EAAgB;IAEtC,CAAA,GAAA,yCAAc,EAAE;QACd,eAAe,OAAO,GAAG;QACzB,OAAO;YACL,eAAe,OAAO,GAAG;QAC3B;IACF,GAAG,EAAE;IAEL,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,GAAG;aACpB,IAAI,CAAC,SAAS,OAAO,IAAI,aAAa,IAAI,CAAC,CAAC,KAAK,IAAM,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,IACvF;QAEF,SAAS,OAAO,GAAG;IACnB,uDAAuD;IACzD,GAAG;AACL","sources":["packages/@react-aria/utils/src/useUpdateLayoutEffect.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {EffectCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\n// Like useLayoutEffect, but only called for updates after the initial render.\nexport function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]) {\n const isInitialMount = useRef(true);\n const lastDeps = useRef<any[] | null>(null);\n\n useLayoutEffect(() => {\n isInitialMount.current = true;\n return () => {\n isInitialMount.current = false;\n };\n }, []);\n\n useLayoutEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n } else if (!lastDeps.current || dependencies.some((dep, i) => !Object.is(dep, lastDeps[i]))) {\n effect();\n }\n lastDeps.current = dependencies;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n}\n"],"names":[],"version":3,"file":"useUpdateLayoutEffect.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CAAsB,MAAsB,EAAE,YAAmB;IAC/E,MAAM,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAC9B,MAAM,WAAW,CAAA,GAAA,aAAK,EAAgB;IAEtC,CAAA,GAAA,yCAAc,EAAE;QACd,eAAe,OAAO,GAAG;QACzB,OAAO;YACL,eAAe,OAAO,GAAG;QAC3B;IACF,GAAG,EAAE;IAEL,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,GAAG;aACpB,IAAI,CAAC,SAAS,OAAO,IAAI,aAAa,IAAI,CAAC,CAAC,KAAK,IAAM,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,IACvF;QAEF,SAAS,OAAO,GAAG;IACnB,uDAAuD;IACzD,GAAG;AACL","sources":["packages/@react-aria/utils/src/useUpdateLayoutEffect.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {EffectCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\n// Like useLayoutEffect, but only called for updates after the initial render.\nexport function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void {\n const isInitialMount = useRef(true);\n const lastDeps = useRef<any[] | null>(null);\n\n useLayoutEffect(() => {\n isInitialMount.current = true;\n return () => {\n isInitialMount.current = false;\n };\n }, []);\n\n useLayoutEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n } else if (!lastDeps.current || dependencies.some((dep, i) => !Object.is(dep, lastDeps[i]))) {\n effect();\n }\n lastDeps.current = dependencies;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n}\n"],"names":[],"version":3,"file":"useUpdateLayoutEffect.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/utils",
3
- "version": "3.28.0",
3
+ "version": "3.28.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,10 +22,10 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/ssr": "^3.9.7",
26
- "@react-stately/flags": "^3.1.0",
27
- "@react-stately/utils": "^3.10.5",
28
- "@react-types/shared": "^3.28.0",
25
+ "@react-aria/ssr": "^3.9.8",
26
+ "@react-stately/flags": "^3.1.1",
27
+ "@react-stately/utils": "^3.10.6",
28
+ "@react-types/shared": "^3.29.0",
29
29
  "@swc/helpers": "^0.5.0",
30
30
  "clsx": "^2.0.0"
31
31
  },
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "4d3c72c94eea2d72eb3a0e7d56000c6ef7e39726"
39
+ "gitHead": "9b66d270572f482948afee95622a85cdf68ed408"
40
40
  }
package/src/animation.ts CHANGED
@@ -14,10 +14,10 @@ import {flushSync} from 'react-dom';
14
14
  import {RefObject, useCallback, useState} from 'react';
15
15
  import {useLayoutEffect} from './useLayoutEffect';
16
16
 
17
- export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {
17
+ export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true): boolean {
18
18
  let [isEntering, setEntering] = useState(true);
19
19
  let isAnimationReady = isEntering && isReady;
20
-
20
+
21
21
  // There are two cases for entry animations:
22
22
  // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
23
  // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
@@ -38,7 +38,7 @@ export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: b
38
38
  return isAnimationReady;
39
39
  }
40
40
 
41
- export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {
41
+ export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean): boolean {
42
42
  let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');
43
43
 
44
44
  switch (exitState) {
@@ -71,7 +71,7 @@ export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boo
71
71
  return isExiting;
72
72
  }
73
73
 
74
- function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {
74
+ function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void): void {
75
75
  useLayoutEffect(() => {
76
76
  if (isActive && ref.current) {
77
77
  if (!('getAnimations' in ref.current)) {
@@ -79,7 +79,7 @@ function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onE
79
79
  onEnd();
80
80
  return;
81
81
  }
82
-
82
+
83
83
  let animations = ref.current.getAnimations();
84
84
  if (animations.length === 0) {
85
85
  onEnd();
@@ -94,7 +94,7 @@ function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onE
94
94
  });
95
95
  }
96
96
  }).catch(() => {});
97
-
97
+
98
98
  return () => {
99
99
  canceled = true;
100
100
  };
@@ -28,7 +28,7 @@ interface ScrollableElement {
28
28
  scrollLeft: number
29
29
  }
30
30
 
31
- export function focusWithoutScrolling(element: FocusableElement) {
31
+ export function focusWithoutScrolling(element: FocusableElement): void {
32
32
  if (supportsPreventScroll()) {
33
33
  element.focus({preventScroll: true});
34
34
  } else {
package/src/getOffset.ts CHANGED
@@ -10,7 +10,9 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export function getOffset(element, reverse, orientation = 'horizontal') {
13
+ import {Orientation} from '@react-types/shared';
14
+
15
+ export function getOffset(element: HTMLElement, reverse?: boolean, orientation: Orientation = 'horizontal'): number {
14
16
  let rect = element.getBoundingClientRect();
15
17
  if (reverse) {
16
18
  return orientation === 'horizontal' ? rect.right : rect.bottom;
package/src/inertValue.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {version} from 'react';
2
2
 
3
- export function inertValue(value?: boolean) {
3
+ export function inertValue(value?: boolean): string | boolean | undefined {
4
4
  const pieces = version.split('.');
5
5
  const major = parseInt(pieces[0], 10);
6
6
  if (major >= 19) {
@@ -19,10 +19,10 @@ const FOCUSABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]),') + '
19
19
  focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
20
20
  const TABBABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
21
21
 
22
- export function isFocusable(element: Element) {
22
+ export function isFocusable(element: Element): boolean {
23
23
  return element.matches(FOCUSABLE_ELEMENT_SELECTOR);
24
24
  }
25
25
 
26
- export function isTabbable(element: Element) {
26
+ export function isTabbable(element: Element): boolean {
27
27
  return element.matches(TABBABLE_ELEMENT_SELECTOR);
28
28
  }
@@ -39,7 +39,7 @@ export function isVirtualClick(event: MouseEvent | PointerEvent): boolean {
39
39
  return event.detail === 0 && !(event as PointerEvent).pointerType;
40
40
  }
41
41
 
42
- export function isVirtualPointerEvent(event: PointerEvent) {
42
+ export function isVirtualPointerEvent(event: PointerEvent): boolean {
43
43
  // If the pointer size is zero, then we assume it's from a screen reader.
44
44
  // Android TalkBack double tap will sometimes return a event with width and height of 1
45
45
  // and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
package/src/keyboard.tsx CHANGED
@@ -18,7 +18,7 @@ interface Event {
18
18
  metaKey: boolean
19
19
  }
20
20
 
21
- export function isCtrlKeyPressed(e: Event) {
21
+ export function isCtrlKeyPressed(e: Event): boolean {
22
22
  if (isMac()) {
23
23
  return e.metaKey;
24
24
  }
package/src/openLink.tsx CHANGED
@@ -13,7 +13,7 @@
13
13
  import {focusWithoutScrolling, isMac, isWebKit} from './index';
14
14
  import {Href, LinkDOMProps, RouterOptions} from '@react-types/shared';
15
15
  import {isFirefox, isIPad} from './platform';
16
- import React, {createContext, ReactNode, useContext, useMemo} from 'react';
16
+ import React, {createContext, DOMAttributes, ReactNode, useContext, useMemo} from 'react';
17
17
 
18
18
  interface Router {
19
19
  isNative: boolean,
@@ -37,7 +37,7 @@ interface RouterProviderProps {
37
37
  * A RouterProvider accepts a `navigate` function from a framework or client side router,
38
38
  * and provides it to all nested React Aria links to enable client side navigation.
39
39
  */
40
- export function RouterProvider(props: RouterProviderProps) {
40
+ export function RouterProvider(props: RouterProviderProps): ReactNode {
41
41
  let {children, navigate, useHref} = props;
42
42
 
43
43
  let ctx = useMemo(() => ({
@@ -72,7 +72,7 @@ interface Modifiers {
72
72
  shiftKey?: boolean
73
73
  }
74
74
 
75
- export function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers) {
75
+ export function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers): boolean {
76
76
  // Use getAttribute here instead of link.target. Firefox will default link.target to "_parent" when inside an iframe.
77
77
  let target = link.getAttribute('target');
78
78
  return (
@@ -86,7 +86,7 @@ export function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifie
86
86
  );
87
87
  }
88
88
 
89
- export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening = true) {
89
+ export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening = true): void {
90
90
  let {metaKey, ctrlKey, altKey, shiftKey} = modifiers;
91
91
 
92
92
  // Firefox does not recognize keyboard events as a user action by default, and the popup blocker
@@ -146,7 +146,7 @@ function openSyntheticLink(target: Element, modifiers: Modifiers) {
146
146
  getSyntheticLink(target, link => openLink(link, modifiers));
147
147
  }
148
148
 
149
- export function useSyntheticLinkProps(props: LinkDOMProps) {
149
+ export function useSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {
150
150
  let router = useRouter();
151
151
  const href = router.useHref(props.href ?? '');
152
152
  return {
@@ -156,11 +156,11 @@ export function useSyntheticLinkProps(props: LinkDOMProps) {
156
156
  'data-download': props.download,
157
157
  'data-ping': props.ping,
158
158
  'data-referrer-policy': props.referrerPolicy
159
- };
159
+ } as DOMAttributes<HTMLElement>;
160
160
  }
161
161
 
162
162
  /** @deprecated - For backward compatibility. */
163
- export function getSyntheticLinkProps(props: LinkDOMProps) {
163
+ export function getSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {
164
164
  return {
165
165
  'data-href': props.href,
166
166
  'data-target': props.target,
@@ -168,10 +168,10 @@ export function getSyntheticLinkProps(props: LinkDOMProps) {
168
168
  'data-download': props.download,
169
169
  'data-ping': props.ping,
170
170
  'data-referrer-policy': props.referrerPolicy
171
- };
171
+ } as DOMAttributes<HTMLElement>;
172
172
  }
173
173
 
174
- export function useLinkProps(props?: LinkDOMProps) {
174
+ export function useLinkProps(props?: LinkDOMProps): LinkDOMProps {
175
175
  let router = useRouter();
176
176
  const href = router.useHref(props?.href ?? '');
177
177
  return {
@@ -91,7 +91,7 @@ if (typeof document !== 'undefined') {
91
91
  }
92
92
  }
93
93
 
94
- export function runAfterTransition(fn: () => void) {
94
+ export function runAfterTransition(fn: () => void): void {
95
95
  // Wait one frame to see if an animation starts, e.g. a transition on mount.
96
96
  requestAnimationFrame(() => {
97
97
  // If no transitions are running, call the function immediately.
@@ -22,7 +22,7 @@ interface ScrollIntoViewportOpts {
22
22
  * Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge),
23
23
  * but doesn't affect parents above `scrollView`.
24
24
  */
25
- export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement) {
25
+ export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement): void {
26
26
  let offsetX = relativeOffset(scrollView, element, 'left');
27
27
  let offsetY = relativeOffset(scrollView, element, 'top');
28
28
  let width = element.offsetWidth;
@@ -97,7 +97,7 @@ function relativeOffset(ancestor: HTMLElement, child: HTMLElement, axis: 'left'|
97
97
  * that will be centered in the viewport prior to scrolling the targetElement into view. If scrolling is prevented on
98
98
  * the body (e.g. targetElement is in a popover), this will only scroll the scroll parents of the targetElement up to but not including the body itself.
99
99
  */
100
- export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts) {
100
+ export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts): void {
101
101
  if (targetElement && document.contains(targetElement)) {
102
102
  let root = document.scrollingElement || document.documentElement;
103
103
  let isScrollPrevented = window.getComputedStyle(root).overflow === 'hidden';
@@ -43,7 +43,7 @@ export function nodeContains(
43
43
  /**
44
44
  * ShadowDOM safe version of document.activeElement.
45
45
  */
46
- export const getActiveElement = (doc: Document = document) => {
46
+ export const getActiveElement = (doc: Document = document): Element | null => {
47
47
  if (!shadowDOM()) {
48
48
  return doc.activeElement;
49
49
  }
@@ -60,11 +60,11 @@ export const getActiveElement = (doc: Document = document) => {
60
60
  /**
61
61
  * ShadowDOM safe version of event.target.
62
62
  */
63
- export function getEventTarget(event): Element {
64
- if (shadowDOM() && event.target.shadowRoot) {
63
+ export function getEventTarget<T extends Event>(event: T): Element {
64
+ if (shadowDOM() && (event.target as HTMLElement).shadowRoot) {
65
65
  if (event.composedPath) {
66
- return event.composedPath()[0];
66
+ return event.composedPath()[0] as Element;
67
67
  }
68
68
  }
69
- return event.target;
69
+ return event.target as Element;
70
70
  }
@@ -311,7 +311,7 @@ export function createShadowTreeWalker(
311
311
  root: Node,
312
312
  whatToShow?: number,
313
313
  filter?: NodeFilter | null
314
- ) {
314
+ ): TreeWalker {
315
315
  if (shadowDOM()) {
316
316
  return new ShadowTreeWalker(doc, root, whatToShow, filter);
317
317
  }
package/src/useEvent.ts CHANGED
@@ -19,7 +19,7 @@ export function useEvent<K extends keyof GlobalEventHandlersEventMap>(
19
19
  event: K | (string & {}),
20
20
  handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,
21
21
  options?: boolean | AddEventListenerOptions
22
- ) {
22
+ ): void {
23
23
  let handleEvent = useEffectEvent(handler);
24
24
  let isDisabled = handler == null;
25
25
 
@@ -18,7 +18,7 @@ export function useFormReset<T>(
18
18
  ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined,
19
19
  initialValue: T,
20
20
  onReset: (value: T) => void
21
- ) {
21
+ ): void {
22
22
  let resetValue = useRef(initialValue);
23
23
  let handleReset = useEffectEvent(() => {
24
24
  if (onReset) {
package/src/useId.ts CHANGED
@@ -26,9 +26,12 @@ export let idsUpdaterMap: Map<string, { current: string | null }[]> = new Map();
26
26
  // This allows us to clean up the idsUpdaterMap when the id is no longer used.
27
27
  // Map is a strong reference, so unused ids wouldn't be cleaned up otherwise.
28
28
  // This can happen in suspended components where mount/unmount is not called.
29
- let registry = new FinalizationRegistry<string>((heldValue) => {
30
- idsUpdaterMap.delete(heldValue);
31
- });
29
+ let registry;
30
+ if (typeof FinalizationRegistry !== 'undefined') {
31
+ registry = new FinalizationRegistry<string>((heldValue) => {
32
+ idsUpdaterMap.delete(heldValue);
33
+ });
34
+ }
32
35
 
33
36
  /**
34
37
  * If a default is not provided, generate an id.
@@ -41,7 +44,9 @@ export function useId(defaultId?: string): string {
41
44
  let res = useSSRSafeId(value);
42
45
  let cleanupRef = useRef(null);
43
46
 
44
- registry.register(cleanupRef, res);
47
+ if (registry) {
48
+ registry.register(cleanupRef, res);
49
+ }
45
50
 
46
51
  if (canUseDOM) {
47
52
  const cacheIdRef = idsUpdaterMap.get(res);
@@ -57,7 +62,9 @@ export function useId(defaultId?: string): string {
57
62
  return () => {
58
63
  // In Suspense, the cleanup function may be not called
59
64
  // when it is though, also remove it from the finalization registry.
60
- registry.unregister(cleanupRef);
65
+ if (registry) {
66
+ registry.unregister(cleanupRef);
67
+ }
61
68
  idsUpdaterMap.delete(r);
62
69
  };
63
70
  }, [res]);
@@ -12,7 +12,7 @@
12
12
 
13
13
  import {RefObject, useCallback, useRef} from 'react';
14
14
  import {useEvent} from './useEvent';
15
-
15
+
16
16
  import {useLayoutEffect} from './useLayoutEffect';
17
17
 
18
18
  export interface LoadMoreProps {
@@ -32,7 +32,7 @@ export interface LoadMoreProps {
32
32
  items?: any
33
33
  }
34
34
 
35
- export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>) {
35
+ export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>): void {
36
36
  let {isLoading, onLoadMore, scrollOffset = 1, items} = props;
37
37
 
38
38
  // Handle scrolling, and call onLoadMore when nearing the bottom.
@@ -12,7 +12,7 @@ type useResizeObserverOptionsType<T> = {
12
12
  onResize: () => void
13
13
  }
14
14
 
15
- export function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>) {
15
+ export function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void {
16
16
  const {ref, box, onResize} = options;
17
17
 
18
18
  useEffect(() => {
package/src/useSyncRef.ts CHANGED
@@ -19,7 +19,7 @@ interface ContextValue<T> {
19
19
  }
20
20
 
21
21
  // Syncs ref from context with ref passed to hook
22
- export function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>) {
22
+ export function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>): void {
23
23
  useLayoutEffect(() => {
24
24
  if (context && context.ref && ref) {
25
25
  context.ref.current = ref.current;
@@ -14,7 +14,7 @@ import {EffectCallback, useRef} from 'react';
14
14
  import {useLayoutEffect} from './useLayoutEffect';
15
15
 
16
16
  // Like useLayoutEffect, but only called for updates after the initial render.
17
- export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]) {
17
+ export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void {
18
18
  const isInitialMount = useRef(true);
19
19
  const lastDeps = useRef<any[] | null>(null);
20
20