UNPKG

@mui/x-tree-view

Version:

The community edition of the MUI X Tree View components.

105 lines 4.29 kB
import { TreeViewItemId, TreeViewValidItem } from "../../../models/index.js"; import { MinimalTreeViewParameters } from "../../MinimalTreeViewStore/MinimalTreeViewStore.types.js"; export declare class TreeViewItemsPlugin<R extends TreeViewValidItem<R>> { private store; constructor(store: any); /** * Determines if the items state should be rebuilt based on the new and previous parameters. */ static shouldRebuildItemsState: <R2 extends TreeViewValidItem<R2>>(newParameters: MinimalTreeViewParameters<R2, any>, previousParameters: MinimalTreeViewParameters<R2, any>) => boolean; /** * Builds the state properties derived from the `items` prop. */ static buildItemsStateIfNeeded: <R2 extends TreeViewValidItem<R2>>(parameters: Pick<MinimalTreeViewParameters<R2, any>, "items" | "isItemDisabled" | "isItemSelectionDisabled" | "getItemId" | "getItemLabel" | "getItemChildren">) => { itemMetaLookup: { [itemId: string]: import("../../index.js").TreeViewItemMeta; }; itemModelLookup: { [itemId: string]: R2; }; itemOrderedChildrenIdsLookup: { [parentItemId: string]: string[]; }; itemChildrenIndexesLookup: { [parentItemId: string]: { [itemId: string]: number; }; }; }; /** * Get the item with the given id. * When used in the Simple Tree View, it returns an object with the `id` and `label` properties. * @param {TreeViewItemId} itemId The id of the item to retrieve. * @returns {R} The item with the given id. */ private getItem; /** * Get all the items in the same format as provided by `props.items`. * @returns {R[]} The items in the tree. */ private getItemTree; /** * Get the ids of a given item's children. * Those ids are returned in the order they should be rendered. * To get the root items, pass `null` as the `itemId`. * @param {TreeViewItemId | null} itemId The id of the item to get the children of. * @returns {TreeViewItemId[]} The ids of the item's children. */ private getItemOrderedChildrenIds; /** * Get the id of the parent item. * @param {TreeViewItemId} itemId The id of the item to whose parentId we want to retrieve. * @returns {TreeViewItemId | null} The id of the parent item. */ private getParentId; /** * Toggle the disabled state of the item with the given id. * @param {object} parameters The params of the method. * @param {TreeViewItemId } parameters.itemId The id of the item to get the children of. * @param {boolean } parameters.shouldBeDisabled true if the item should be disabled. */ private setIsItemDisabled; buildPublicAPI: () => { getItem: (itemId: TreeViewItemId) => R; getItemDOMElement: (itemId: TreeViewItemId) => HTMLElement | null; getItemOrderedChildrenIds: (itemId: TreeViewItemId | null) => TreeViewItemId[]; getItemTree: () => R[]; getParentId: (itemId: TreeViewItemId) => TreeViewItemId | null; setIsItemDisabled: ({ itemId, shouldBeDisabled }: { itemId: TreeViewItemId; shouldBeDisabled?: boolean; }) => void; }; /** * Get the DOM element of the item with the given id. * @param {TreeViewItemId} itemId The id of the item to get the DOM element of. * @returns {HTMLElement | null} The DOM element of the item with the given id. */ getItemDOMElement: (itemId: TreeViewItemId) => HTMLElement | null; /** * Add an array of items to the tree. * @param {SetItemChildrenParameters<R>} args The items to add to the tree and information about their ancestors. */ setItemChildren: ({ items, parentId, getChildrenCount }: { items: readonly R[]; parentId: TreeViewItemId | null; getChildrenCount: (item: R) => number; }) => void; /** * Remove the children of an item. * @param {TreeViewItemId | null} parentId The id of the item to remove the children of. */ removeChildren: (parentId: TreeViewItemId | null) => void; /** * Callback fired when the `content` slot of a given Tree Item is clicked. * @param {React.MouseEvent} event The DOM event that triggered the change. * @param {TreeViewItemId} itemId The id of the item being clicked. */ handleItemClick: (event: React.MouseEvent, itemId: TreeViewItemId) => void; }