import * as React from 'react'; import { TreeItemSelectedInterface, TreeViewItemInterface } from './TreeViewContext'; import { TreeViewSelectable } from './types'; export type { TreeItemSelectedInterface }; export interface TreeViewApi { selectItem({ itemId, checkedStatus, }: Pick): void; selectAll(): void; clearAll(): void; showMore(): void; showLess(): void; expandAll(): void; collapseAll(): void; addItem(item: TreeViewItemInterface): void; } export interface UseTreeViewProps { /** * The ref object that allows TreeView manipulation. * Actions available: * selectItem({ itemId, checkedStatus }: Pick): void - action that allows to change item selection, * selectAll(): void - action that allows to select all items, * clearAll(): void - action that allows to unselect all items. * showMore(): void - action that gets called when a tree has hidden items and they get expanded. * showLess(): void - action that gets called when a tree has hidden items and they get collapsed. * expandAll(): void - action that allows to expand all items. * collapseAll(): void - action that allows to collapse all items. */ apiRef?: React.MutableRefObject; /** * Text for aria-label attribute for the tree. * If there is no visible name for the element you can reference, use aria-label to provide the user with a recognizable accessible name. * It's required to use either `ariaLabel` OR `ariaLabelledBy`. */ ariaLabel?: string; /** * Text for aria-labelledby attribute for the tree. * If there is visible text that labels an element, use aria-labelledby. * It's required to use either `ariaLabel` OR `ariaLabelledBy`. */ ariaLabelledBy?: string; /** * Only affects if selectable mode is TreeViewSelectable.multi. * Determines if the parent checkbox will get selected when the user selects all its children checkboxes. * When checkParents is enabled, the TreeView displays the indeterminate state of the parent checkboxes too. * @default true */ checkParents?: boolean; /** * Only affects if selectable mode is TreeViewSelectable.multi. * Determines if the child checkboxes get selected when the user selects parent checkbox. * @default true */ checkChildren?: boolean; children?: React.ReactNode[] | React.ReactNode; /** * Expand icon styles. */ expandIconStyles?: ExpandIconStylesProps; /** * If true, every item is disabled * @default false */ isDisabled?: boolean; /** * Array list of itemIds of items that should be expanded by default. * For all items expanded, provide an array with all the indexes * @default [] (no items expanded) */ initialExpandedItems?: Array; isInverse?: boolean; /** * If false, top-level items will not be selectable in multi-select mode. * Their checkboxes will be hidden, and they will only function as expandable groups. * @default true */ isTopLevelSelectable?: boolean; /** * Action that fires when an item is expanded or collapsed * Return an array of itemIds of items that are expanded * Example: ['item0', 'item1', 'item3'] */ onExpandedChange?: (event: React.SyntheticEvent, expandedItems: Array) => void; /** * Action that fires when an item is selected * Return an array of objects. * Example: [ {itemId: 'item0', checkedStatus: IndeterminateCheckboxStatus.indeterminate}, {itemId: 'item0-child', checkedStatus: IndeterminateCheckboxStatus.checked} ] */ onSelectedItemChange?: (selectedItems: Array) => void; /** * Array list of itemIds of items that should be selected when the component renders * * @default [] (no items selected) */ preselectedItems?: Array; /** * How many items can be selected in the tree view: single, multi, off * @default TreeViewSelectable.single */ selectable?: TreeViewSelectable; /** * When enabled (default), parent items (folders) can be selected in TreeViewSelectable.single mode. * When disabled, parent items will only expand/collapse on click and won't trigger selection or onClick. * Child items (leaves) can always be selected regardless of this setting. * @default true */ selectParents?: boolean; /** * @internal */ testId?: string; /** * If true, TreeView will render guide lines for expanded items with children. */ hasGuideLines?: boolean; } interface ExpandIconStylesProps { /** * Size for the expand/collapse icon. * @default 24 */ size?: number; /** * Color for the expand/collapse icon. */ color?: string; } export declare function useTreeView(props: UseTreeViewProps): { selectionContextValue: { items: TreeViewItemInterface[]; itemsById: Map; selectedItems: TreeViewItemInterface[]; selectItem: ({ itemId, checkedStatus, }: Pick & Partial>) => void; onSelectedItemChange: (selectedItems: TreeItemSelectedInterface[]) => void; selectable: TreeViewSelectable; itemToFocus: string; }; expansionContextValue: { expandedSet: Set; handleExpandedChange: (event: React.SyntheticEvent, itemId: string | string[]) => void; onExpandedChange: (event: React.SyntheticEvent, expandedItems: string[]) => void; initialExpandedItems: any[]; bulkExpansionRef: React.MutableRefObject<"expand" | "collapse">; }; configContextValue: { hasIcons: boolean; selectable: TreeViewSelectable; checkParents: boolean; checkChildren: boolean; isTopLevelSelectable: boolean; selectParents: boolean; expandIconStyles: ExpandIconStylesProps; hasGuideLines: boolean; registerTreeItem: (refArray: React.MutableRefObject[]>, ref: React.MutableRefObject) => void; treeItemRefArray: React.MutableRefObject[]>; }; }; export declare type UseTreeViewReturn = ReturnType;