@react-aria/utils 3.25.2 → 3.26.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/focusWithoutScrolling.main.js +1 -1
- package/dist/focusWithoutScrolling.main.js.map +1 -1
- package/dist/focusWithoutScrolling.mjs +1 -1
- package/dist/focusWithoutScrolling.module.js +1 -1
- package/dist/focusWithoutScrolling.module.js.map +1 -1
- package/dist/isScrollable.main.js +1 -0
- package/dist/isScrollable.main.js.map +1 -1
- package/dist/isScrollable.mjs +1 -0
- package/dist/isScrollable.module.js +1 -0
- package/dist/isScrollable.module.js.map +1 -1
- package/dist/mergeProps.main.js.map +1 -1
- package/dist/mergeProps.module.js.map +1 -1
- package/dist/openLink.main.js +6 -2
- package/dist/openLink.main.js.map +1 -1
- package/dist/openLink.mjs +6 -2
- package/dist/openLink.module.js +6 -2
- package/dist/openLink.module.js.map +1 -1
- package/dist/scrollIntoView.main.js +1 -1
- package/dist/scrollIntoView.main.js.map +1 -1
- package/dist/scrollIntoView.mjs +1 -1
- package/dist/scrollIntoView.module.js +1 -1
- package/dist/scrollIntoView.module.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/useDescription.main.js.map +1 -1
- package/dist/useDescription.module.js.map +1 -1
- package/dist/useFormReset.main.js.map +1 -1
- package/dist/useFormReset.module.js.map +1 -1
- package/dist/useGlobalListeners.main.js +0 -1
- package/dist/useGlobalListeners.main.js.map +1 -1
- package/dist/useGlobalListeners.mjs +0 -1
- package/dist/useGlobalListeners.module.js +0 -1
- package/dist/useGlobalListeners.module.js.map +1 -1
- package/dist/useId.main.js +16 -7
- package/dist/useId.main.js.map +1 -1
- package/dist/useId.mjs +16 -7
- package/dist/useId.module.js +16 -7
- package/dist/useId.module.js.map +1 -1
- package/dist/useLoadMore.main.js +2 -1
- package/dist/useLoadMore.main.js.map +1 -1
- package/dist/useLoadMore.mjs +2 -1
- package/dist/useLoadMore.module.js +2 -1
- package/dist/useLoadMore.module.js.map +1 -1
- package/dist/useViewportSize.main.js +0 -1
- package/dist/useViewportSize.main.js.map +1 -1
- package/dist/useViewportSize.mjs +0 -1
- package/dist/useViewportSize.module.js +0 -1
- package/dist/useViewportSize.module.js.map +1 -1
- package/package.json +6 -6
- package/src/focusWithoutScrolling.ts +1 -1
- package/src/isScrollable.ts +4 -1
- package/src/mergeProps.ts +1 -1
- package/src/openLink.tsx +5 -3
- package/src/scrollIntoView.ts +3 -3
- package/src/useFormReset.ts +1 -1
- package/src/useGlobalListeners.ts +1 -1
- package/src/useId.ts +13 -8
- package/src/useLoadMore.ts +3 -3
- package/src/useViewportSize.ts +0 -1
package/src/openLink.tsx
CHANGED
|
@@ -148,8 +148,9 @@ function openSyntheticLink(target: Element, modifiers: Modifiers) {
|
|
|
148
148
|
|
|
149
149
|
export function useSyntheticLinkProps(props: LinkDOMProps) {
|
|
150
150
|
let router = useRouter();
|
|
151
|
+
const href = router.useHref(props.href ?? '');
|
|
151
152
|
return {
|
|
152
|
-
'data-href': props.href ?
|
|
153
|
+
'data-href': props.href ? href : undefined,
|
|
153
154
|
'data-target': props.target,
|
|
154
155
|
'data-rel': props.rel,
|
|
155
156
|
'data-download': props.download,
|
|
@@ -170,10 +171,11 @@ export function getSyntheticLinkProps(props: LinkDOMProps) {
|
|
|
170
171
|
};
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
export function useLinkProps(props
|
|
174
|
+
export function useLinkProps(props?: LinkDOMProps) {
|
|
174
175
|
let router = useRouter();
|
|
176
|
+
const href = router.useHref(props?.href ?? '');
|
|
175
177
|
return {
|
|
176
|
-
href: props?.href ?
|
|
178
|
+
href: props?.href ? href : undefined,
|
|
177
179
|
target: props?.target,
|
|
178
180
|
rel: props?.rel,
|
|
179
181
|
download: props?.download,
|
package/src/scrollIntoView.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {getScrollParents} from './getScrollParents';
|
|
|
14
14
|
|
|
15
15
|
interface ScrollIntoViewportOpts {
|
|
16
16
|
/** The optional containing element of the target to be centered in the viewport. */
|
|
17
|
-
containingElement?: Element
|
|
17
|
+
containingElement?: Element | null
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -81,8 +81,8 @@ function relativeOffset(ancestor: HTMLElement, child: HTMLElement, axis: 'left'|
|
|
|
81
81
|
* that will be centered in the viewport prior to scrolling the targetElement into view. If scrolling is prevented on
|
|
82
82
|
* the body (e.g. targetElement is in a popover), this will only scroll the scroll parents of the targetElement up to but not including the body itself.
|
|
83
83
|
*/
|
|
84
|
-
export function scrollIntoViewport(targetElement: Element, opts?: ScrollIntoViewportOpts) {
|
|
85
|
-
if (document.contains(targetElement)) {
|
|
84
|
+
export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts) {
|
|
85
|
+
if (targetElement && document.contains(targetElement)) {
|
|
86
86
|
let root = document.scrollingElement || document.documentElement;
|
|
87
87
|
let isScrollPrevented = window.getComputedStyle(root).overflow === 'hidden';
|
|
88
88
|
// If scrolling is not currently prevented then we aren’t in a overlay nor is a overlay open, just use element.scrollIntoView to bring the element into view
|
package/src/useFormReset.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {useEffect, useRef} from 'react';
|
|
|
15
15
|
import {useEffectEvent} from './useEffectEvent';
|
|
16
16
|
|
|
17
17
|
export function useFormReset<T>(
|
|
18
|
-
ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null
|
|
18
|
+
ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined,
|
|
19
19
|
initialValue: T,
|
|
20
20
|
onReset: (value: T) => void
|
|
21
21
|
) {
|
package/src/useId.ts
CHANGED
|
@@ -22,7 +22,7 @@ let canUseDOM = Boolean(
|
|
|
22
22
|
window.document.createElement
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
let idsUpdaterMap: Map<string, (v: string) => void
|
|
25
|
+
let idsUpdaterMap: Map<string, Array<(v: string) => void>> = new Map();
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* If a default is not provided, generate an id.
|
|
@@ -39,7 +39,12 @@ export function useId(defaultId?: string): string {
|
|
|
39
39
|
}, []);
|
|
40
40
|
|
|
41
41
|
if (canUseDOM) {
|
|
42
|
-
|
|
42
|
+
// TS not smart enough to know that `has` means the value exists
|
|
43
|
+
if (idsUpdaterMap.has(res) && !idsUpdaterMap.get(res)!.includes(updateValue)) {
|
|
44
|
+
idsUpdaterMap.set(res, [...idsUpdaterMap.get(res)!, updateValue]);
|
|
45
|
+
} else {
|
|
46
|
+
idsUpdaterMap.set(res, [updateValue]);
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
useLayoutEffect(() => {
|
|
@@ -71,15 +76,15 @@ export function mergeIds(idA: string, idB: string): string {
|
|
|
71
76
|
return idA;
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
let
|
|
75
|
-
if (
|
|
76
|
-
|
|
79
|
+
let setIdsA = idsUpdaterMap.get(idA);
|
|
80
|
+
if (setIdsA) {
|
|
81
|
+
setIdsA.forEach(fn => fn(idB));
|
|
77
82
|
return idB;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
let
|
|
81
|
-
if (
|
|
82
|
-
|
|
85
|
+
let setIdsB = idsUpdaterMap.get(idB);
|
|
86
|
+
if (setIdsB) {
|
|
87
|
+
setIdsB.forEach(fn => fn(idA));
|
|
83
88
|
return idA;
|
|
84
89
|
}
|
|
85
90
|
|
package/src/useLoadMore.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {RefObject, useCallback, useRef} from 'react';
|
|
14
14
|
import {useEvent} from './useEvent';
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
import {useLayoutEffect} from './useLayoutEffect';
|
|
17
17
|
|
|
18
18
|
export interface LoadMoreProps {
|
|
@@ -29,7 +29,7 @@ export interface LoadMoreProps {
|
|
|
29
29
|
*/
|
|
30
30
|
scrollOffset?: number,
|
|
31
31
|
/** The data currently loaded. */
|
|
32
|
-
items?: any
|
|
32
|
+
items?: any
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>) {
|
|
@@ -73,7 +73,7 @@ export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | n
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
lastItems.current = items;
|
|
76
|
-
}, [isLoading, onLoadMore, props, ref]);
|
|
76
|
+
}, [isLoading, onLoadMore, props, ref, items]);
|
|
77
77
|
|
|
78
78
|
// TODO: maybe this should still just return scroll props?
|
|
79
79
|
// Test against case where the ref isn't defined when this is called
|