@react-aria/utils 3.24.0 → 3.25.0
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.
- package/dist/chain.main.js +1 -1
- package/dist/chain.mjs +2 -2
- package/dist/chain.module.js +1 -1
- package/dist/domHelpers.main.js +1 -1
- package/dist/domHelpers.mjs +2 -2
- package/dist/domHelpers.module.js +1 -1
- package/dist/filterDOMProps.main.js +12 -12
- package/dist/filterDOMProps.mjs +13 -13
- package/dist/filterDOMProps.module.js +12 -12
- package/dist/focusWithoutScrolling.main.js +1 -1
- package/dist/focusWithoutScrolling.mjs +2 -2
- package/dist/focusWithoutScrolling.module.js +1 -1
- package/dist/getOffset.main.js +3 -3
- package/dist/getOffset.mjs +4 -4
- package/dist/getOffset.module.js +3 -3
- package/dist/getScrollParent.mjs +1 -1
- package/dist/getScrollParents.mjs +1 -1
- package/dist/import.mjs +4 -2
- package/dist/isScrollable.mjs +1 -1
- package/dist/isVirtualEvent.main.js +2 -2
- package/dist/isVirtualEvent.mjs +3 -3
- package/dist/isVirtualEvent.module.js +2 -2
- package/dist/main.js +4 -1
- package/dist/main.js.map +1 -1
- package/dist/mergeProps.main.js +4 -4
- package/dist/mergeProps.mjs +5 -5
- package/dist/mergeProps.module.js +4 -4
- package/dist/mergeRefs.main.js +2 -2
- package/dist/mergeRefs.main.js.map +1 -1
- package/dist/mergeRefs.mjs +3 -3
- package/dist/mergeRefs.module.js +2 -2
- package/dist/mergeRefs.module.js.map +1 -1
- package/dist/module.js +4 -2
- package/dist/module.js.map +1 -1
- package/dist/openLink.main.js +23 -22
- package/dist/openLink.main.js.map +1 -1
- package/dist/openLink.mjs +24 -23
- package/dist/openLink.module.js +23 -22
- package/dist/openLink.module.js.map +1 -1
- package/dist/platform.main.js +28 -21
- package/dist/platform.main.js.map +1 -1
- package/dist/platform.mjs +29 -22
- package/dist/platform.module.js +28 -21
- package/dist/platform.module.js.map +1 -1
- package/dist/runAfterTransition.main.js +9 -9
- package/dist/runAfterTransition.mjs +10 -10
- package/dist/runAfterTransition.module.js +9 -9
- package/dist/scrollIntoView.main.js +8 -8
- package/dist/scrollIntoView.mjs +9 -9
- package/dist/scrollIntoView.module.js +8 -8
- package/dist/types.d.ts +35 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/useDeepMemo.mjs +1 -1
- package/dist/useDescription.main.js +3 -3
- package/dist/useDescription.mjs +4 -4
- package/dist/useDescription.module.js +3 -3
- package/dist/useDrag1D.main.js +21 -21
- package/dist/useDrag1D.mjs +22 -22
- package/dist/useDrag1D.module.js +21 -21
- package/dist/useEffectEvent.mjs +1 -1
- package/dist/useEvent.main.js.map +1 -1
- package/dist/useEvent.mjs +1 -1
- package/dist/useEvent.module.js.map +1 -1
- package/dist/useFormReset.main.js +2 -2
- package/dist/useFormReset.main.js.map +1 -1
- package/dist/useFormReset.mjs +3 -3
- package/dist/useFormReset.module.js +2 -2
- package/dist/useFormReset.module.js.map +1 -1
- package/dist/useGlobalListeners.mjs +1 -1
- package/dist/useId.main.js +1 -1
- package/dist/useId.mjs +2 -2
- package/dist/useId.module.js +1 -1
- package/dist/useLabels.main.js +5 -5
- package/dist/useLabels.mjs +6 -6
- package/dist/useLabels.module.js +5 -5
- package/dist/useLayoutEffect.main.js +1 -1
- package/dist/useLayoutEffect.mjs +2 -2
- package/dist/useLayoutEffect.module.js +1 -1
- package/dist/useLoadMore.main.js +72 -0
- package/dist/useLoadMore.main.js.map +1 -0
- package/dist/useLoadMore.mjs +67 -0
- package/dist/useLoadMore.module.js +67 -0
- package/dist/useLoadMore.module.js.map +1 -0
- package/dist/useObjectRef.main.js +1 -1
- package/dist/useObjectRef.mjs +2 -2
- package/dist/useObjectRef.module.js +1 -1
- package/dist/useResizeObserver.main.js +9 -6
- package/dist/useResizeObserver.main.js.map +1 -1
- package/dist/useResizeObserver.mjs +10 -7
- package/dist/useResizeObserver.module.js +9 -6
- package/dist/useResizeObserver.module.js.map +1 -1
- package/dist/useSyncRef.main.js.map +1 -1
- package/dist/useSyncRef.mjs +1 -1
- package/dist/useSyncRef.module.js.map +1 -1
- package/dist/useUpdateEffect.mjs +1 -1
- package/dist/useValueEffect.mjs +1 -1
- package/dist/useViewportSize.main.js +5 -5
- package/dist/useViewportSize.mjs +6 -6
- package/dist/useViewportSize.module.js +5 -5
- package/package.json +6 -6
- package/src/index.ts +2 -1
- package/src/mergeRefs.ts +2 -2
- package/src/openLink.tsx +3 -2
- package/src/platform.ts +32 -18
- package/src/useEvent.ts +4 -3
- package/src/useFormReset.ts +4 -2
- package/src/useLoadMore.ts +82 -0
- package/src/useResizeObserver.ts +8 -5
- package/src/useSyncRef.ts +3 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var $2a8c0bb1629926c8$exports = require("./useEvent.main.js");
|
|
2
|
+
var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
|
|
3
|
+
var $4Zukt$react = require("react");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "useLoadMore", () => $faa6ccd6fb62f877$export$7717c92ee915373e);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function $faa6ccd6fb62f877$export$7717c92ee915373e(props, ref) {
|
|
25
|
+
let { isLoading: isLoading, onLoadMore: onLoadMore, scrollOffset: scrollOffset = 1, items: items } = props;
|
|
26
|
+
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
27
|
+
let isLoadingRef = (0, $4Zukt$react.useRef)(isLoading);
|
|
28
|
+
let prevProps = (0, $4Zukt$react.useRef)(props);
|
|
29
|
+
let onScroll = (0, $4Zukt$react.useCallback)(()=>{
|
|
30
|
+
if (ref.current && !isLoadingRef.current && onLoadMore) {
|
|
31
|
+
let shouldLoadMore = ref.current.scrollHeight - ref.current.scrollTop - ref.current.clientHeight < ref.current.clientHeight * scrollOffset;
|
|
32
|
+
if (shouldLoadMore) {
|
|
33
|
+
isLoadingRef.current = true;
|
|
34
|
+
onLoadMore();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, [
|
|
38
|
+
onLoadMore,
|
|
39
|
+
ref,
|
|
40
|
+
scrollOffset
|
|
41
|
+
]);
|
|
42
|
+
let lastItems = (0, $4Zukt$react.useRef)(items);
|
|
43
|
+
(0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
|
|
44
|
+
// Only update isLoadingRef if props object actually changed,
|
|
45
|
+
// not if a local state change occurred.
|
|
46
|
+
if (props !== prevProps.current) {
|
|
47
|
+
isLoadingRef.current = isLoading;
|
|
48
|
+
prevProps.current = props;
|
|
49
|
+
}
|
|
50
|
+
// TODO: Eventually this hook will move back into RAC during which we will accept the collection as a option to this hook.
|
|
51
|
+
// We will only load more if the collection has changed after the last load to prevent multiple onLoadMore from being called
|
|
52
|
+
// while the data from the last onLoadMore is being processed by RAC collection.
|
|
53
|
+
let shouldLoadMore = (ref === null || ref === void 0 ? void 0 : ref.current) && !isLoadingRef.current && onLoadMore && (!items || items !== lastItems.current) && ref.current.clientHeight === ref.current.scrollHeight;
|
|
54
|
+
if (shouldLoadMore) {
|
|
55
|
+
isLoadingRef.current = true;
|
|
56
|
+
onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
|
|
57
|
+
}
|
|
58
|
+
lastItems.current = items;
|
|
59
|
+
}, [
|
|
60
|
+
isLoading,
|
|
61
|
+
onLoadMore,
|
|
62
|
+
props,
|
|
63
|
+
ref
|
|
64
|
+
]);
|
|
65
|
+
// TODO: maybe this should still just return scroll props?
|
|
66
|
+
// Test against case where the ref isn't defined when this is called
|
|
67
|
+
// Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll
|
|
68
|
+
(0, $2a8c0bb1629926c8$exports.useEvent)(ref, 'scroll', onScroll);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=useLoadMore.main.js.map
|
|
@@ -0,0 +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,mBAAK,EAAE;IAC1B,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,wBAAU,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,mBAAK,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;KAAI;IAEtC,0DAA0D;IAC1D,oEAAoE;IACpE,kHAAkH;IAClH,CAAA,GAAA,kCAAO,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// eslint-disable-next-line rulesdir/useLayoutEffectRule\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]);\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.main.js.map"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {useEvent as $e9faafb641e167db$export$90fc3a17d93f704c} from "./useEvent.mjs";
|
|
2
|
+
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
|
|
3
|
+
import {useRef as $hDRkU$useRef, useCallback as $hDRkU$useCallback} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $26f7f3da73fcd9d6$export$7717c92ee915373e(props, ref) {
|
|
19
|
+
let { isLoading: isLoading, onLoadMore: onLoadMore, scrollOffset: scrollOffset = 1, items: items } = props;
|
|
20
|
+
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
21
|
+
let isLoadingRef = (0, $hDRkU$useRef)(isLoading);
|
|
22
|
+
let prevProps = (0, $hDRkU$useRef)(props);
|
|
23
|
+
let onScroll = (0, $hDRkU$useCallback)(()=>{
|
|
24
|
+
if (ref.current && !isLoadingRef.current && onLoadMore) {
|
|
25
|
+
let shouldLoadMore = ref.current.scrollHeight - ref.current.scrollTop - ref.current.clientHeight < ref.current.clientHeight * scrollOffset;
|
|
26
|
+
if (shouldLoadMore) {
|
|
27
|
+
isLoadingRef.current = true;
|
|
28
|
+
onLoadMore();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
onLoadMore,
|
|
33
|
+
ref,
|
|
34
|
+
scrollOffset
|
|
35
|
+
]);
|
|
36
|
+
let lastItems = (0, $hDRkU$useRef)(items);
|
|
37
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
38
|
+
// Only update isLoadingRef if props object actually changed,
|
|
39
|
+
// not if a local state change occurred.
|
|
40
|
+
if (props !== prevProps.current) {
|
|
41
|
+
isLoadingRef.current = isLoading;
|
|
42
|
+
prevProps.current = props;
|
|
43
|
+
}
|
|
44
|
+
// TODO: Eventually this hook will move back into RAC during which we will accept the collection as a option to this hook.
|
|
45
|
+
// We will only load more if the collection has changed after the last load to prevent multiple onLoadMore from being called
|
|
46
|
+
// while the data from the last onLoadMore is being processed by RAC collection.
|
|
47
|
+
let shouldLoadMore = (ref === null || ref === void 0 ? void 0 : ref.current) && !isLoadingRef.current && onLoadMore && (!items || items !== lastItems.current) && ref.current.clientHeight === ref.current.scrollHeight;
|
|
48
|
+
if (shouldLoadMore) {
|
|
49
|
+
isLoadingRef.current = true;
|
|
50
|
+
onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
|
|
51
|
+
}
|
|
52
|
+
lastItems.current = items;
|
|
53
|
+
}, [
|
|
54
|
+
isLoading,
|
|
55
|
+
onLoadMore,
|
|
56
|
+
props,
|
|
57
|
+
ref
|
|
58
|
+
]);
|
|
59
|
+
// TODO: maybe this should still just return scroll props?
|
|
60
|
+
// Test against case where the ref isn't defined when this is called
|
|
61
|
+
// Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll
|
|
62
|
+
(0, $e9faafb641e167db$export$90fc3a17d93f704c)(ref, 'scroll', onScroll);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export {$26f7f3da73fcd9d6$export$7717c92ee915373e as useLoadMore};
|
|
67
|
+
//# sourceMappingURL=useLoadMore.module.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {useEvent as $e9faafb641e167db$export$90fc3a17d93f704c} from "./useEvent.module.js";
|
|
2
|
+
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
|
|
3
|
+
import {useRef as $hDRkU$useRef, useCallback as $hDRkU$useCallback} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $26f7f3da73fcd9d6$export$7717c92ee915373e(props, ref) {
|
|
19
|
+
let { isLoading: isLoading, onLoadMore: onLoadMore, scrollOffset: scrollOffset = 1, items: items } = props;
|
|
20
|
+
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
21
|
+
let isLoadingRef = (0, $hDRkU$useRef)(isLoading);
|
|
22
|
+
let prevProps = (0, $hDRkU$useRef)(props);
|
|
23
|
+
let onScroll = (0, $hDRkU$useCallback)(()=>{
|
|
24
|
+
if (ref.current && !isLoadingRef.current && onLoadMore) {
|
|
25
|
+
let shouldLoadMore = ref.current.scrollHeight - ref.current.scrollTop - ref.current.clientHeight < ref.current.clientHeight * scrollOffset;
|
|
26
|
+
if (shouldLoadMore) {
|
|
27
|
+
isLoadingRef.current = true;
|
|
28
|
+
onLoadMore();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
onLoadMore,
|
|
33
|
+
ref,
|
|
34
|
+
scrollOffset
|
|
35
|
+
]);
|
|
36
|
+
let lastItems = (0, $hDRkU$useRef)(items);
|
|
37
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
38
|
+
// Only update isLoadingRef if props object actually changed,
|
|
39
|
+
// not if a local state change occurred.
|
|
40
|
+
if (props !== prevProps.current) {
|
|
41
|
+
isLoadingRef.current = isLoading;
|
|
42
|
+
prevProps.current = props;
|
|
43
|
+
}
|
|
44
|
+
// TODO: Eventually this hook will move back into RAC during which we will accept the collection as a option to this hook.
|
|
45
|
+
// We will only load more if the collection has changed after the last load to prevent multiple onLoadMore from being called
|
|
46
|
+
// while the data from the last onLoadMore is being processed by RAC collection.
|
|
47
|
+
let shouldLoadMore = (ref === null || ref === void 0 ? void 0 : ref.current) && !isLoadingRef.current && onLoadMore && (!items || items !== lastItems.current) && ref.current.clientHeight === ref.current.scrollHeight;
|
|
48
|
+
if (shouldLoadMore) {
|
|
49
|
+
isLoadingRef.current = true;
|
|
50
|
+
onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
|
|
51
|
+
}
|
|
52
|
+
lastItems.current = items;
|
|
53
|
+
}, [
|
|
54
|
+
isLoading,
|
|
55
|
+
onLoadMore,
|
|
56
|
+
props,
|
|
57
|
+
ref
|
|
58
|
+
]);
|
|
59
|
+
// TODO: maybe this should still just return scroll props?
|
|
60
|
+
// Test against case where the ref isn't defined when this is called
|
|
61
|
+
// Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll
|
|
62
|
+
(0, $e9faafb641e167db$export$90fc3a17d93f704c)(ref, 'scroll', onScroll);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export {$26f7f3da73fcd9d6$export$7717c92ee915373e as useLoadMore};
|
|
67
|
+
//# sourceMappingURL=useLoadMore.module.js.map
|
|
@@ -0,0 +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;KAAI;IAEtC,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// eslint-disable-next-line rulesdir/useLayoutEffectRule\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]);\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"}
|
|
@@ -25,7 +25,7 @@ function $475b35fe72ba49b3$export$4338b53315abf666(forwardedRef) {
|
|
|
25
25
|
},
|
|
26
26
|
set current (value){
|
|
27
27
|
objRef.current = value;
|
|
28
|
-
if (typeof forwardedRef ===
|
|
28
|
+
if (typeof forwardedRef === 'function') forwardedRef(value);
|
|
29
29
|
else if (forwardedRef) forwardedRef.current = value;
|
|
30
30
|
}
|
|
31
31
|
}), [
|
package/dist/useObjectRef.mjs
CHANGED
|
@@ -19,7 +19,7 @@ function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
|
|
|
19
19
|
},
|
|
20
20
|
set current (value){
|
|
21
21
|
objRef.current = value;
|
|
22
|
-
if (typeof forwardedRef ===
|
|
22
|
+
if (typeof forwardedRef === 'function') forwardedRef(value);
|
|
23
23
|
else if (forwardedRef) forwardedRef.current = value;
|
|
24
24
|
}
|
|
25
25
|
}), [
|
|
@@ -29,4 +29,4 @@ function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
export {$df56164dff5785e2$export$4338b53315abf666 as useObjectRef};
|
|
32
|
-
//# sourceMappingURL=useObjectRef.
|
|
32
|
+
//# sourceMappingURL=useObjectRef.module.js.map
|
|
@@ -19,7 +19,7 @@ function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
|
|
|
19
19
|
},
|
|
20
20
|
set current (value){
|
|
21
21
|
objRef.current = value;
|
|
22
|
-
if (typeof forwardedRef ===
|
|
22
|
+
if (typeof forwardedRef === 'function') forwardedRef(value);
|
|
23
23
|
else if (forwardedRef) forwardedRef.current = value;
|
|
24
24
|
}
|
|
25
25
|
}), [
|
|
@@ -8,31 +8,34 @@ function $parcel$export(e, n, v, s) {
|
|
|
8
8
|
$parcel$export(module.exports, "useResizeObserver", () => $37733e1652f47193$export$683480f191c0e3ea);
|
|
9
9
|
|
|
10
10
|
function $37733e1652f47193$var$hasResizeObserver() {
|
|
11
|
-
return typeof window.ResizeObserver !==
|
|
11
|
+
return typeof window.ResizeObserver !== 'undefined';
|
|
12
12
|
}
|
|
13
13
|
function $37733e1652f47193$export$683480f191c0e3ea(options) {
|
|
14
|
-
const { ref: ref, onResize: onResize } = options;
|
|
14
|
+
const { ref: ref, box: box, onResize: onResize } = options;
|
|
15
15
|
(0, $aM4zL$react.useEffect)(()=>{
|
|
16
16
|
let element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
17
17
|
if (!element) return;
|
|
18
18
|
if (!$37733e1652f47193$var$hasResizeObserver()) {
|
|
19
|
-
window.addEventListener(
|
|
19
|
+
window.addEventListener('resize', onResize, false);
|
|
20
20
|
return ()=>{
|
|
21
|
-
window.removeEventListener(
|
|
21
|
+
window.removeEventListener('resize', onResize, false);
|
|
22
22
|
};
|
|
23
23
|
} else {
|
|
24
24
|
const resizeObserverInstance = new window.ResizeObserver((entries)=>{
|
|
25
25
|
if (!entries.length) return;
|
|
26
26
|
onResize();
|
|
27
27
|
});
|
|
28
|
-
resizeObserverInstance.observe(element
|
|
28
|
+
resizeObserverInstance.observe(element, {
|
|
29
|
+
box: box
|
|
30
|
+
});
|
|
29
31
|
return ()=>{
|
|
30
32
|
if (element) resizeObserverInstance.unobserve(element);
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
}, [
|
|
34
36
|
onResize,
|
|
35
|
-
ref
|
|
37
|
+
ref,
|
|
38
|
+
box
|
|
36
39
|
]);
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;
|
|
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"}
|
|
@@ -2,34 +2,37 @@ import {useEffect as $Vsl8o$useEffect} from "react";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function $9daab02d461809db$var$hasResizeObserver() {
|
|
5
|
-
return typeof window.ResizeObserver !==
|
|
5
|
+
return typeof window.ResizeObserver !== 'undefined';
|
|
6
6
|
}
|
|
7
7
|
function $9daab02d461809db$export$683480f191c0e3ea(options) {
|
|
8
|
-
const { ref: ref, onResize: onResize } = options;
|
|
8
|
+
const { ref: ref, box: box, onResize: onResize } = options;
|
|
9
9
|
(0, $Vsl8o$useEffect)(()=>{
|
|
10
10
|
let element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
11
11
|
if (!element) return;
|
|
12
12
|
if (!$9daab02d461809db$var$hasResizeObserver()) {
|
|
13
|
-
window.addEventListener(
|
|
13
|
+
window.addEventListener('resize', onResize, false);
|
|
14
14
|
return ()=>{
|
|
15
|
-
window.removeEventListener(
|
|
15
|
+
window.removeEventListener('resize', onResize, false);
|
|
16
16
|
};
|
|
17
17
|
} else {
|
|
18
18
|
const resizeObserverInstance = new window.ResizeObserver((entries)=>{
|
|
19
19
|
if (!entries.length) return;
|
|
20
20
|
onResize();
|
|
21
21
|
});
|
|
22
|
-
resizeObserverInstance.observe(element
|
|
22
|
+
resizeObserverInstance.observe(element, {
|
|
23
|
+
box: box
|
|
24
|
+
});
|
|
23
25
|
return ()=>{
|
|
24
26
|
if (element) resizeObserverInstance.unobserve(element);
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
}, [
|
|
28
30
|
onResize,
|
|
29
|
-
ref
|
|
31
|
+
ref,
|
|
32
|
+
box
|
|
30
33
|
]);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
export {$9daab02d461809db$export$683480f191c0e3ea as useResizeObserver};
|
|
35
|
-
//# sourceMappingURL=useResizeObserver.
|
|
38
|
+
//# sourceMappingURL=useResizeObserver.module.js.map
|
|
@@ -2,31 +2,34 @@ import {useEffect as $Vsl8o$useEffect} from "react";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function $9daab02d461809db$var$hasResizeObserver() {
|
|
5
|
-
return typeof window.ResizeObserver !==
|
|
5
|
+
return typeof window.ResizeObserver !== 'undefined';
|
|
6
6
|
}
|
|
7
7
|
function $9daab02d461809db$export$683480f191c0e3ea(options) {
|
|
8
|
-
const { ref: ref, onResize: onResize } = options;
|
|
8
|
+
const { ref: ref, box: box, onResize: onResize } = options;
|
|
9
9
|
(0, $Vsl8o$useEffect)(()=>{
|
|
10
10
|
let element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
11
11
|
if (!element) return;
|
|
12
12
|
if (!$9daab02d461809db$var$hasResizeObserver()) {
|
|
13
|
-
window.addEventListener(
|
|
13
|
+
window.addEventListener('resize', onResize, false);
|
|
14
14
|
return ()=>{
|
|
15
|
-
window.removeEventListener(
|
|
15
|
+
window.removeEventListener('resize', onResize, false);
|
|
16
16
|
};
|
|
17
17
|
} else {
|
|
18
18
|
const resizeObserverInstance = new window.ResizeObserver((entries)=>{
|
|
19
19
|
if (!entries.length) return;
|
|
20
20
|
onResize();
|
|
21
21
|
});
|
|
22
|
-
resizeObserverInstance.observe(element
|
|
22
|
+
resizeObserverInstance.observe(element, {
|
|
23
|
+
box: box
|
|
24
|
+
});
|
|
23
25
|
return ()=>{
|
|
24
26
|
if (element) resizeObserverInstance.unobserve(element);
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
}, [
|
|
28
30
|
onResize,
|
|
29
|
-
ref
|
|
31
|
+
ref,
|
|
32
|
+
box
|
|
30
33
|
]);
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;
|
|
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 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;
|
|
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"}
|
package/dist/useSyncRef.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;
|
|
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"}
|
package/dist/useUpdateEffect.mjs
CHANGED
package/dist/useValueEffect.mjs
CHANGED
|
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "useViewportSize", () => $8b24bab62f5c65ad$export
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
// @ts-ignore
|
|
23
|
-
let $8b24bab62f5c65ad$var$visualViewport = typeof document !==
|
|
23
|
+
let $8b24bab62f5c65ad$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
24
24
|
function $8b24bab62f5c65ad$export$d699905dd57c73ca() {
|
|
25
25
|
let isSSR = (0, $4gIVO$reactariassr.useIsSSR)();
|
|
26
26
|
let [size, setSize] = (0, $4gIVO$react.useState)(()=>isSSR ? {
|
|
@@ -36,11 +36,11 @@ function $8b24bab62f5c65ad$export$d699905dd57c73ca() {
|
|
|
36
36
|
return newSize;
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
if (!$8b24bab62f5c65ad$var$visualViewport) window.addEventListener(
|
|
40
|
-
else $8b24bab62f5c65ad$var$visualViewport.addEventListener(
|
|
39
|
+
if (!$8b24bab62f5c65ad$var$visualViewport) window.addEventListener('resize', onResize);
|
|
40
|
+
else $8b24bab62f5c65ad$var$visualViewport.addEventListener('resize', onResize);
|
|
41
41
|
return ()=>{
|
|
42
|
-
if (!$8b24bab62f5c65ad$var$visualViewport) window.removeEventListener(
|
|
43
|
-
else $8b24bab62f5c65ad$var$visualViewport.removeEventListener(
|
|
42
|
+
if (!$8b24bab62f5c65ad$var$visualViewport) window.removeEventListener('resize', onResize);
|
|
43
|
+
else $8b24bab62f5c65ad$var$visualViewport.removeEventListener('resize', onResize);
|
|
44
44
|
};
|
|
45
45
|
}, []);
|
|
46
46
|
return size;
|
package/dist/useViewportSize.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import {useIsSSR as $fuDHA$useIsSSR} from "@react-aria/ssr";
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
let $5df64b3807dc15ee$var$visualViewport = typeof document !==
|
|
17
|
+
let $5df64b3807dc15ee$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
18
18
|
function $5df64b3807dc15ee$export$d699905dd57c73ca() {
|
|
19
19
|
let isSSR = (0, $fuDHA$useIsSSR)();
|
|
20
20
|
let [size, setSize] = (0, $fuDHA$useState)(()=>isSSR ? {
|
|
@@ -30,11 +30,11 @@ function $5df64b3807dc15ee$export$d699905dd57c73ca() {
|
|
|
30
30
|
return newSize;
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener(
|
|
34
|
-
else $5df64b3807dc15ee$var$visualViewport.addEventListener(
|
|
33
|
+
if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener('resize', onResize);
|
|
34
|
+
else $5df64b3807dc15ee$var$visualViewport.addEventListener('resize', onResize);
|
|
35
35
|
return ()=>{
|
|
36
|
-
if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener(
|
|
37
|
-
else $5df64b3807dc15ee$var$visualViewport.removeEventListener(
|
|
36
|
+
if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener('resize', onResize);
|
|
37
|
+
else $5df64b3807dc15ee$var$visualViewport.removeEventListener('resize', onResize);
|
|
38
38
|
};
|
|
39
39
|
}, []);
|
|
40
40
|
return size;
|
|
@@ -48,4 +48,4 @@ function $5df64b3807dc15ee$var$getViewportSize() {
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
export {$5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize};
|
|
51
|
-
//# sourceMappingURL=useViewportSize.
|
|
51
|
+
//# sourceMappingURL=useViewportSize.module.js.map
|
|
@@ -14,7 +14,7 @@ import {useIsSSR as $fuDHA$useIsSSR} from "@react-aria/ssr";
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
let $5df64b3807dc15ee$var$visualViewport = typeof document !==
|
|
17
|
+
let $5df64b3807dc15ee$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
18
18
|
function $5df64b3807dc15ee$export$d699905dd57c73ca() {
|
|
19
19
|
let isSSR = (0, $fuDHA$useIsSSR)();
|
|
20
20
|
let [size, setSize] = (0, $fuDHA$useState)(()=>isSSR ? {
|
|
@@ -30,11 +30,11 @@ function $5df64b3807dc15ee$export$d699905dd57c73ca() {
|
|
|
30
30
|
return newSize;
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener(
|
|
34
|
-
else $5df64b3807dc15ee$var$visualViewport.addEventListener(
|
|
33
|
+
if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener('resize', onResize);
|
|
34
|
+
else $5df64b3807dc15ee$var$visualViewport.addEventListener('resize', onResize);
|
|
35
35
|
return ()=>{
|
|
36
|
-
if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener(
|
|
37
|
-
else $5df64b3807dc15ee$var$visualViewport.removeEventListener(
|
|
36
|
+
if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener('resize', onResize);
|
|
37
|
+
else $5df64b3807dc15ee$var$visualViewport.removeEventListener('resize', onResize);
|
|
38
38
|
};
|
|
39
39
|
}, []);
|
|
40
40
|
return size;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.25.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/ssr": "^3.9.
|
|
26
|
-
"@react-stately/utils": "^3.10.
|
|
27
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/ssr": "^3.9.5",
|
|
26
|
+
"@react-stately/utils": "^3.10.2",
|
|
27
|
+
"@react-types/shared": "^3.24.0",
|
|
28
28
|
"@swc/helpers": "^0.5.0",
|
|
29
29
|
"clsx": "^2.0.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "86d80e3216bc32e75108831cf3a5a720bc849206"
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export {mergeRefs} from './mergeRefs';
|
|
|
17
17
|
export {filterDOMProps} from './filterDOMProps';
|
|
18
18
|
export {focusWithoutScrolling} from './focusWithoutScrolling';
|
|
19
19
|
export {getOffset} from './getOffset';
|
|
20
|
-
export {openLink,
|
|
20
|
+
export {openLink, useSyntheticLinkProps, RouterProvider, shouldClientNavigate, useRouter, useLinkProps} from './openLink';
|
|
21
21
|
export {runAfterTransition} from './runAfterTransition';
|
|
22
22
|
export {useDrag1D} from './useDrag1D';
|
|
23
23
|
export {useGlobalListeners} from './useGlobalListeners';
|
|
@@ -41,3 +41,4 @@ export {isVirtualClick, isVirtualPointerEvent} from './isVirtualEvent';
|
|
|
41
41
|
export {useEffectEvent} from './useEffectEvent';
|
|
42
42
|
export {useDeepMemo} from './useDeepMemo';
|
|
43
43
|
export {useFormReset} from './useFormReset';
|
|
44
|
+
export {useLoadMore} from './useLoadMore';
|
package/src/mergeRefs.ts
CHANGED
|
@@ -15,8 +15,8 @@ import {ForwardedRef, MutableRefObject} from 'react';
|
|
|
15
15
|
/**
|
|
16
16
|
* Merges multiple refs into one. Works with either callback or object refs.
|
|
17
17
|
*/
|
|
18
|
-
export function mergeRefs<T>(...refs: Array<ForwardedRef<T> | MutableRefObject<T
|
|
19
|
-
if (refs.length === 1) {
|
|
18
|
+
export function mergeRefs<T>(...refs: Array<ForwardedRef<T> | MutableRefObject<T> | null | undefined>): ForwardedRef<T> {
|
|
19
|
+
if (refs.length === 1 && refs[0]) {
|
|
20
20
|
return refs[0];
|
|
21
21
|
}
|
|
22
22
|
|
package/src/openLink.tsx
CHANGED
|
@@ -146,9 +146,10 @@ function openSyntheticLink(target: Element, modifiers: Modifiers) {
|
|
|
146
146
|
getSyntheticLink(target, link => openLink(link, modifiers));
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
export function
|
|
149
|
+
export function useSyntheticLinkProps(props: LinkDOMProps) {
|
|
150
|
+
let router = useRouter();
|
|
150
151
|
return {
|
|
151
|
-
'data-href': props.href,
|
|
152
|
+
'data-href': props.href ? router.useHref(props.href) : undefined,
|
|
152
153
|
'data-target': props.target,
|
|
153
154
|
'data-rel': props.rel,
|
|
154
155
|
'data-download': props.download,
|