@react-aria/utils 3.33.0 → 3.34.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/import.mjs +47 -43
- package/dist/main.js +120 -114
- package/dist/main.js.map +1 -1
- package/dist/module.js +47 -43
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +45 -0
- package/package.json +15 -15
- package/src/index.ts +45 -43
- package/dist/DOMFunctions.main.js +0 -44
- package/dist/DOMFunctions.main.js.map +0 -1
- package/dist/DOMFunctions.mjs +0 -37
- package/dist/DOMFunctions.module.js +0 -37
- package/dist/DOMFunctions.module.js.map +0 -1
- package/dist/ShadowTreeWalker.main.js +0 -200
- package/dist/ShadowTreeWalker.main.js.map +0 -1
- package/dist/ShadowTreeWalker.mjs +0 -194
- package/dist/ShadowTreeWalker.module.js +0 -194
- package/dist/ShadowTreeWalker.module.js.map +0 -1
- package/dist/animation.main.js +0 -97
- package/dist/animation.main.js.map +0 -1
- package/dist/animation.mjs +0 -91
- package/dist/animation.module.js +0 -91
- package/dist/animation.module.js.map +0 -1
- package/dist/chain.main.js +0 -26
- package/dist/chain.main.js.map +0 -1
- package/dist/chain.mjs +0 -21
- package/dist/chain.module.js +0 -21
- package/dist/chain.module.js.map +0 -1
- package/dist/constants.main.js +0 -23
- package/dist/constants.main.js.map +0 -1
- package/dist/constants.mjs +0 -17
- package/dist/constants.module.js +0 -17
- package/dist/constants.module.js.map +0 -1
- package/dist/domHelpers.main.js +0 -28
- package/dist/domHelpers.main.js.map +0 -1
- package/dist/domHelpers.mjs +0 -21
- package/dist/domHelpers.module.js +0 -21
- package/dist/domHelpers.module.js.map +0 -1
- package/dist/filterDOMProps.main.js +0 -88
- package/dist/filterDOMProps.main.js.map +0 -1
- package/dist/filterDOMProps.mjs +0 -83
- package/dist/filterDOMProps.module.js +0 -83
- package/dist/filterDOMProps.module.js.map +0 -1
- package/dist/focusWithoutScrolling.main.js +0 -72
- package/dist/focusWithoutScrolling.main.js.map +0 -1
- package/dist/focusWithoutScrolling.mjs +0 -67
- package/dist/focusWithoutScrolling.module.js +0 -67
- package/dist/focusWithoutScrolling.module.js.map +0 -1
- package/dist/getOffset.main.js +0 -24
- package/dist/getOffset.main.js.map +0 -1
- package/dist/getOffset.mjs +0 -19
- package/dist/getOffset.module.js +0 -19
- package/dist/getOffset.module.js.map +0 -1
- package/dist/getScrollParent.main.js +0 -28
- package/dist/getScrollParent.main.js.map +0 -1
- package/dist/getScrollParent.mjs +0 -23
- package/dist/getScrollParent.module.js +0 -23
- package/dist/getScrollParent.module.js.map +0 -1
- package/dist/getScrollParents.main.js +0 -30
- package/dist/getScrollParents.main.js.map +0 -1
- package/dist/getScrollParents.mjs +0 -25
- package/dist/getScrollParents.module.js +0 -25
- package/dist/getScrollParents.module.js.map +0 -1
- package/dist/inertValue.main.js +0 -19
- package/dist/inertValue.main.js.map +0 -1
- package/dist/inertValue.mjs +0 -14
- package/dist/inertValue.module.js +0 -14
- package/dist/inertValue.module.js.map +0 -1
- package/dist/isElementVisible.main.js +0 -45
- package/dist/isElementVisible.main.js.map +0 -1
- package/dist/isElementVisible.mjs +0 -40
- package/dist/isElementVisible.module.js +0 -40
- package/dist/isElementVisible.module.js.map +0 -1
- package/dist/isFocusable.main.js +0 -56
- package/dist/isFocusable.main.js.map +0 -1
- package/dist/isFocusable.mjs +0 -50
- package/dist/isFocusable.module.js +0 -50
- package/dist/isFocusable.module.js.map +0 -1
- package/dist/isScrollable.main.js +0 -26
- package/dist/isScrollable.main.js.map +0 -1
- package/dist/isScrollable.mjs +0 -21
- package/dist/isScrollable.module.js +0 -21
- package/dist/isScrollable.module.js.map +0 -1
- package/dist/isVirtualEvent.main.js +0 -41
- package/dist/isVirtualEvent.main.js.map +0 -1
- package/dist/isVirtualEvent.mjs +0 -35
- package/dist/isVirtualEvent.module.js +0 -35
- package/dist/isVirtualEvent.module.js.map +0 -1
- package/dist/keyboard.main.js +0 -42
- package/dist/keyboard.main.js.map +0 -1
- package/dist/keyboard.mjs +0 -36
- package/dist/keyboard.module.js +0 -36
- package/dist/keyboard.module.js.map +0 -1
- package/dist/mergeProps.main.js +0 -54
- package/dist/mergeProps.main.js.map +0 -1
- package/dist/mergeProps.mjs +0 -45
- package/dist/mergeProps.module.js +0 -45
- package/dist/mergeProps.module.js.map +0 -1
- package/dist/mergeRefs.main.js +0 -40
- package/dist/mergeRefs.main.js.map +0 -1
- package/dist/mergeRefs.mjs +0 -35
- package/dist/mergeRefs.module.js +0 -35
- package/dist/mergeRefs.module.js.map +0 -1
- package/dist/openLink.main.js +0 -169
- package/dist/openLink.main.js.map +0 -1
- package/dist/openLink.mjs +0 -153
- package/dist/openLink.module.js +0 -153
- package/dist/openLink.module.js.map +0 -1
- package/dist/platform.main.js +0 -73
- package/dist/platform.main.js.map +0 -1
- package/dist/platform.mjs +0 -60
- package/dist/platform.module.js +0 -60
- package/dist/platform.module.js.map +0 -1
- package/dist/runAfterTransition.main.js +0 -92
- package/dist/runAfterTransition.main.js.map +0 -1
- package/dist/runAfterTransition.mjs +0 -87
- package/dist/runAfterTransition.module.js +0 -87
- package/dist/runAfterTransition.module.js.map +0 -1
- package/dist/scrollIntoView.main.js +0 -105
- package/dist/scrollIntoView.main.js.map +0 -1
- package/dist/scrollIntoView.mjs +0 -99
- package/dist/scrollIntoView.module.js +0 -99
- package/dist/scrollIntoView.module.js.map +0 -1
- package/dist/types.d.ts +0 -286
- package/dist/types.d.ts.map +0 -1
- package/dist/useDeepMemo.main.js +0 -30
- package/dist/useDeepMemo.main.js.map +0 -1
- package/dist/useDeepMemo.mjs +0 -25
- package/dist/useDeepMemo.module.js +0 -25
- package/dist/useDeepMemo.module.js.map +0 -1
- package/dist/useDescription.main.js +0 -59
- package/dist/useDescription.main.js.map +0 -1
- package/dist/useDescription.mjs +0 -54
- package/dist/useDescription.module.js +0 -54
- package/dist/useDescription.module.js.map +0 -1
- package/dist/useDrag1D.main.js +0 -141
- package/dist/useDrag1D.main.js.map +0 -1
- package/dist/useDrag1D.mjs +0 -136
- package/dist/useDrag1D.module.js +0 -136
- package/dist/useDrag1D.module.js.map +0 -1
- package/dist/useEffectEvent.main.js +0 -45
- package/dist/useEffectEvent.main.js.map +0 -1
- package/dist/useEffectEvent.mjs +0 -36
- package/dist/useEffectEvent.module.js +0 -36
- package/dist/useEffectEvent.module.js.map +0 -1
- package/dist/useEvent.main.js +0 -41
- package/dist/useEvent.main.js.map +0 -1
- package/dist/useEvent.mjs +0 -36
- package/dist/useEvent.module.js +0 -36
- package/dist/useEvent.module.js.map +0 -1
- package/dist/useFormReset.main.js +0 -39
- package/dist/useFormReset.main.js.map +0 -1
- package/dist/useFormReset.mjs +0 -34
- package/dist/useFormReset.module.js +0 -34
- package/dist/useFormReset.module.js.map +0 -1
- package/dist/useGlobalListeners.main.js +0 -62
- package/dist/useGlobalListeners.main.js.map +0 -1
- package/dist/useGlobalListeners.mjs +0 -57
- package/dist/useGlobalListeners.module.js +0 -57
- package/dist/useGlobalListeners.module.js.map +0 -1
- package/dist/useId.main.js +0 -108
- package/dist/useId.main.js.map +0 -1
- package/dist/useId.mjs +0 -101
- package/dist/useId.module.js +0 -101
- package/dist/useId.module.js.map +0 -1
- package/dist/useLabels.main.js +0 -44
- package/dist/useLabels.main.js.map +0 -1
- package/dist/useLabels.mjs +0 -39
- package/dist/useLabels.module.js +0 -39
- package/dist/useLabels.module.js.map +0 -1
- package/dist/useLayoutEffect.main.js +0 -27
- package/dist/useLayoutEffect.main.js.map +0 -1
- package/dist/useLayoutEffect.mjs +0 -18
- package/dist/useLayoutEffect.module.js +0 -18
- package/dist/useLayoutEffect.module.js.map +0 -1
- package/dist/useLoadMore.main.js +0 -73
- package/dist/useLoadMore.main.js.map +0 -1
- package/dist/useLoadMore.mjs +0 -68
- package/dist/useLoadMore.module.js +0 -68
- package/dist/useLoadMore.module.js.map +0 -1
- package/dist/useLoadMoreSentinel.main.js +0 -58
- package/dist/useLoadMoreSentinel.main.js.map +0 -1
- package/dist/useLoadMoreSentinel.mjs +0 -53
- package/dist/useLoadMoreSentinel.module.js +0 -53
- package/dist/useLoadMoreSentinel.module.js.map +0 -1
- package/dist/useObjectRef.main.js +0 -58
- package/dist/useObjectRef.main.js.map +0 -1
- package/dist/useObjectRef.mjs +0 -53
- package/dist/useObjectRef.module.js +0 -53
- package/dist/useObjectRef.module.js.map +0 -1
- package/dist/useResizeObserver.main.js +0 -47
- package/dist/useResizeObserver.main.js.map +0 -1
- package/dist/useResizeObserver.mjs +0 -42
- package/dist/useResizeObserver.module.js +0 -42
- package/dist/useResizeObserver.module.js.map +0 -1
- package/dist/useSyncRef.main.js +0 -32
- package/dist/useSyncRef.main.js.map +0 -1
- package/dist/useSyncRef.mjs +0 -27
- package/dist/useSyncRef.module.js +0 -27
- package/dist/useSyncRef.module.js.map +0 -1
- package/dist/useUpdateEffect.main.js +0 -42
- package/dist/useUpdateEffect.main.js.map +0 -1
- package/dist/useUpdateEffect.mjs +0 -37
- package/dist/useUpdateEffect.module.js +0 -37
- package/dist/useUpdateEffect.module.js.map +0 -1
- package/dist/useUpdateLayoutEffect.main.js +0 -40
- package/dist/useUpdateLayoutEffect.main.js.map +0 -1
- package/dist/useUpdateLayoutEffect.mjs +0 -35
- package/dist/useUpdateLayoutEffect.module.js +0 -35
- package/dist/useUpdateLayoutEffect.module.js.map +0 -1
- package/dist/useValueEffect.main.js +0 -63
- package/dist/useValueEffect.main.js.map +0 -1
- package/dist/useValueEffect.mjs +0 -58
- package/dist/useValueEffect.module.js +0 -58
- package/dist/useValueEffect.module.js.map +0 -1
- package/dist/useViewportSize.main.js +0 -79
- package/dist/useViewportSize.main.js.map +0 -1
- package/dist/useViewportSize.mjs +0 -74
- package/dist/useViewportSize.module.js +0 -74
- package/dist/useViewportSize.module.js.map +0 -1
- package/src/animation.ts +0 -103
- package/src/chain.ts +0 -24
- package/src/constants.ts +0 -15
- package/src/domHelpers.ts +0 -33
- package/src/filterDOMProps.ts +0 -127
- package/src/focusWithoutScrolling.ts +0 -96
- package/src/getOffset.ts +0 -21
- package/src/getScrollParent.ts +0 -27
- package/src/getScrollParents.ts +0 -26
- package/src/inertValue.ts +0 -11
- package/src/isElementVisible.ts +0 -75
- package/src/isFocusable.ts +0 -56
- package/src/isScrollable.ts +0 -25
- package/src/isVirtualEvent.ts +0 -58
- package/src/keyboard.tsx +0 -48
- package/src/mergeProps.ts +0 -77
- package/src/mergeRefs.ts +0 -52
- package/src/openLink.tsx +0 -201
- package/src/platform.ts +0 -78
- package/src/runAfterTransition.ts +0 -121
- package/src/scrollIntoView.ts +0 -129
- package/src/shadowdom/DOMFunctions.ts +0 -71
- package/src/shadowdom/ShadowTreeWalker.ts +0 -319
- package/src/useDeepMemo.ts +0 -27
- package/src/useDescription.ts +0 -56
- package/src/useDrag1D.ts +0 -191
- package/src/useEffectEvent.ts +0 -30
- package/src/useEvent.ts +0 -37
- package/src/useFormReset.ts +0 -36
- package/src/useGlobalListeners.ts +0 -52
- package/src/useId.ts +0 -129
- package/src/useLabels.ts +0 -48
- package/src/useLayoutEffect.ts +0 -20
- package/src/useLoadMore.ts +0 -82
- package/src/useLoadMoreSentinel.ts +0 -63
- package/src/useObjectRef.ts +0 -69
- package/src/useResizeObserver.ts +0 -52
- package/src/useSyncRef.ts +0 -33
- package/src/useUpdateEffect.ts +0 -39
- package/src/useUpdateLayoutEffect.ts +0 -37
- package/src/useValueEffect.ts +0 -68
- package/src/useViewportSize.ts +0 -96
package/dist/useId.main.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
|
|
2
|
-
var $19a2307bfabafaf1$exports = require("./useValueEffect.main.js");
|
|
3
|
-
var $dG5aF$react = require("react");
|
|
4
|
-
var $dG5aF$reactariassr = require("@react-aria/ssr");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function $parcel$export(e, n, v, s) {
|
|
8
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
$parcel$export(module.exports, "useId", () => $8c61827343eed941$export$f680877a34711e37);
|
|
12
|
-
$parcel$export(module.exports, "mergeIds", () => $8c61827343eed941$export$cd8c9cb68f842629);
|
|
13
|
-
$parcel$export(module.exports, "useSlotId", () => $8c61827343eed941$export$b4cc09c592e8fdb8);
|
|
14
|
-
/*
|
|
15
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
-
* governing permissions and limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing
|
|
29
|
-
let $8c61827343eed941$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
30
|
-
let $8c61827343eed941$export$d41a04c74483c6ef = new Map();
|
|
31
|
-
// This allows us to clean up the idsUpdaterMap when the id is no longer used.
|
|
32
|
-
// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise.
|
|
33
|
-
// This can happen in suspended components where mount/unmount is not called.
|
|
34
|
-
let $8c61827343eed941$var$registry;
|
|
35
|
-
if (typeof FinalizationRegistry !== 'undefined') $8c61827343eed941$var$registry = new FinalizationRegistry((heldValue)=>{
|
|
36
|
-
$8c61827343eed941$export$d41a04c74483c6ef.delete(heldValue);
|
|
37
|
-
});
|
|
38
|
-
function $8c61827343eed941$export$f680877a34711e37(defaultId) {
|
|
39
|
-
let [value, setValue] = (0, $dG5aF$react.useState)(defaultId);
|
|
40
|
-
let nextId = (0, $dG5aF$react.useRef)(null);
|
|
41
|
-
let res = (0, $dG5aF$reactariassr.useSSRSafeId)(value);
|
|
42
|
-
let cleanupRef = (0, $dG5aF$react.useRef)(null);
|
|
43
|
-
if ($8c61827343eed941$var$registry) $8c61827343eed941$var$registry.register(cleanupRef, res);
|
|
44
|
-
if ($8c61827343eed941$var$canUseDOM) {
|
|
45
|
-
const cacheIdRef = $8c61827343eed941$export$d41a04c74483c6ef.get(res);
|
|
46
|
-
if (cacheIdRef && !cacheIdRef.includes(nextId)) cacheIdRef.push(nextId);
|
|
47
|
-
else $8c61827343eed941$export$d41a04c74483c6ef.set(res, [
|
|
48
|
-
nextId
|
|
49
|
-
]);
|
|
50
|
-
}
|
|
51
|
-
(0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
|
|
52
|
-
let r = res;
|
|
53
|
-
return ()=>{
|
|
54
|
-
// In Suspense, the cleanup function may be not called
|
|
55
|
-
// when it is though, also remove it from the finalization registry.
|
|
56
|
-
if ($8c61827343eed941$var$registry) $8c61827343eed941$var$registry.unregister(cleanupRef);
|
|
57
|
-
$8c61827343eed941$export$d41a04c74483c6ef.delete(r);
|
|
58
|
-
};
|
|
59
|
-
}, [
|
|
60
|
-
res
|
|
61
|
-
]);
|
|
62
|
-
// This cannot cause an infinite loop because the ref is always cleaned up.
|
|
63
|
-
// eslint-disable-next-line
|
|
64
|
-
(0, $dG5aF$react.useEffect)(()=>{
|
|
65
|
-
let newId = nextId.current;
|
|
66
|
-
if (newId) setValue(newId);
|
|
67
|
-
return ()=>{
|
|
68
|
-
if (newId) nextId.current = null;
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
return res;
|
|
72
|
-
}
|
|
73
|
-
function $8c61827343eed941$export$cd8c9cb68f842629(idA, idB) {
|
|
74
|
-
if (idA === idB) return idA;
|
|
75
|
-
let setIdsA = $8c61827343eed941$export$d41a04c74483c6ef.get(idA);
|
|
76
|
-
if (setIdsA) {
|
|
77
|
-
setIdsA.forEach((ref)=>ref.current = idB);
|
|
78
|
-
return idB;
|
|
79
|
-
}
|
|
80
|
-
let setIdsB = $8c61827343eed941$export$d41a04c74483c6ef.get(idB);
|
|
81
|
-
if (setIdsB) {
|
|
82
|
-
setIdsB.forEach((ref)=>ref.current = idA);
|
|
83
|
-
return idA;
|
|
84
|
-
}
|
|
85
|
-
return idB;
|
|
86
|
-
}
|
|
87
|
-
function $8c61827343eed941$export$b4cc09c592e8fdb8(depArray = []) {
|
|
88
|
-
let id = $8c61827343eed941$export$f680877a34711e37();
|
|
89
|
-
let [resolvedId, setResolvedId] = (0, $19a2307bfabafaf1$exports.useValueEffect)(id);
|
|
90
|
-
let updateId = (0, $dG5aF$react.useCallback)(()=>{
|
|
91
|
-
setResolvedId(function*() {
|
|
92
|
-
yield id;
|
|
93
|
-
yield document.getElementById(id) ? id : undefined;
|
|
94
|
-
});
|
|
95
|
-
}, [
|
|
96
|
-
id,
|
|
97
|
-
setResolvedId
|
|
98
|
-
]);
|
|
99
|
-
(0, $78605a5d7424e31b$exports.useLayoutEffect)(updateId, [
|
|
100
|
-
id,
|
|
101
|
-
updateId,
|
|
102
|
-
...depArray
|
|
103
|
-
]);
|
|
104
|
-
return resolvedId;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//# sourceMappingURL=useId.main.js.map
|
package/dist/useId.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAOD,mFAAmF;AACnF,IAAI,kCAAY,QACd,OAAO,WAAW,eAClB,OAAO,QAAQ,IACf,OAAO,QAAQ,CAAC,aAAa;AAGxB,IAAI,4CAA2D,IAAI;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,IAAI;AACJ,IAAI,OAAO,yBAAyB,aAClC,iCAAW,IAAI,qBAA6B,CAAC;IAC3C,0CAAc,MAAM,CAAC;AACvB;AAOK,SAAS,0CAAM,SAAkB;IACtC,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAO,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAE;IAEpB,IAAI,MAAM,CAAA,GAAA,gCAAW,EAAE;IACvB,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAE;IAExB,IAAI,gCACF,+BAAS,QAAQ,CAAC,YAAY;IAGhC,IAAI,iCAAW;QACb,MAAM,aAAa,0CAAc,GAAG,CAAC;QACrC,IAAI,cAAc,CAAC,WAAW,QAAQ,CAAC,SACrC,WAAW,IAAI,CAAC;aAEhB,0CAAc,GAAG,CAAC,KAAK;YAAC;SAAO;IAEnC;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI;QACR,OAAO;YACL,sDAAsD;YACtD,oEAAoE;YACpE,IAAI,gCACF,+BAAS,UAAU,CAAC;YAEtB,0CAAc,MAAM,CAAC;QACvB;IACF,GAAG;QAAC;KAAI;IAER,2EAA2E;IAC3E,2BAA2B;IAC3B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,QAAQ,OAAO,OAAO;QAC1B,IAAI,OAAS,SAAS;QAEtB,OAAO;YACL,IAAI,OAAS,OAAO,OAAO,GAAG;QAChC;IACF;IAEA,OAAO;AACT;AAMO,SAAS,0CAAS,GAAW,EAAE,GAAW;IAC/C,IAAI,QAAQ,KACV,OAAO;IAGT,IAAI,UAAU,0CAAc,GAAG,CAAC;IAChC,IAAI,SAAS;QACX,QAAQ,OAAO,CAAC,CAAA,MAAQ,IAAI,OAAO,GAAG;QACtC,OAAO;IACT;IAEA,IAAI,UAAU,0CAAc,GAAG,CAAC;IAChC,IAAI,SAAS;QACX,QAAQ,OAAO,CAAC,CAAC,MAAS,IAAI,OAAO,GAAG;QACxC,OAAO;IACT;IAEA,OAAO;AACT;AAOO,SAAS,0CAAU,WAA+B,EAAE;IACzD,IAAI,KAAK;IACT,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,wCAAa,EAAE;IACjD,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE;QACzB,cAAc;YACZ,MAAM;YAEN,MAAM,SAAS,cAAc,CAAC,MAAM,KAAK;QAC3C;IACF,GAAG;QAAC;QAAI;KAAc;IAEtB,CAAA,GAAA,yCAAc,EAAE,UAAU;QAAC;QAAI;WAAa;KAAS;IAErD,OAAO;AACT","sources":["packages/@react-aria/utils/src/useId.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 {useCallback, useEffect, useRef, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useSSRSafeId} from '@react-aria/ssr';\nimport {useValueEffect} from './';\n\n// copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing\nlet canUseDOM = Boolean(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\nexport let idsUpdaterMap: Map<string, { current: string | null }[]> = new Map();\n// This allows us to clean up the idsUpdaterMap when the id is no longer used.\n// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise.\n// This can happen in suspended components where mount/unmount is not called.\nlet registry;\nif (typeof FinalizationRegistry !== 'undefined') {\n registry = new FinalizationRegistry<string>((heldValue) => {\n idsUpdaterMap.delete(heldValue);\n });\n}\n\n/**\n * If a default is not provided, generate an id.\n * @param defaultId - Default component id.\n */\nexport function useId(defaultId?: string): string {\n let [value, setValue] = useState(defaultId);\n let nextId = useRef(null);\n\n let res = useSSRSafeId(value);\n let cleanupRef = useRef(null);\n\n if (registry) {\n registry.register(cleanupRef, res);\n }\n\n if (canUseDOM) {\n const cacheIdRef = idsUpdaterMap.get(res);\n if (cacheIdRef && !cacheIdRef.includes(nextId)) {\n cacheIdRef.push(nextId);\n } else {\n idsUpdaterMap.set(res, [nextId]);\n }\n }\n\n useLayoutEffect(() => {\n let r = res;\n return () => {\n // In Suspense, the cleanup function may be not called\n // when it is though, also remove it from the finalization registry.\n if (registry) {\n registry.unregister(cleanupRef);\n }\n idsUpdaterMap.delete(r);\n };\n }, [res]);\n\n // This cannot cause an infinite loop because the ref is always cleaned up.\n // eslint-disable-next-line\n useEffect(() => {\n let newId = nextId.current;\n if (newId) { setValue(newId); }\n\n return () => {\n if (newId) { nextId.current = null; }\n };\n });\n\n return res;\n}\n\n/**\n * Merges two ids.\n * Different ids will trigger a side-effect and re-render components hooked up with `useId`.\n */\nexport function mergeIds(idA: string, idB: string): string {\n if (idA === idB) {\n return idA;\n }\n\n let setIdsA = idsUpdaterMap.get(idA);\n if (setIdsA) {\n setIdsA.forEach(ref => (ref.current = idB));\n return idB;\n }\n\n let setIdsB = idsUpdaterMap.get(idB);\n if (setIdsB) {\n setIdsB.forEach((ref) => (ref.current = idA));\n return idA;\n }\n\n return idB;\n}\n\n/**\n * Used to generate an id, and after render, check if that id is rendered so we know\n * if we can use it in places such as labelledby.\n * @param depArray - When to recalculate if the id is in the DOM.\n */\nexport function useSlotId(depArray: ReadonlyArray<any> = []): string {\n let id = useId();\n let [resolvedId, setResolvedId] = useValueEffect(id);\n let updateId = useCallback(() => {\n setResolvedId(function *() {\n yield id;\n\n yield document.getElementById(id) ? id : undefined;\n });\n }, [id, setResolvedId]);\n\n useLayoutEffect(updateId, [id, updateId, ...depArray]);\n\n return resolvedId;\n}\n"],"names":[],"version":3,"file":"useId.main.js.map"}
|
package/dist/useId.mjs
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
|
|
2
|
-
import {useValueEffect as $1dbecbe27a04f9af$export$14d238f342723f25} from "./useValueEffect.mjs";
|
|
3
|
-
import {useState as $eKkEp$useState, useRef as $eKkEp$useRef, useEffect as $eKkEp$useEffect, useCallback as $eKkEp$useCallback} from "react";
|
|
4
|
-
import {useSSRSafeId as $eKkEp$useSSRSafeId} from "@react-aria/ssr";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
8
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
-
* governing permissions and limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing
|
|
21
|
-
let $bdb11010cef70236$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
22
|
-
let $bdb11010cef70236$export$d41a04c74483c6ef = new Map();
|
|
23
|
-
// This allows us to clean up the idsUpdaterMap when the id is no longer used.
|
|
24
|
-
// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise.
|
|
25
|
-
// This can happen in suspended components where mount/unmount is not called.
|
|
26
|
-
let $bdb11010cef70236$var$registry;
|
|
27
|
-
if (typeof FinalizationRegistry !== 'undefined') $bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue)=>{
|
|
28
|
-
$bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue);
|
|
29
|
-
});
|
|
30
|
-
function $bdb11010cef70236$export$f680877a34711e37(defaultId) {
|
|
31
|
-
let [value, setValue] = (0, $eKkEp$useState)(defaultId);
|
|
32
|
-
let nextId = (0, $eKkEp$useRef)(null);
|
|
33
|
-
let res = (0, $eKkEp$useSSRSafeId)(value);
|
|
34
|
-
let cleanupRef = (0, $eKkEp$useRef)(null);
|
|
35
|
-
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.register(cleanupRef, res);
|
|
36
|
-
if ($bdb11010cef70236$var$canUseDOM) {
|
|
37
|
-
const cacheIdRef = $bdb11010cef70236$export$d41a04c74483c6ef.get(res);
|
|
38
|
-
if (cacheIdRef && !cacheIdRef.includes(nextId)) cacheIdRef.push(nextId);
|
|
39
|
-
else $bdb11010cef70236$export$d41a04c74483c6ef.set(res, [
|
|
40
|
-
nextId
|
|
41
|
-
]);
|
|
42
|
-
}
|
|
43
|
-
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
44
|
-
let r = res;
|
|
45
|
-
return ()=>{
|
|
46
|
-
// In Suspense, the cleanup function may be not called
|
|
47
|
-
// when it is though, also remove it from the finalization registry.
|
|
48
|
-
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.unregister(cleanupRef);
|
|
49
|
-
$bdb11010cef70236$export$d41a04c74483c6ef.delete(r);
|
|
50
|
-
};
|
|
51
|
-
}, [
|
|
52
|
-
res
|
|
53
|
-
]);
|
|
54
|
-
// This cannot cause an infinite loop because the ref is always cleaned up.
|
|
55
|
-
// eslint-disable-next-line
|
|
56
|
-
(0, $eKkEp$useEffect)(()=>{
|
|
57
|
-
let newId = nextId.current;
|
|
58
|
-
if (newId) setValue(newId);
|
|
59
|
-
return ()=>{
|
|
60
|
-
if (newId) nextId.current = null;
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
return res;
|
|
64
|
-
}
|
|
65
|
-
function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
|
|
66
|
-
if (idA === idB) return idA;
|
|
67
|
-
let setIdsA = $bdb11010cef70236$export$d41a04c74483c6ef.get(idA);
|
|
68
|
-
if (setIdsA) {
|
|
69
|
-
setIdsA.forEach((ref)=>ref.current = idB);
|
|
70
|
-
return idB;
|
|
71
|
-
}
|
|
72
|
-
let setIdsB = $bdb11010cef70236$export$d41a04c74483c6ef.get(idB);
|
|
73
|
-
if (setIdsB) {
|
|
74
|
-
setIdsB.forEach((ref)=>ref.current = idA);
|
|
75
|
-
return idA;
|
|
76
|
-
}
|
|
77
|
-
return idB;
|
|
78
|
-
}
|
|
79
|
-
function $bdb11010cef70236$export$b4cc09c592e8fdb8(depArray = []) {
|
|
80
|
-
let id = $bdb11010cef70236$export$f680877a34711e37();
|
|
81
|
-
let [resolvedId, setResolvedId] = (0, $1dbecbe27a04f9af$export$14d238f342723f25)(id);
|
|
82
|
-
let updateId = (0, $eKkEp$useCallback)(()=>{
|
|
83
|
-
setResolvedId(function*() {
|
|
84
|
-
yield id;
|
|
85
|
-
yield document.getElementById(id) ? id : undefined;
|
|
86
|
-
});
|
|
87
|
-
}, [
|
|
88
|
-
id,
|
|
89
|
-
setResolvedId
|
|
90
|
-
]);
|
|
91
|
-
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(updateId, [
|
|
92
|
-
id,
|
|
93
|
-
updateId,
|
|
94
|
-
...depArray
|
|
95
|
-
]);
|
|
96
|
-
return resolvedId;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export {$bdb11010cef70236$export$d41a04c74483c6ef as idsUpdaterMap, $bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId};
|
|
101
|
-
//# sourceMappingURL=useId.module.js.map
|
package/dist/useId.module.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
|
|
2
|
-
import {useValueEffect as $1dbecbe27a04f9af$export$14d238f342723f25} from "./useValueEffect.module.js";
|
|
3
|
-
import {useState as $eKkEp$useState, useRef as $eKkEp$useRef, useEffect as $eKkEp$useEffect, useCallback as $eKkEp$useCallback} from "react";
|
|
4
|
-
import {useSSRSafeId as $eKkEp$useSSRSafeId} from "@react-aria/ssr";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
8
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
-
* governing permissions and limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing
|
|
21
|
-
let $bdb11010cef70236$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
22
|
-
let $bdb11010cef70236$export$d41a04c74483c6ef = new Map();
|
|
23
|
-
// This allows us to clean up the idsUpdaterMap when the id is no longer used.
|
|
24
|
-
// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise.
|
|
25
|
-
// This can happen in suspended components where mount/unmount is not called.
|
|
26
|
-
let $bdb11010cef70236$var$registry;
|
|
27
|
-
if (typeof FinalizationRegistry !== 'undefined') $bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue)=>{
|
|
28
|
-
$bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue);
|
|
29
|
-
});
|
|
30
|
-
function $bdb11010cef70236$export$f680877a34711e37(defaultId) {
|
|
31
|
-
let [value, setValue] = (0, $eKkEp$useState)(defaultId);
|
|
32
|
-
let nextId = (0, $eKkEp$useRef)(null);
|
|
33
|
-
let res = (0, $eKkEp$useSSRSafeId)(value);
|
|
34
|
-
let cleanupRef = (0, $eKkEp$useRef)(null);
|
|
35
|
-
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.register(cleanupRef, res);
|
|
36
|
-
if ($bdb11010cef70236$var$canUseDOM) {
|
|
37
|
-
const cacheIdRef = $bdb11010cef70236$export$d41a04c74483c6ef.get(res);
|
|
38
|
-
if (cacheIdRef && !cacheIdRef.includes(nextId)) cacheIdRef.push(nextId);
|
|
39
|
-
else $bdb11010cef70236$export$d41a04c74483c6ef.set(res, [
|
|
40
|
-
nextId
|
|
41
|
-
]);
|
|
42
|
-
}
|
|
43
|
-
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
44
|
-
let r = res;
|
|
45
|
-
return ()=>{
|
|
46
|
-
// In Suspense, the cleanup function may be not called
|
|
47
|
-
// when it is though, also remove it from the finalization registry.
|
|
48
|
-
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.unregister(cleanupRef);
|
|
49
|
-
$bdb11010cef70236$export$d41a04c74483c6ef.delete(r);
|
|
50
|
-
};
|
|
51
|
-
}, [
|
|
52
|
-
res
|
|
53
|
-
]);
|
|
54
|
-
// This cannot cause an infinite loop because the ref is always cleaned up.
|
|
55
|
-
// eslint-disable-next-line
|
|
56
|
-
(0, $eKkEp$useEffect)(()=>{
|
|
57
|
-
let newId = nextId.current;
|
|
58
|
-
if (newId) setValue(newId);
|
|
59
|
-
return ()=>{
|
|
60
|
-
if (newId) nextId.current = null;
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
return res;
|
|
64
|
-
}
|
|
65
|
-
function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
|
|
66
|
-
if (idA === idB) return idA;
|
|
67
|
-
let setIdsA = $bdb11010cef70236$export$d41a04c74483c6ef.get(idA);
|
|
68
|
-
if (setIdsA) {
|
|
69
|
-
setIdsA.forEach((ref)=>ref.current = idB);
|
|
70
|
-
return idB;
|
|
71
|
-
}
|
|
72
|
-
let setIdsB = $bdb11010cef70236$export$d41a04c74483c6ef.get(idB);
|
|
73
|
-
if (setIdsB) {
|
|
74
|
-
setIdsB.forEach((ref)=>ref.current = idA);
|
|
75
|
-
return idA;
|
|
76
|
-
}
|
|
77
|
-
return idB;
|
|
78
|
-
}
|
|
79
|
-
function $bdb11010cef70236$export$b4cc09c592e8fdb8(depArray = []) {
|
|
80
|
-
let id = $bdb11010cef70236$export$f680877a34711e37();
|
|
81
|
-
let [resolvedId, setResolvedId] = (0, $1dbecbe27a04f9af$export$14d238f342723f25)(id);
|
|
82
|
-
let updateId = (0, $eKkEp$useCallback)(()=>{
|
|
83
|
-
setResolvedId(function*() {
|
|
84
|
-
yield id;
|
|
85
|
-
yield document.getElementById(id) ? id : undefined;
|
|
86
|
-
});
|
|
87
|
-
}, [
|
|
88
|
-
id,
|
|
89
|
-
setResolvedId
|
|
90
|
-
]);
|
|
91
|
-
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(updateId, [
|
|
92
|
-
id,
|
|
93
|
-
updateId,
|
|
94
|
-
...depArray
|
|
95
|
-
]);
|
|
96
|
-
return resolvedId;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export {$bdb11010cef70236$export$d41a04c74483c6ef as idsUpdaterMap, $bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId};
|
|
101
|
-
//# sourceMappingURL=useId.module.js.map
|
package/dist/useId.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAOD,mFAAmF;AACnF,IAAI,kCAAY,QACd,OAAO,WAAW,eAClB,OAAO,QAAQ,IACf,OAAO,QAAQ,CAAC,aAAa;AAGxB,IAAI,4CAA2D,IAAI;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,IAAI;AACJ,IAAI,OAAO,yBAAyB,aAClC,iCAAW,IAAI,qBAA6B,CAAC;IAC3C,0CAAc,MAAM,CAAC;AACvB;AAOK,SAAS,0CAAM,SAAkB;IACtC,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,aAAK,EAAE;IAEpB,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IACvB,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;IAExB,IAAI,gCACF,+BAAS,QAAQ,CAAC,YAAY;IAGhC,IAAI,iCAAW;QACb,MAAM,aAAa,0CAAc,GAAG,CAAC;QACrC,IAAI,cAAc,CAAC,WAAW,QAAQ,CAAC,SACrC,WAAW,IAAI,CAAC;aAEhB,0CAAc,GAAG,CAAC,KAAK;YAAC;SAAO;IAEnC;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI;QACR,OAAO;YACL,sDAAsD;YACtD,oEAAoE;YACpE,IAAI,gCACF,+BAAS,UAAU,CAAC;YAEtB,0CAAc,MAAM,CAAC;QACvB;IACF,GAAG;QAAC;KAAI;IAER,2EAA2E;IAC3E,2BAA2B;IAC3B,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,QAAQ,OAAO,OAAO;QAC1B,IAAI,OAAS,SAAS;QAEtB,OAAO;YACL,IAAI,OAAS,OAAO,OAAO,GAAG;QAChC;IACF;IAEA,OAAO;AACT;AAMO,SAAS,0CAAS,GAAW,EAAE,GAAW;IAC/C,IAAI,QAAQ,KACV,OAAO;IAGT,IAAI,UAAU,0CAAc,GAAG,CAAC;IAChC,IAAI,SAAS;QACX,QAAQ,OAAO,CAAC,CAAA,MAAQ,IAAI,OAAO,GAAG;QACtC,OAAO;IACT;IAEA,IAAI,UAAU,0CAAc,GAAG,CAAC;IAChC,IAAI,SAAS;QACX,QAAQ,OAAO,CAAC,CAAC,MAAS,IAAI,OAAO,GAAG;QACxC,OAAO;IACT;IAEA,OAAO;AACT;AAOO,SAAS,0CAAU,WAA+B,EAAE;IACzD,IAAI,KAAK;IACT,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,yCAAa,EAAE;IACjD,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QACzB,cAAc;YACZ,MAAM;YAEN,MAAM,SAAS,cAAc,CAAC,MAAM,KAAK;QAC3C;IACF,GAAG;QAAC;QAAI;KAAc;IAEtB,CAAA,GAAA,yCAAc,EAAE,UAAU;QAAC;QAAI;WAAa;KAAS;IAErD,OAAO;AACT","sources":["packages/@react-aria/utils/src/useId.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 {useCallback, useEffect, useRef, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useSSRSafeId} from '@react-aria/ssr';\nimport {useValueEffect} from './';\n\n// copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing\nlet canUseDOM = Boolean(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\nexport let idsUpdaterMap: Map<string, { current: string | null }[]> = new Map();\n// This allows us to clean up the idsUpdaterMap when the id is no longer used.\n// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise.\n// This can happen in suspended components where mount/unmount is not called.\nlet registry;\nif (typeof FinalizationRegistry !== 'undefined') {\n registry = new FinalizationRegistry<string>((heldValue) => {\n idsUpdaterMap.delete(heldValue);\n });\n}\n\n/**\n * If a default is not provided, generate an id.\n * @param defaultId - Default component id.\n */\nexport function useId(defaultId?: string): string {\n let [value, setValue] = useState(defaultId);\n let nextId = useRef(null);\n\n let res = useSSRSafeId(value);\n let cleanupRef = useRef(null);\n\n if (registry) {\n registry.register(cleanupRef, res);\n }\n\n if (canUseDOM) {\n const cacheIdRef = idsUpdaterMap.get(res);\n if (cacheIdRef && !cacheIdRef.includes(nextId)) {\n cacheIdRef.push(nextId);\n } else {\n idsUpdaterMap.set(res, [nextId]);\n }\n }\n\n useLayoutEffect(() => {\n let r = res;\n return () => {\n // In Suspense, the cleanup function may be not called\n // when it is though, also remove it from the finalization registry.\n if (registry) {\n registry.unregister(cleanupRef);\n }\n idsUpdaterMap.delete(r);\n };\n }, [res]);\n\n // This cannot cause an infinite loop because the ref is always cleaned up.\n // eslint-disable-next-line\n useEffect(() => {\n let newId = nextId.current;\n if (newId) { setValue(newId); }\n\n return () => {\n if (newId) { nextId.current = null; }\n };\n });\n\n return res;\n}\n\n/**\n * Merges two ids.\n * Different ids will trigger a side-effect and re-render components hooked up with `useId`.\n */\nexport function mergeIds(idA: string, idB: string): string {\n if (idA === idB) {\n return idA;\n }\n\n let setIdsA = idsUpdaterMap.get(idA);\n if (setIdsA) {\n setIdsA.forEach(ref => (ref.current = idB));\n return idB;\n }\n\n let setIdsB = idsUpdaterMap.get(idB);\n if (setIdsB) {\n setIdsB.forEach((ref) => (ref.current = idA));\n return idA;\n }\n\n return idB;\n}\n\n/**\n * Used to generate an id, and after render, check if that id is rendered so we know\n * if we can use it in places such as labelledby.\n * @param depArray - When to recalculate if the id is in the DOM.\n */\nexport function useSlotId(depArray: ReadonlyArray<any> = []): string {\n let id = useId();\n let [resolvedId, setResolvedId] = useValueEffect(id);\n let updateId = useCallback(() => {\n setResolvedId(function *() {\n yield id;\n\n yield document.getElementById(id) ? id : undefined;\n });\n }, [id, setResolvedId]);\n\n useLayoutEffect(updateId, [id, updateId, ...depArray]);\n\n return resolvedId;\n}\n"],"names":[],"version":3,"file":"useId.module.js.map"}
|
package/dist/useLabels.main.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var $8c61827343eed941$exports = require("./useId.main.js");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$export(e, n, v, s) {
|
|
5
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
$parcel$export(module.exports, "useLabels", () => $6ec78bde395c477d$export$d6875122194c7b44);
|
|
9
|
-
/*
|
|
10
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
-
* governing permissions and limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
function $6ec78bde395c477d$export$d6875122194c7b44(props, defaultLabel) {
|
|
21
|
-
let { id: id, 'aria-label': label, 'aria-labelledby': labelledBy } = props;
|
|
22
|
-
// If there is both an aria-label and aria-labelledby,
|
|
23
|
-
// combine them by pointing to the element itself.
|
|
24
|
-
id = (0, $8c61827343eed941$exports.useId)(id);
|
|
25
|
-
if (labelledBy && label) {
|
|
26
|
-
let ids = new Set([
|
|
27
|
-
id,
|
|
28
|
-
...labelledBy.trim().split(/\s+/)
|
|
29
|
-
]);
|
|
30
|
-
labelledBy = [
|
|
31
|
-
...ids
|
|
32
|
-
].join(' ');
|
|
33
|
-
} else if (labelledBy) labelledBy = labelledBy.trim().split(/\s+/).join(' ');
|
|
34
|
-
// If no labels are provided, use the default
|
|
35
|
-
if (!label && !labelledBy && defaultLabel) label = defaultLabel;
|
|
36
|
-
return {
|
|
37
|
-
id: id,
|
|
38
|
-
'aria-label': label,
|
|
39
|
-
'aria-labelledby': labelledBy
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=useLabels.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,SAAS,0CAAU,KAAmC,EAAE,YAAqB;IAClF,IAAI,MACF,EAAE,EACF,cAAc,KAAK,EACnB,mBAAmB,UAAU,EAC9B,GAAG;IAEJ,sDAAsD;IACtD,kDAAkD;IAClD,KAAK,CAAA,GAAA,+BAAI,EAAE;IACX,IAAI,cAAc,OAAO;QACvB,IAAI,MAAM,IAAI,IAAI;YAAC;eAAO,WAAW,IAAI,GAAG,KAAK,CAAC;SAAO;QACzD,aAAa;eAAI;SAAI,CAAC,IAAI,CAAC;IAC7B,OAAO,IAAI,YACT,aAAa,WAAW,IAAI,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC;IAGnD,6CAA6C;IAC7C,IAAI,CAAC,SAAS,CAAC,cAAc,cAC3B,QAAQ;IAGV,OAAO;YACL;QACA,cAAc;QACd,mBAAmB;IACrB;AACF","sources":["packages/@react-aria/utils/src/useLabels.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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {useId} from './useId';\n\n/**\n * Merges aria-label and aria-labelledby into aria-labelledby when both exist.\n * @param props - Aria label props.\n * @param defaultLabel - Default value for aria-label when not present.\n */\nexport function useLabels(props: DOMProps & AriaLabelingProps, defaultLabel?: string): DOMProps & AriaLabelingProps {\n let {\n id,\n 'aria-label': label,\n 'aria-labelledby': labelledBy\n } = props;\n\n // If there is both an aria-label and aria-labelledby,\n // combine them by pointing to the element itself.\n id = useId(id);\n if (labelledBy && label) {\n let ids = new Set([id, ...labelledBy.trim().split(/\\s+/)]);\n labelledBy = [...ids].join(' ');\n } else if (labelledBy) {\n labelledBy = labelledBy.trim().split(/\\s+/).join(' ');\n }\n\n // If no labels are provided, use the default\n if (!label && !labelledBy && defaultLabel) {\n label = defaultLabel;\n }\n\n return {\n id,\n 'aria-label': label,\n 'aria-labelledby': labelledBy\n };\n}\n"],"names":[],"version":3,"file":"useLabels.main.js.map"}
|
package/dist/useLabels.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {useId as $bdb11010cef70236$export$f680877a34711e37} from "./useId.mjs";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
|
|
15
|
-
let { id: id, 'aria-label': label, 'aria-labelledby': labelledBy } = props;
|
|
16
|
-
// If there is both an aria-label and aria-labelledby,
|
|
17
|
-
// combine them by pointing to the element itself.
|
|
18
|
-
id = (0, $bdb11010cef70236$export$f680877a34711e37)(id);
|
|
19
|
-
if (labelledBy && label) {
|
|
20
|
-
let ids = new Set([
|
|
21
|
-
id,
|
|
22
|
-
...labelledBy.trim().split(/\s+/)
|
|
23
|
-
]);
|
|
24
|
-
labelledBy = [
|
|
25
|
-
...ids
|
|
26
|
-
].join(' ');
|
|
27
|
-
} else if (labelledBy) labelledBy = labelledBy.trim().split(/\s+/).join(' ');
|
|
28
|
-
// If no labels are provided, use the default
|
|
29
|
-
if (!label && !labelledBy && defaultLabel) label = defaultLabel;
|
|
30
|
-
return {
|
|
31
|
-
id: id,
|
|
32
|
-
'aria-label': label,
|
|
33
|
-
'aria-labelledby': labelledBy
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export {$313b98861ee5dd6c$export$d6875122194c7b44 as useLabels};
|
|
39
|
-
//# sourceMappingURL=useLabels.module.js.map
|
package/dist/useLabels.module.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {useId as $bdb11010cef70236$export$f680877a34711e37} from "./useId.module.js";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
|
|
15
|
-
let { id: id, 'aria-label': label, 'aria-labelledby': labelledBy } = props;
|
|
16
|
-
// If there is both an aria-label and aria-labelledby,
|
|
17
|
-
// combine them by pointing to the element itself.
|
|
18
|
-
id = (0, $bdb11010cef70236$export$f680877a34711e37)(id);
|
|
19
|
-
if (labelledBy && label) {
|
|
20
|
-
let ids = new Set([
|
|
21
|
-
id,
|
|
22
|
-
...labelledBy.trim().split(/\s+/)
|
|
23
|
-
]);
|
|
24
|
-
labelledBy = [
|
|
25
|
-
...ids
|
|
26
|
-
].join(' ');
|
|
27
|
-
} else if (labelledBy) labelledBy = labelledBy.trim().split(/\s+/).join(' ');
|
|
28
|
-
// If no labels are provided, use the default
|
|
29
|
-
if (!label && !labelledBy && defaultLabel) label = defaultLabel;
|
|
30
|
-
return {
|
|
31
|
-
id: id,
|
|
32
|
-
'aria-label': label,
|
|
33
|
-
'aria-labelledby': labelledBy
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export {$313b98861ee5dd6c$export$d6875122194c7b44 as useLabels};
|
|
39
|
-
//# sourceMappingURL=useLabels.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,SAAS,0CAAU,KAAmC,EAAE,YAAqB;IAClF,IAAI,MACF,EAAE,EACF,cAAc,KAAK,EACnB,mBAAmB,UAAU,EAC9B,GAAG;IAEJ,sDAAsD;IACtD,kDAAkD;IAClD,KAAK,CAAA,GAAA,yCAAI,EAAE;IACX,IAAI,cAAc,OAAO;QACvB,IAAI,MAAM,IAAI,IAAI;YAAC;eAAO,WAAW,IAAI,GAAG,KAAK,CAAC;SAAO;QACzD,aAAa;eAAI;SAAI,CAAC,IAAI,CAAC;IAC7B,OAAO,IAAI,YACT,aAAa,WAAW,IAAI,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC;IAGnD,6CAA6C;IAC7C,IAAI,CAAC,SAAS,CAAC,cAAc,cAC3B,QAAQ;IAGV,OAAO;YACL;QACA,cAAc;QACd,mBAAmB;IACrB;AACF","sources":["packages/@react-aria/utils/src/useLabels.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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {useId} from './useId';\n\n/**\n * Merges aria-label and aria-labelledby into aria-labelledby when both exist.\n * @param props - Aria label props.\n * @param defaultLabel - Default value for aria-label when not present.\n */\nexport function useLabels(props: DOMProps & AriaLabelingProps, defaultLabel?: string): DOMProps & AriaLabelingProps {\n let {\n id,\n 'aria-label': label,\n 'aria-labelledby': labelledBy\n } = props;\n\n // If there is both an aria-label and aria-labelledby,\n // combine them by pointing to the element itself.\n id = useId(id);\n if (labelledBy && label) {\n let ids = new Set([id, ...labelledBy.trim().split(/\\s+/)]);\n labelledBy = [...ids].join(' ');\n } else if (labelledBy) {\n labelledBy = labelledBy.trim().split(/\\s+/).join(' ');\n }\n\n // If no labels are provided, use the default\n if (!label && !labelledBy && defaultLabel) {\n label = defaultLabel;\n }\n\n return {\n id,\n 'aria-label': label,\n 'aria-labelledby': labelledBy\n };\n}\n"],"names":[],"version":3,"file":"useLabels.module.js.map"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var $ezjoC$react = require("react");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$interopDefault(a) {
|
|
5
|
-
return a && a.__esModule ? a.default : a;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function $parcel$export(e, n, v, s) {
|
|
9
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
$parcel$export(module.exports, "useLayoutEffect", () => $78605a5d7424e31b$export$e5c5a5f917a5871c);
|
|
13
|
-
/*
|
|
14
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
-
*
|
|
19
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
-
* governing permissions and limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
const $78605a5d7424e31b$export$e5c5a5f917a5871c = typeof document !== 'undefined' ? (0, ($parcel$interopDefault($ezjoC$react))).useLayoutEffect : ()=>{};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=useLayoutEffect.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAOM,MAAM,4CAAgD,OAAO,aAAa,cAC7E,CAAA,GAAA,sCAAI,EAAE,eAAe,GACrB,KAAO","sources":["packages/@react-aria/utils/src/useLayoutEffect.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 React from 'react';\n\n// During SSR, React emits a warning when calling useLayoutEffect.\n// Since neither useLayoutEffect nor useEffect run on the server,\n// we can suppress this by replace it with a noop on the server.\nexport const useLayoutEffect: typeof React.useLayoutEffect = typeof document !== 'undefined'\n ? React.useLayoutEffect\n : () => {};\n"],"names":[],"version":3,"file":"useLayoutEffect.main.js.map"}
|
package/dist/useLayoutEffect.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import $HgANd$react from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document !== 'undefined' ? (0, $HgANd$react).useLayoutEffect : ()=>{};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export {$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect};
|
|
18
|
-
//# sourceMappingURL=useLayoutEffect.module.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import $HgANd$react from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document !== 'undefined' ? (0, $HgANd$react).useLayoutEffect : ()=>{};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export {$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect};
|
|
18
|
-
//# sourceMappingURL=useLayoutEffect.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAOM,MAAM,4CAAgD,OAAO,aAAa,cAC7E,CAAA,GAAA,YAAI,EAAE,eAAe,GACrB,KAAO","sources":["packages/@react-aria/utils/src/useLayoutEffect.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 React from 'react';\n\n// During SSR, React emits a warning when calling useLayoutEffect.\n// Since neither useLayoutEffect nor useEffect run on the server,\n// we can suppress this by replace it with a noop on the server.\nexport const useLayoutEffect: typeof React.useLayoutEffect = typeof document !== 'undefined'\n ? React.useLayoutEffect\n : () => {};\n"],"names":[],"version":3,"file":"useLayoutEffect.module.js.map"}
|
package/dist/useLoadMore.main.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
items
|
|
65
|
-
]);
|
|
66
|
-
// TODO: maybe this should still just return scroll props?
|
|
67
|
-
// Test against case where the ref isn't defined when this is called
|
|
68
|
-
// Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll
|
|
69
|
-
(0, $2a8c0bb1629926c8$exports.useEvent)(ref, 'scroll', onScroll);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
//# sourceMappingURL=useLoadMore.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;QAAK;KAAM;IAE7C,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\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.main.js.map"}
|