-
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.
[TreeView] Allow the plugins to enrich the props passed to the item s…
…lots (mui#13953)
- Loading branch information
1 parent
fe100c7
commit f03f787
Showing
7 changed files
with
101 additions
and
19 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './helpers'; | ||
export * from './plugin'; | ||
export * from './itemPlugin'; | ||
export * from './treeView'; |
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,49 @@ | ||
import * as React from 'react'; | ||
import { EventHandlers } from '@mui/base/utils'; | ||
import type { | ||
UseTreeItem2ContentSlotOwnProps, | ||
UseTreeItem2RootSlotOwnProps, | ||
} from '../../useTreeItem2'; | ||
|
||
export interface TreeViewItemPluginSlotPropsEnhancerParams { | ||
rootRefObject: React.MutableRefObject<HTMLLIElement | null>; | ||
contentRefObject: React.MutableRefObject<HTMLDivElement | null>; | ||
externalEventHandlers: EventHandlers; | ||
} | ||
|
||
type TreeViewItemPluginSlotPropsEnhancer<TSlotProps> = ( | ||
params: TreeViewItemPluginSlotPropsEnhancerParams, | ||
) => Partial<TSlotProps>; | ||
|
||
export interface TreeViewItemPluginSlotPropsEnhancers { | ||
root?: TreeViewItemPluginSlotPropsEnhancer<UseTreeItem2RootSlotOwnProps>; | ||
content?: TreeViewItemPluginSlotPropsEnhancer<UseTreeItem2ContentSlotOwnProps>; | ||
} | ||
|
||
export interface TreeViewItemPluginResponse { | ||
/** | ||
* Root of the `content` slot enriched by the plugin. | ||
*/ | ||
contentRef?: React.RefCallback<HTMLElement> | null; | ||
/** | ||
* Ref of the `root` slot enriched by the plugin | ||
*/ | ||
rootRef?: React.RefCallback<HTMLLIElement> | null; | ||
/** | ||
* Callback to enhance the slot props of the Tree Item. | ||
* | ||
* Not all slots are enabled by default, | ||
* if a new plugin needs to pass to an unconfigured slot, | ||
* it just needs to be added to `TreeViewItemPluginSlotPropsEnhancers` | ||
*/ | ||
propsEnhancers?: TreeViewItemPluginSlotPropsEnhancers; | ||
} | ||
|
||
export interface TreeViewItemPluginOptions<TProps extends {}> | ||
extends Omit<TreeViewItemPluginResponse, 'propsEnhancers'> { | ||
props: TProps; | ||
} | ||
|
||
export type TreeViewItemPlugin<TProps extends {}> = ( | ||
options: TreeViewItemPluginOptions<TProps>, | ||
) => void | TreeViewItemPluginResponse; |
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