forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
react-card - Phase 2 (microsoft#20132)
* Add useGroupper * Change files * Update API * Rename hook * Update API * Rename enum * Change options prop * react-card - Migrate Card to new prop merging / root as a slot (microsoft#20111) * Add focus keyboard interactions * Update stories to have context menus * Change files * Remove context examples because Typescript hates me * Update snapshots * Use new hook name * Formatting * revert(react-card): remove tabster behavior from card footer * fix: update snapshots Co-authored-by: varholak-peter <[email protected]>
- Loading branch information
1 parent
ede5f86
commit cbab338
Showing
9 changed files
with
168 additions
and
73 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-card-b42d28bf-e2ec-4352-8b18-5052df2d5aa2.json
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,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add keyboard focus interactions", | ||
"packageName": "@fluentui/react-card", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-tabster-29b2dc96-c72a-490d-af5c-fa0e1e956863.json
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,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add useFocusableGroup hook", | ||
"packageName": "@fluentui/react-tabster", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Types, getGroupper } from 'tabster'; | ||
import { useTabsterAttributes } from './useTabsterAttributes'; | ||
import { useTabster } from './useTabster'; | ||
|
||
export enum FocusableGroupTabBehavior { | ||
/** | ||
* Tab will cycle into and out of the groupper content. | ||
*/ | ||
Unlimited = Types.GroupperTabbabilities.Unlimited, | ||
/** | ||
* Tab will cycle out of the container, but not into it. | ||
*/ | ||
Limited = Types.GroupperTabbabilities.Limited, | ||
/** | ||
* Tab only cycles the inner elements. | ||
*/ | ||
LimitedTrapFocus = Types.GroupperTabbabilities.LimitedTrapFocus, | ||
} | ||
|
||
export interface UseFocusableGroupOptions { | ||
/** | ||
* Type of TAB key interaction. | ||
*/ | ||
tabBehavior?: FocusableGroupTabBehavior; | ||
} | ||
|
||
/** | ||
* A hook that returns the necessary tabster attributes to support groupping. | ||
* @param options - Options to configure keyboard navigation | ||
*/ | ||
export const useFocusableGroup = (options?: UseFocusableGroupOptions) => { | ||
const tabster = useTabster(); | ||
|
||
if (tabster) { | ||
getGroupper(tabster); | ||
} | ||
|
||
return useTabsterAttributes({ | ||
groupper: { | ||
tabbability: options?.tabBehavior as Types.GroupperTabbability, | ||
}, | ||
}); | ||
}; |