UNPKG

@fluentui/react-northstar

Version:
51 lines (50 loc) 1.93 kB
import { ObjectShorthandValue } from '../../../types'; import { TreeItemProps } from '../TreeItem'; export interface FlatTreeItem { /** * Also in TreeItemProps. * The index of the item among its siblings. Count starts at 1. */ index: number; /** * Also in TreeItemProps. * Level of the tree/subtree that contains this item. */ level: number; /** * Also in TreeItemProps. * true if the tree item is expanded (indicating tree item has subtree). * when tree item has no subtree, expanded is undefined */ expanded?: boolean; /** * Also in TreeItemProps. * parent id of the tree item. For the top level tree items, parent is undefined */ parent?: string; /** * Also in TreeItemProps. * Size of the tree/subtree that contains this item. */ treeSize: number; /** true if the tree item has subtree, indicating childrenIds are not undefined */ hasSubtree: boolean; /** children ids of the tree item. For leaf tree item, childrenIds is undefined */ childrenIds?: string[]; /** Shorthand props for the current item */ item: ObjectShorthandValue<TreeItemProps>; /** * when selected=true, the tree item is fully selected, indicating all its descendents are fully selected; * when selected=false, the tree item is not selected, indicating none of its descendents is selected; * when selected='indeterminate', only part of the tree item's descendents are selected */ selected?: boolean | 'indeterminate'; } export declare type FlatTree = Record<string, FlatTreeItem>; /** * @returns returns the flattened tree, and an array of all visible tree item ids in a Depth First order. */ export declare function flattenTree(items: ObjectShorthandValue<TreeItemProps>[], activeItemIds: string[], selectedItemIds: string[]): { flatTree: FlatTree; visibleItemIds: string[]; };