@react-aria/focus 3.14.2 → 3.15.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 +102 -71
- package/dist/main.js +103 -70
- package/dist/main.js.map +1 -1
- package/dist/module.js +102 -71
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/FocusScope.tsx +156 -113
- package/src/isElementVisible.ts +3 -3
- package/src/useFocusable.tsx +6 -5
package/src/useFocusable.tsx
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import {DOMAttributes, FocusableDOMProps, FocusableElement, FocusableProps} from '@react-types/shared';
|
|
14
14
|
import {focusSafely} from './';
|
|
15
|
-
import {mergeProps, useSyncRef} from '@react-aria/utils';
|
|
16
|
-
import React, {MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';
|
|
15
|
+
import {mergeProps, useObjectRef, useSyncRef} from '@react-aria/utils';
|
|
16
|
+
import React, {ForwardedRef, MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';
|
|
17
17
|
import {useFocus, useKeyboard} from '@react-aria/interactions';
|
|
18
18
|
|
|
19
19
|
export interface FocusableOptions extends FocusableProps, FocusableDOMProps {
|
|
@@ -30,7 +30,7 @@ interface FocusableContextValue extends FocusableProviderProps {
|
|
|
30
30
|
ref?: MutableRefObject<FocusableElement>
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
let FocusableContext = React.createContext<FocusableContextValue>(null);
|
|
33
|
+
let FocusableContext = React.createContext<FocusableContextValue | null>(null);
|
|
34
34
|
|
|
35
35
|
function useFocusableContext(ref: RefObject<FocusableElement>): FocusableContextValue {
|
|
36
36
|
let context = useContext(FocusableContext) || {};
|
|
@@ -44,11 +44,12 @@ function useFocusableContext(ref: RefObject<FocusableElement>): FocusableContext
|
|
|
44
44
|
/**
|
|
45
45
|
* Provides DOM props to the nearest focusable child.
|
|
46
46
|
*/
|
|
47
|
-
function FocusableProvider(props: FocusableProviderProps, ref:
|
|
47
|
+
function FocusableProvider(props: FocusableProviderProps, ref: ForwardedRef<FocusableElement>) {
|
|
48
48
|
let {children, ...otherProps} = props;
|
|
49
|
+
let objRef = useObjectRef(ref);
|
|
49
50
|
let context = {
|
|
50
51
|
...otherProps,
|
|
51
|
-
ref
|
|
52
|
+
ref: objRef
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
return (
|