@react-aria/utils 3.29.1 → 3.30.1
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/filterDOMProps.main.js +45 -2
- package/dist/filterDOMProps.main.js.map +1 -1
- package/dist/filterDOMProps.mjs +45 -2
- package/dist/filterDOMProps.module.js +45 -2
- package/dist/filterDOMProps.module.js.map +1 -1
- package/dist/import.mjs +3 -3
- package/dist/isElementVisible.main.js +43 -0
- package/dist/isElementVisible.main.js.map +1 -0
- package/dist/isElementVisible.mjs +38 -0
- package/dist/isElementVisible.module.js +38 -0
- package/dist/isElementVisible.module.js.map +1 -0
- package/dist/isFocusable.main.js +25 -3
- package/dist/isFocusable.main.js.map +1 -1
- package/dist/isFocusable.mjs +25 -3
- package/dist/isFocusable.module.js +25 -3
- package/dist/isFocusable.module.js.map +1 -1
- package/dist/isVirtualEvent.main.js +1 -1
- package/dist/isVirtualEvent.main.js.map +1 -1
- package/dist/isVirtualEvent.mjs +1 -1
- package/dist/isVirtualEvent.module.js +1 -1
- package/dist/isVirtualEvent.module.js.map +1 -1
- package/dist/main.js +3 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -3
- package/dist/module.js.map +1 -1
- package/dist/openLink.main.js +9 -0
- package/dist/openLink.main.js.map +1 -1
- package/dist/openLink.mjs +9 -1
- package/dist/openLink.module.js +9 -1
- package/dist/openLink.module.js.map +1 -1
- package/dist/platform.main.js +2 -1
- package/dist/platform.main.js.map +1 -1
- package/dist/platform.mjs +2 -1
- package/dist/platform.module.js +2 -1
- package/dist/platform.module.js.map +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/useEffectEvent.main.js +9 -1
- package/dist/useEffectEvent.main.js.map +1 -1
- package/dist/useEffectEvent.mjs +6 -2
- package/dist/useEffectEvent.module.js +6 -2
- package/dist/useEffectEvent.module.js.map +1 -1
- package/dist/useFormReset.main.js +1 -2
- package/dist/useFormReset.main.js.map +1 -1
- package/dist/useFormReset.mjs +2 -3
- package/dist/useFormReset.module.js +2 -3
- package/dist/useFormReset.module.js.map +1 -1
- package/dist/useLayoutEffect.main.js.map +1 -1
- package/dist/useLayoutEffect.module.js.map +1 -1
- package/dist/useLoadMoreSentinel.main.js +2 -2
- package/dist/useLoadMoreSentinel.main.js.map +1 -1
- package/dist/useLoadMoreSentinel.mjs +2 -2
- package/dist/useLoadMoreSentinel.module.js +2 -2
- package/dist/useLoadMoreSentinel.module.js.map +1 -1
- package/package.json +5 -5
- package/src/filterDOMProps.ts +54 -3
- package/src/index.ts +2 -2
- package/src/isElementVisible.ts +75 -0
- package/src/isFocusable.ts +31 -3
- package/src/isVirtualEvent.ts +1 -1
- package/src/openLink.tsx +17 -1
- package/src/platform.ts +13 -14
- package/src/useEffectEvent.ts +6 -2
- package/src/useFormReset.ts +3 -3
- package/src/useLayoutEffect.ts +1 -1
- package/src/useLoadMoreSentinel.ts +1 -1
package/src/useEffectEvent.ts
CHANGED
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {useCallback, useRef} from 'react';
|
|
13
|
+
import React, {useCallback, useRef} from 'react';
|
|
14
14
|
import {useLayoutEffect} from './useLayoutEffect';
|
|
15
15
|
|
|
16
|
+
// Use the earliest effect type possible. useInsertionEffect runs during the mutation phase,
|
|
17
|
+
// before all layout effects, but is available only in React 18 and later.
|
|
18
|
+
const useEarlyEffect = React['useInsertionEffect'] ?? useLayoutEffect;
|
|
19
|
+
|
|
16
20
|
export function useEffectEvent<T extends Function>(fn?: T): T {
|
|
17
21
|
const ref = useRef<T | null | undefined>(null);
|
|
18
|
-
|
|
22
|
+
useEarlyEffect(() => {
|
|
19
23
|
ref.current = fn;
|
|
20
24
|
}, [fn]);
|
|
21
25
|
// @ts-ignore
|
package/src/useFormReset.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {RefObject} from '@react-types/shared';
|
|
14
|
-
import {useEffect
|
|
14
|
+
import {useEffect} from 'react';
|
|
15
15
|
import {useEffectEvent} from './useEffectEvent';
|
|
16
16
|
|
|
17
17
|
export function useFormReset<T>(
|
|
@@ -19,15 +19,15 @@ export function useFormReset<T>(
|
|
|
19
19
|
initialValue: T,
|
|
20
20
|
onReset: (value: T) => void
|
|
21
21
|
): void {
|
|
22
|
-
let resetValue = useRef(initialValue);
|
|
23
22
|
let handleReset = useEffectEvent(() => {
|
|
24
23
|
if (onReset) {
|
|
25
|
-
onReset(
|
|
24
|
+
onReset(initialValue);
|
|
26
25
|
}
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
useEffect(() => {
|
|
30
29
|
let form = ref?.current?.form;
|
|
30
|
+
|
|
31
31
|
form?.addEventListener('reset', handleReset);
|
|
32
32
|
return () => {
|
|
33
33
|
form?.removeEventListener('reset', handleReset);
|
package/src/useLayoutEffect.ts
CHANGED
|
@@ -15,6 +15,6 @@ import React from 'react';
|
|
|
15
15
|
// During SSR, React emits a warning when calling useLayoutEffect.
|
|
16
16
|
// Since neither useLayoutEffect nor useEffect run on the server,
|
|
17
17
|
// we can suppress this by replace it with a noop on the server.
|
|
18
|
-
export const useLayoutEffect = typeof document !== 'undefined'
|
|
18
|
+
export const useLayoutEffect: typeof React.useLayoutEffect = typeof document !== 'undefined'
|
|
19
19
|
? React.useLayoutEffect
|
|
20
20
|
: () => {};
|
|
@@ -28,7 +28,7 @@ export interface LoadMoreSentinelProps extends Omit<AsyncLoadable, 'isLoading'>
|
|
|
28
28
|
scrollOffset?: number
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function
|
|
31
|
+
export function useLoadMoreSentinel(props: LoadMoreSentinelProps, ref: RefObject<HTMLElement | null>): void {
|
|
32
32
|
let {collection, onLoadMore, scrollOffset = 1} = props;
|
|
33
33
|
|
|
34
34
|
let sentinelObserver = useRef<IntersectionObserver>(null);
|