@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
42 lines • 2.51 kB
TypeScript
import * as React from 'react';
import type { UseTreeViewLazyLoadingSignature } from "../../internals/plugins/useTreeViewLazyLoading/index.js";
import type { UseTreeViewSelectionSignature } from "../../internals/plugins/useTreeViewSelection/index.js";
import type { UseTreeViewExpansionSignature } from "../../internals/plugins/useTreeViewExpansion/index.js";
import type { UseTreeViewItemsSignature } from "../../internals/plugins/useTreeViewItems/index.js";
import type { UseTreeViewFocusSignature } from "../../internals/plugins/useTreeViewFocus/index.js";
import { UseTreeViewLabelSignature } from "../../internals/plugins/useTreeViewLabel/index.js";
import type { UseTreeItemStatus } from "../../useTreeItem/index.js";
import { TreeViewPublicAPI } from "../../internals/models/index.js";
export interface UseTreeItemInteractions {
handleExpansion: (event: React.MouseEvent) => void;
handleSelection: (event: React.MouseEvent) => void;
handleCheckboxSelection: (event: React.ChangeEvent<HTMLInputElement>) => void;
toggleItemEditing: () => void;
handleSaveItemLabel: (event: React.SyntheticEvent, label: string) => void;
handleCancelItemLabelEditing: (event: React.SyntheticEvent) => void;
}
/**
* Plugins that need to be present in the Tree View in order for `useTreeItemUtils` to work correctly.
*/
type UseTreeItemUtilsMinimalPlugins = readonly [UseTreeViewSelectionSignature, UseTreeViewExpansionSignature, UseTreeViewItemsSignature, UseTreeViewFocusSignature];
/**
* Plugins that `useTreeItemUtils` can use if they are present, but are not required.
*/
export type UseTreeItemUtilsOptionalPlugins = readonly [UseTreeViewLabelSignature, UseTreeViewLazyLoadingSignature];
interface UseTreeItemUtilsReturnValue<TSignatures extends UseTreeItemUtilsMinimalPlugins, TOptionalSignatures extends UseTreeItemUtilsOptionalPlugins> {
interactions: UseTreeItemInteractions;
status: UseTreeItemStatus;
/**
* The object the allows Tree View manipulation.
*/
publicAPI: TreeViewPublicAPI<TSignatures, TOptionalSignatures>;
}
export declare const itemHasChildren: (reactChildren: React.ReactNode) => boolean;
export declare const useTreeItemUtils: <TSignatures extends UseTreeItemUtilsMinimalPlugins = UseTreeItemUtilsMinimalPlugins, TOptionalSignatures extends UseTreeItemUtilsOptionalPlugins = UseTreeItemUtilsOptionalPlugins>({
itemId,
children
}: {
itemId: string;
children?: React.ReactNode;
}) => UseTreeItemUtilsReturnValue<TSignatures, TOptionalSignatures>;
export {};