-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TreeView] New instance and publicAPI method: getItem
#12251
Conversation
getItem
nodeTree: TreeViewNodeIdAndChildren[]; | ||
nodeMap: TreeViewNodeMap; | ||
export interface UseTreeViewNodesState<R extends {}> { | ||
nodes: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I scoped the node state because having 3 elements at the root was starting to be messy
Deploy preview: https://deploy-preview-12251--material-ui-x.netlify.app/ |
T extends TreeViewAnyPluginSignature, | ||
Api extends TreeViewUsedPublicAPI<T>, | ||
>() => React.useRef(undefined) as React.MutableRefObject<Api>; | ||
TPlugins extends readonly TreeViewAnyPluginSignature[] = DefaultTreeViewPlugins, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing was weird, it was only taking a single plugin
Now by default the type is the one of the default plugins (which are used by both the rich and the simple tree view)
but you can pass a generic to support more plugins (not useful for now, will become useful with RichTreeView-only plugins if they end up having public methods)
focusNode: (event: React.SyntheticEvent, nodeId: string | null) => void; | ||
} | ||
|
||
export interface UseTreeViewFocusPublicAPI extends Pick<UseTreeViewFocusInstance, 'focusNode'> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensure the public API is always a subset of the private one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉 Thanks for doing this 💯
Closes #10957
Not sure why but I can't use the PR package on Codesandbox 🤔
Here is a basic usage of the method if you want to test it: