Skip to content

Commit

Permalink
[TreeView] Add JSDoc to all publicAPI methods (mui#12649)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle authored and DungTiger committed Jul 23, 2024
1 parent 8fb4b96 commit 78f84ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@ import type { UseTreeViewItemsSignature } from '../useTreeViewItems';
import type { UseTreeViewSelectionSignature } from '../useTreeViewSelection';
import { UseTreeViewExpansionSignature } from '../useTreeViewExpansion';

export interface UseTreeViewFocusInstance {
export interface UseTreeViewFocusPublicAPI {
/**
* Focuses the item with the given id.
*
* If the item is the child of a collapsed item, then this method will do nothing.
* Make sure to expand the ancestors of the item before calling this method if needed.
* @param {React.SyntheticEvent} event The event source of the action.
* @param {string} itemId The id of the item to focus.
*/
focusItem: (event: React.SyntheticEvent, itemId: string) => void;
}

export interface UseTreeViewFocusInstance extends UseTreeViewFocusPublicAPI {
isItemFocused: (itemId: string) => boolean;
canItemBeTabbed: (itemId: string) => boolean;
focusItem: (event: React.SyntheticEvent, itemId: string) => void;
focusDefaultItem: (event: React.SyntheticEvent | null) => void;
removeFocusedItem: () => void;
}

export interface UseTreeViewFocusPublicAPI extends Pick<UseTreeViewFocusInstance, 'focusItem'> {}

export interface UseTreeViewFocusParameters {
/**
* Callback fired when tree items are focused.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ interface TreeViewItemProps {
children?: TreeViewItemProps[];
}

export interface UseTreeViewItemsInstance<R extends {}> {
getNode: (itemId: string) => TreeViewNode;
export interface UseTreeViewItemsPublicAPI<R extends {}> {
/**
* Get the item with the given id.
* @param {string} itemId The id of the item to return.
* @returns {R} The item with the given id.
*/
getItem: (itemId: string) => R;
}

export interface UseTreeViewItemsInstance<R extends {}> extends UseTreeViewItemsPublicAPI<R> {
getNode: (itemId: string) => TreeViewNode;
getItemsToRender: () => TreeViewItemProps[];
getChildrenIds: (itemId: string | null) => string[];
getNavigableChildrenIds: (itemId: string | null) => string[];
Expand All @@ -28,9 +36,6 @@ export interface UseTreeViewItemsInstance<R extends {}> {
areItemUpdatesPrevented: () => boolean;
}

export interface UseTreeViewItemsPublicAPI<R extends {}>
extends Pick<UseTreeViewItemsInstance<R>, 'getItem'> {}

export interface UseTreeViewItemsParameters<R extends {}> {
/**
* If `true`, will allow focus on disabled items.
Expand Down

0 comments on commit 78f84ea

Please sign in to comment.