-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(focusvisible): migrate focusvisible to TypeScript (#137)
- Loading branch information
Showing
12 changed files
with
143 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@types/react-native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright Zendesk, Inc. | ||
* | ||
* Use of this source code is governed under the Apache License, Version 2.0 | ||
* found at http://www.apache.org/licenses/LICENSE-2.0. | ||
*/ | ||
|
||
import { useRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { useFocusVisible, IUseFocusVisibleProps } from './useFocusVisible'; | ||
|
||
export interface IFocusVisibleContainerProps extends Omit<IUseFocusVisibleProps, 'scope'> { | ||
render?: (options: { ref: React.RefObject<HTMLDivElement> }) => React.ReactNode; | ||
children?: (options: { ref: React.RefObject<HTMLDivElement> }) => React.ReactNode; | ||
} | ||
|
||
export const FocusVisibleContainer: React.FunctionComponent<IFocusVisibleContainerProps> = ({ | ||
children, | ||
render = children, | ||
...options | ||
}) => { | ||
const scopeRef = useRef(null); | ||
|
||
useFocusVisible({ scope: scopeRef, ...options }); | ||
|
||
return render!({ ref: scopeRef }) as React.ReactElement; | ||
}; | ||
|
||
FocusVisibleContainer.propTypes = { | ||
children: PropTypes.func, | ||
render: PropTypes.func, | ||
relativeDocument: PropTypes.object, | ||
className: PropTypes.string, | ||
dataAttribute: PropTypes.string | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.