@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
88 lines • 4.25 kB
TypeScript
import type { TreeViewItemId, TreeViewItemSelectionStatus } from "../../../models/index.js";
export declare class TreeViewSelectionPlugin<Multiple extends boolean | undefined> {
private store;
private lastSelectedItem;
private lastSelectedRange;
constructor(store: any);
private setSelectedItems;
private selectRange;
/**
* Get the selection status of an item.
* An item that is not selected is `indeterminate` when some of its selectable descendants are selected.
* @param {TreeViewItemId} itemId The id of the item to get the selection status of.
* @returns {TreeViewItemSelectionStatus} The selection status of the item.
*/
private getItemSelection;
buildPublicAPI: () => {
getItemSelection: (itemId: TreeViewItemId) => TreeViewItemSelectionStatus;
setItemSelection: ({
itemId,
event,
keepExistingSelection,
shouldBeSelected
}: {
itemId: string;
event?: React.SyntheticEvent | null;
shouldBeSelected?: boolean;
keepExistingSelection?: boolean;
}) => void;
};
/**
* Select the items added below a selected parent when the selection propagates to the descendants.
* @param {TreeViewItemId | null} parentId The id of the item the new items were added to.
* @param {TreeViewItemId[]} newItemIds The ids of the items that were just added.
*/
propagateSelectionToNewItems: (parentId: TreeViewItemId | null, newItemIds: TreeViewItemId[]) => void;
/**
* Select or deselect an item.
* @param {object} parameters The parameters of the method.
* @param {TreeViewItemId} parameters.itemId The id of the item to select or deselect.
* @param {React.SyntheticEvent} parameters.event The DOM event that triggered the change.
* @param {boolean} parameters.keepExistingSelection If `true`, the other already selected items will remain selected, otherwise, they will be deselected. This parameter is only relevant when `multiSelect` is `true`
* @param {boolean | undefined} parameters.shouldBeSelected If `true` the item will be selected. If `false` the item will be deselected. If not defined, the item's selection status will be toggled.
*/
setItemSelection: ({
itemId,
event,
keepExistingSelection,
shouldBeSelected
}: {
itemId: string;
event?: React.SyntheticEvent | null;
shouldBeSelected?: boolean;
keepExistingSelection?: boolean;
}) => void;
/**
* Select all the navigable items in the tree.
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
*/
selectAllNavigableItems: (event: React.SyntheticEvent) => void;
/**
* Expand the current selection range up to the given item.
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
* @param {TreeViewItemId} itemId The id of the item to expand the selection to.
*/
expandSelectionRange: (event: React.SyntheticEvent, itemId: string) => void;
/**
* Expand the current selection range from the first navigable item to the given item.
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
* @param {TreeViewItemId} itemId The id of the item up to which the selection range should be expanded.
*/
selectRangeFromStartToItem: (event: React.SyntheticEvent, itemId: string) => void;
/**
* Expand the current selection range from the given item to the last navigable item.
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
* @param {TreeViewItemId} itemId The id of the item from which the selection range should be expanded.
*/
selectRangeFromItemToEnd: (event: React.SyntheticEvent, itemId: string) => void;
/**
* Update the selection when navigating with ArrowUp / ArrowDown keys.
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
* @param {TreeViewItemId} currentItemId The id of the active item before the keyboard navigation.
* @param {TreeViewItemId} nextItemId The id of the active item after the keyboard navigation.
*/
selectItemFromArrowNavigation: (event: React.SyntheticEvent, currentItem: string, nextItem: string) => void;
}
export declare function getLookupFromArray(array: string[]): {
[itemId: string]: true;
};