-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: activedescendant works with vanilla JS
- Loading branch information
Showing
28 changed files
with
358 additions
and
290 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/react-components/react-aria/src/activedescendant/ActiveDescendantContext.ts
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,27 @@ | ||
import * as React from 'react'; | ||
import { ActiveDescendantImperativeRef } from './types'; | ||
|
||
export type ActiveDescendantContextValue = { | ||
controller: ActiveDescendantImperativeRef; | ||
}; | ||
|
||
const noop = () => undefined; | ||
|
||
const activeDescendantContextDefaultValue: ActiveDescendantContextValue = { | ||
controller: { | ||
active: noop, | ||
blur: noop, | ||
find: noop, | ||
first: noop, | ||
focus: noop, | ||
last: noop, | ||
next: noop, | ||
prev: noop, | ||
}, | ||
}; | ||
|
||
const ActiveDescendantContext = React.createContext<ActiveDescendantContextValue | undefined>(undefined); | ||
|
||
export const ActiveDescendantContextProvider = ActiveDescendantContext.Provider; | ||
export const useActiveDescendantContext = () => | ||
React.useContext(ActiveDescendantContext) ?? activeDescendantContextDefaultValue; |
1 change: 1 addition & 0 deletions
1
packages/react-components/react-aria/src/activedescendant/index.ts
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './ActiveDescendantContext'; | ||
export * from './useActiveDescendant'; | ||
export * from './constants'; | ||
export * from './types'; |
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
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
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.