| 1 |
/// <reference types="react" /> |
| 2 |
import { TreeViewCheckProps } from './TreeViewListItem'; |
| 3 |
/** Properties that make up a tree view data item. These properties should be passed in as an |
| 4 |
* object to one of the various tree view component properties which accept TreeViewDataItem as |
| 5 |
* a type. |
| 6 |
*/ |
| 7 |
export interface TreeViewDataItem { |
| 8 |
/** Action of a tree view item, which can be either a button or dropdown component. */ |
| 9 |
action?: React.ReactNode; |
| 10 |
/** Additional properties of the tree view item badge. */ |
| 11 |
badgeProps?: any; |
| 12 |
/** Additional properties of the tree view item checkbox. */ |
| 13 |
checkProps?: TreeViewCheckProps; |
| 14 |
/** Child nodes of a tree view item. */ |
| 15 |
children?: TreeViewDataItem[]; |
| 16 |
/** Optional prop for a custom badge. */ |
| 17 |
customBadgeContent?: React.ReactNode; |
| 18 |
/** Flag indicating if node is expanded by default. */ |
| 19 |
defaultExpanded?: boolean; |
| 20 |
/** Expanded icon of a tree view item. */ |
| 21 |
expandedIcon?: React.ReactNode; |
| 22 |
/** Flag indicating if a tree view item has a badge. */ |
| 23 |
hasBadge?: boolean; |
| 24 |
/** Flag indicating if a tree view item has a checkbox. */ |
| 25 |
hasCheckbox?: boolean; |
| 26 |
/** Default icon of a tree view item. */ |
| 27 |
icon?: React.ReactNode; |
| 28 |
/** ID of a tree view item. */ |
| 29 |
id?: string; |
| 30 |
/** Internal content of a tree view item. */ |
| 31 |
name: React.ReactNode; |
| 32 |
/** Title of a tree view item. Only used in compact presentations. */ |
| 33 |
title?: React.ReactNode; |
| 34 |
/** Flag indicating if the tree view item is disabled. */ |
| 35 |
isDisabled?: boolean; |
| 36 |
/** Flag indicating if the tree view item toggle is disabled. */ |
| 37 |
isToggleDisabled?: boolean; |
| 38 |
} |
| 39 |
/** The main tree view component. */ |
| 40 |
export interface TreeViewProps { |
| 41 |
/** Active items of tree view. */ |
| 42 |
activeItems?: TreeViewDataItem[]; |
| 43 |
/** Sets the expanded state on all tree nodes, overriding default behavior and current |
| 44 |
* internal state. |
| 45 |
*/ |
| 46 |
allExpanded?: boolean; |
| 47 |
/** A text string that sets the accessible name of the tree view list. Either this or the aria-labelledby property must |
| 48 |
* be passed in. |
| 49 |
*/ |
| 50 |
'aria-label'?: string; |
| 51 |
/** A space separated list of element id's that sets the accessible name of the tree view list. Either |
| 52 |
* this or the aria-label property must be passed in. |
| 53 |
*/ |
| 54 |
'aria-labelledby'?: string; |
| 55 |
/** Class to add if not passed a parentItem property. */ |
| 56 |
className?: string; |
| 57 |
/** Comparison function for determining active items. */ |
| 58 |
compareItems?: (item: TreeViewDataItem, itemToCheck: TreeViewDataItem) => boolean; |
| 59 |
/** Data of the tree view. */ |
| 60 |
data: TreeViewDataItem[]; |
| 61 |
/** Sets the default expanded behavior. */ |
| 62 |
defaultAllExpanded?: boolean; |
| 63 |
/** Icon for all expanded node items. */ |
| 64 |
expandedIcon?: React.ReactNode; |
| 65 |
/** Flag indicating if all nodes in the tree view should have badges. */ |
| 66 |
hasBadges?: boolean; |
| 67 |
/** Flag indicating if all nodes in the tree view should have checkboxes. */ |
| 68 |
hasCheckboxes?: boolean; |
| 69 |
/** Flag indicating if the tree view has guide lines. */ |
| 70 |
hasGuides?: boolean; |
| 71 |
/** Flag indicating if the tree view is nested. */ |
| 72 |
isNested?: boolean; |
| 73 |
/** Flag indicating that tree nodes should be independently selectable, even when having |
| 74 |
* children. |
| 75 |
*/ |
| 76 |
hasSelectableNodes?: boolean; |
| 77 |
/** Icon for all leaf or unexpanded node items. */ |
| 78 |
icon?: React.ReactNode; |
| 79 |
/** ID of the tree view. */ |
| 80 |
id?: string; |
| 81 |
/** Flag indicating whether multiple nodes can be selected in the tree view. This will also set the |
| 82 |
* aria-multiselectable attribute on the tree view list which is required to be true when multiple selection is intended. |
| 83 |
* Can only be applied to the root tree view list. |
| 84 |
*/ |
| 85 |
isMultiSelectable?: boolean; |
| 86 |
/** Callback for item checkbox selection. */ |
| 87 |
onCheck?: (event: React.ChangeEvent<HTMLInputElement>, item: TreeViewDataItem, parentItem: TreeViewDataItem) => void; |
| 88 |
/** Callback for item selection. */ |
| 89 |
onSelect?: (event: React.MouseEvent, item: TreeViewDataItem, parentItem: TreeViewDataItem) => void; |
| 90 |
/** Callback for expanding a node with children. */ |
| 91 |
onExpand?: (event: React.MouseEvent, item: TreeViewDataItem, parentItem: TreeViewDataItem) => void; |
| 92 |
/** Callback for collapsing a node with children. */ |
| 93 |
onCollapse?: (event: React.MouseEvent, item: TreeViewDataItem, parentItem: TreeViewDataItem) => void; |
| 94 |
/** Internal. Parent item of a tree view list item. */ |
| 95 |
parentItem?: TreeViewDataItem; |
| 96 |
/** Toolbar to display above the tree view. */ |
| 97 |
toolbar?: React.ReactNode; |
| 98 |
/** Flag indicating the tree view should utilize memoization to help render large data sets. |
| 99 |
* Setting this property requires that the activeItems property is passed an array containing |
| 100 |
* every node in the selected item's path. |
| 101 |
*/ |
| 102 |
useMemo?: boolean; |
| 103 |
/** Variant presentation styles for the tree view. */ |
| 104 |
variant?: 'default' | 'compact' | 'compactNoBackground'; |
| 105 |
/** Flag indicating whether a tree view has animations. This will always render |
| 106 |
* nested tree view items rather than dynamically rendering them. This prop will be removed in |
| 107 |
* the next breaking change release in favor of defaulting to always-rendered items. |
| 108 |
*/ |
| 109 |
hasAnimations?: boolean; |
| 110 |
} |
| 111 |
export declare const TreeView: React.FunctionComponent<TreeViewProps>; |
| 112 |
//# sourceMappingURL=TreeView.d.ts.map |