tree.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { CreateElement, VNode } from 'vue'
  2. import { ElementUIComponent } from './component'
  3. /** The node of the tree */
  4. export interface TreeNode {
  5. id?: any,
  6. label?: string,
  7. children?: TreeNode[]
  8. }
  9. export interface RenderContent {
  10. /**
  11. * Render function for a specific node
  12. *
  13. * @param h The render function
  14. * @param data The data object containing the specific node
  15. */
  16. (h: CreateElement, data: { node: TreeNode }): VNode
  17. }
  18. export interface FilterNodeMethod {
  19. // TODO: complete type and description here
  20. (value: any, data: TreeNode, node: any): boolean
  21. }
  22. /** Tree Component */
  23. export declare class ElTree extends ElementUIComponent {
  24. /** Tree data */
  25. data: TreeNode[]
  26. /** Text displayed when data is void */
  27. emptyText: string
  28. /** Unique identity key name for nodes, its value should be unique across the whole tree */
  29. nodeKey: string
  30. /** Configuration options, see the following table */
  31. props: object
  32. /** Method for loading subtree data */
  33. load: (node: TreeNode, resolve) => void
  34. /** Render function for tree node */
  35. renderContent: RenderContent
  36. /** Whether current node is highlighted */
  37. highlightCurrent: boolean
  38. /** Key of current node, a set only prop */
  39. currentNodeKey: string | number
  40. /** Whether to expand all nodes by default */
  41. defaultExpandAll: boolean
  42. /** Whether to expand or collapse node when clicking on the node. If false, then expand or collapse node only when clicking on the arrow icon. */
  43. expandOnClickNode: boolean
  44. /** Whether to expand father node when a child node is expanded */
  45. autoExpandParent: boolean
  46. /** Array of keys of initially expanded nodes */
  47. defaultExpandedKeys: any[]
  48. /** Whether node is selectable */
  49. showCheckbox: boolean
  50. /** Whether checked state of a node not affects its father and child nodes when show-checkbox is true */
  51. checkStrictly: boolean
  52. /** Array of keys of initially checked nodes */
  53. defaultCheckedKeys: any[]
  54. /** This function will be executed on each node when use filter method. If return false, tree node will be hidden. */
  55. filterNodeMethod: FilterNodeMethod
  56. /** Whether only one node among the same level can be expanded at one time */
  57. accordion: boolean
  58. /** Horizontal indentation of nodes in adjacent levels in pixels */
  59. indent: number
  60. /**
  61. * Filter all tree nodes.Ffiltered nodes will be hidden
  62. *
  63. * @param value The value to be used as first parameter for `filter-node-method`
  64. */
  65. filter (value: any): void
  66. /**
  67. * If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes
  68. *
  69. * @param subnodes If the `subnodes` is `true`, it only returns the currently selected array of sub-nodes
  70. */
  71. getCheckedNodes (leafOnly?: boolean): TreeNode[]
  72. /**
  73. * Set certain nodes to be checked. Only works when `node-key` is assigned
  74. *
  75. * @param nodes An array of nodes to be checked
  76. * @param leafOnly If the parameter is true, it only returns the currently selected array of sub-nodes
  77. */
  78. setCheckedNodes (nodes: TreeNode[], leafOnly?: boolean): void
  79. /**
  80. * If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes' keys
  81. *
  82. * @param subnodes If the `subnodes` is `true`, it only returns the currently selected array of sub-nodes
  83. */
  84. getCheckedKeys (leafOnly?: boolean): any[]
  85. /**
  86. * Set certain nodes to be checked. Only works when `node-key` is assigned
  87. *
  88. * @param keys An array of node's keys to be checked
  89. * @param leafOnly If the parameter is true, it only returns the currently selected array of sub-nodes
  90. */
  91. setCheckedKeys (keys: any[], leafOnly?: boolean): void
  92. /**
  93. * Set node to be checked or not. Only works when `node-key` is assigned
  94. *
  95. * @param data Node's key or data to be checked
  96. * @param checked Indicating the node checked or not
  97. * @param deep Indicating whether to checked state deeply or not
  98. */
  99. setChecked (data: TreeNode | any, checked: boolean, deep: boolean)
  100. }