UNPKG

@mui/x-tree-view

Version:

The community edition of the MUI X Tree View components.

45 lines 2.12 kB
import * as React from 'react'; import { TreeViewPluginSignature } from "../../models/index.js"; import type { UseTreeViewItemsSignature } from "../useTreeViewItems/index.js"; import type { UseTreeViewSelectionSignature } from "../useTreeViewSelection/index.js"; import { UseTreeViewExpansionSignature } from "../useTreeViewExpansion/index.js"; import { TreeViewItemId } from "../../../models/index.js"; export interface UseTreeViewFocusPublicAPI { /** * Focus 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 | null} event The DOM event that triggered the change. * @param {TreeViewItemId} itemId The id of the item to focus. */ focusItem: (event: React.SyntheticEvent | null, itemId: TreeViewItemId) => void; } export interface UseTreeViewFocusInstance extends UseTreeViewFocusPublicAPI { /** * Remove the focus from the currently focused item (both from the internal state and the DOM). */ removeFocusedItem: () => void; } export interface UseTreeViewFocusParameters { /** * Callback fired when a given Tree Item is focused. * @param {React.SyntheticEvent | null} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event. * @param {TreeViewItemId} itemId The id of the focused item. */ onItemFocus?: (event: React.SyntheticEvent | null, itemId: TreeViewItemId) => void; } export type UseTreeViewFocusParametersWithDefaults = UseTreeViewFocusParameters; export interface UseTreeViewFocusState { focus: { focusedItemId: TreeViewItemId | null; }; } export type UseTreeViewFocusSignature = TreeViewPluginSignature<{ params: UseTreeViewFocusParameters; paramsWithDefaults: UseTreeViewFocusParametersWithDefaults; instance: UseTreeViewFocusInstance; publicAPI: UseTreeViewFocusPublicAPI; state: UseTreeViewFocusState; dependencies: [UseTreeViewItemsSignature, UseTreeViewSelectionSignature, UseTreeViewExpansionSignature]; }>;