-
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(react-tree): creates SubtreeContext to avoid spreading root cont…
…ext (#29194) * feat: creates SubtreeContext * chore: review comments
- Loading branch information
1 parent
bfa0ec8
commit b7c4075
Showing
22 changed files
with
252 additions
and
91 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-components-79050853-fe98-49ee-994b-b9dca0dd661a.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": "minor", | ||
"comment": "feat: export SubtreeContext from @fluentui/react-tree", | ||
"packageName": "@fluentui/react-components", | ||
"email": "bernardo.sunderhus@gmail.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-tree-ee908991-9ab8-4d9c-b7a5-5d0c06648855.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": "minor", | ||
"comment": "feat: creates SubtreeContext", | ||
"packageName": "@fluentui/react-tree", | ||
"email": "bernardo.sunderhus@gmail.com", | ||
"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
6 changes: 3 additions & 3 deletions
6
packages/react-components/react-tree/src/components/FlatTree/renderFlatTree.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,5 +1,5 @@ | ||
import { TreeContextValues, renderTree_unstable } from '../../Tree'; | ||
import type { FlatTreeState } from './FlatTree.types'; | ||
import { renderTree_unstable } from '../../Tree'; | ||
import type { FlatTreeContextValues, FlatTreeState } from './FlatTree.types'; | ||
|
||
export const renderFlatTree_unstable: (state: FlatTreeState, contextValues: TreeContextValues) => JSX.Element = | ||
export const renderFlatTree_unstable: (state: FlatTreeState, contextValues: FlatTreeContextValues) => JSX.Element = | ||
renderTree_unstable; |
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
36 changes: 32 additions & 4 deletions
36
packages/react-components/react-tree/src/components/FlatTree/useFlatTreeContextValues.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,5 +1,33 @@ | ||
import { TreeContextValues, useTreeContextValues_unstable } from '../../Tree'; | ||
import type { FlatTreeState } from './FlatTree.types'; | ||
import type { TreeContextValue } from '../../contexts'; | ||
import type { FlatTreeContextValues, FlatTreeState } from './FlatTree.types'; | ||
|
||
export const useFlatTreeContextValues_unstable: (state: FlatTreeState) => TreeContextValues = | ||
useTreeContextValues_unstable; | ||
export const useFlatTreeContextValues_unstable = (state: FlatTreeState): FlatTreeContextValues => { | ||
const { | ||
openItems, | ||
level, | ||
contextType, | ||
treeType, | ||
checkedItems, | ||
selectionMode, | ||
appearance, | ||
size, | ||
requestTreeResponse, | ||
} = state; | ||
/** | ||
* This context is created with "@fluentui/react-context-selector", | ||
* there is no sense to memoize it | ||
*/ | ||
const tree: TreeContextValue = { | ||
treeType, | ||
size, | ||
openItems, | ||
appearance, | ||
checkedItems, | ||
selectionMode, | ||
contextType, | ||
level, | ||
requestTreeResponse, | ||
}; | ||
|
||
return { tree }; | ||
}; |
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
2 changes: 1 addition & 1 deletion
2
packages/react-components/react-tree/src/components/Tree/renderTree.tsx
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.