@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
71 lines • 2.53 kB
TypeScript
import type { TreeViewValidItem, TreeViewItemId } from "../../../models/index.js";
import type { TreeViewItemMeta } from "../../models/index.js";
import type { MinimalTreeViewParameters } from "../../MinimalTreeViewStore/index.js";
export declare const TREE_VIEW_ROOT_PARENT_ID = "__TREE_VIEW_ROOT_PARENT_ID__";
export declare const buildSiblingIndexes: (siblings: string[]) => {
[itemId: string]: number;
};
/**
* Check if an item is disabled.
* This method should only be used in selectors that are checking if several items are disabled.
* Otherwise, use the `itemsSelector.isItemDisabled` selector.
* @returns
*/
export declare const isItemDisabled: (itemMetaLookup: {
[itemId: string]: TreeViewItemMeta;
}, itemId: TreeViewItemId) => boolean;
export declare function buildItemsLookups<R extends TreeViewValidItem<R>>(parameters: BuildItemsLookupsParameters<R>): {
metaLookup: {
[itemId: string]: TreeViewItemMeta;
};
modelLookup: {
[itemId: string]: R;
};
orderedChildrenIds: string[];
childrenIndexes: {
[itemId: string]: number;
};
itemsChildren: {
id: string | null;
children: R[];
}[];
};
/**
* Builds the items lookups for a tree of items, recursing into the children of each item.
* The returned lookups only contain the items passed to this method.
*/
export declare function buildItemsLookupsRecursively<R extends TreeViewValidItem<R>>(parameters: BuildItemsLookupsRecursivelyParameters<R>): {
itemMetaLookup: {
[itemId: string]: TreeViewItemMeta;
};
itemModelLookup: {
[itemId: string]: R;
};
itemOrderedChildrenIdsLookup: {
[parentItemId: string]: string[];
};
itemChildrenIndexesLookup: {
[parentItemId: string]: {
[itemId: string]: number;
};
};
};
interface BuildItemsLookupsRecursivelyParameters<R extends TreeViewValidItem<R>> extends Omit<BuildItemsLookupsParameters<R>, 'otherItemsMetaLookup'> {
/**
* The meta of the items already present in the tree, used to detect duplicated ids.
*/
existingItemMetaLookup?: {
[itemId: string]: TreeViewItemMeta;
};
}
interface BuildItemsLookupsParameters<R extends TreeViewValidItem<R>> {
items: readonly R[];
storeParameters: Pick<MinimalTreeViewParameters<R, any>, 'getItemId' | 'getItemLabel' | 'getItemChildren' | 'isItemDisabled' | 'isItemSelectionDisabled'>;
parentId: string | null;
depth: number;
isItemExpandable: (item: R, children: R[] | undefined) => boolean;
otherItemsMetaLookup: {
[itemId: string]: TreeViewItemMeta;
};
}
export {};