tree.d.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. isLeaf?: boolean,
  8. children?: TreeNode[]
  9. }
  10. export interface RenderContent {
  11. /**
  12. * Render function for a specific node
  13. *
  14. * @param h The render function
  15. * @param data The data object containing the specific node
  16. */
  17. (h: CreateElement, data: { node: TreeNode }): VNode
  18. }
  19. export interface FilterNodeMethod {
  20. /**
  21. * Filter method for each node
  22. *
  23. * @param value The query string
  24. * @param data The original data object
  25. * @param node Tree node
  26. */
  27. (value: string, data: TreeNode, node: any): boolean
  28. }
  29. /** Tree Component */
  30. export declare class ElTree extends ElementUIComponent {
  31. /** Tree data */
  32. data: TreeNode[]
  33. /** Text displayed when data is void */
  34. emptyText: string
  35. /** Unique identity key name for nodes, its value should be unique across the whole tree */
  36. nodeKey: string
  37. /** Configuration options, see the following table */
  38. props: object
  39. /** Method for loading subtree data */
  40. load: (node: TreeNode, resolve: Function) => void
  41. /** Render function for tree node */
  42. renderContent: RenderContent
  43. /** Whether current node is highlighted */
  44. highlightCurrent: boolean
  45. /** Whether to expand all nodes by default */
  46. defaultExpandAll: boolean
  47. /** 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. */
  48. expandOnClickNode: boolean
  49. /** Whether to expand father node when a child node is expanded */
  50. autoExpandParent: boolean
  51. /** Array of keys of initially expanded nodes */
  52. defaultExpandedKeys: any[]
  53. /** Whether node is selectable */
  54. showCheckbox: boolean
  55. /** Whether checked state of a node not affects its father and child nodes when show-checkbox is true */
  56. checkStrictly: boolean
  57. /** Array of keys of initially checked nodes */
  58. defaultCheckedKeys: any[]
  59. /** This function will be executed on each node when use filter method. If return false, tree node will be hidden. */
  60. filterNodeMethod: FilterNodeMethod
  61. /** Whether only one node among the same level can be expanded at one time */
  62. accordion: boolean
  63. /** Horizontal indentation of nodes in adjacent levels in pixels */
  64. indent: number
  65. /**
  66. * Filter all tree nodes.Ffiltered nodes will be hidden
  67. *
  68. * @param value The value to be used as first parameter for `filter-node-method`
  69. */
  70. filter (value: any): void
  71. /**
  72. * If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes
  73. *
  74. * @param subnodes If the `subnodes` is `true`, it only returns the currently selected array of sub-nodes
  75. */
  76. getCheckedNodes (leafOnly?: boolean): TreeNode[]
  77. /**
  78. * Set certain nodes to be checked. Only works when `node-key` is assigned
  79. *
  80. * @param nodes An array of nodes to be checked
  81. * @param leafOnly If the parameter is true, it only returns the currently selected array of sub-nodes
  82. */
  83. setCheckedNodes (nodes: TreeNode[], leafOnly?: boolean): void
  84. /**
  85. * If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes' keys
  86. *
  87. * @param subnodes If the `subnodes` is `true`, it only returns the currently selected array of sub-nodes
  88. */
  89. getCheckedKeys (leafOnly?: boolean): any[]
  90. /**
  91. * Set certain nodes to be checked. Only works when `node-key` is assigned
  92. *
  93. * @param keys An array of node's keys to be checked
  94. * @param leafOnly If the parameter is true, it only returns the currently selected array of sub-nodes
  95. */
  96. setCheckedKeys (keys: any[], leafOnly?: boolean): void
  97. /**
  98. * Set node to be checked or not. Only works when `node-key` is assigned
  99. *
  100. * @param data Node's key or data to be checked
  101. * @param checked Indicating the node checked or not
  102. * @param deep Indicating whether to checked state deeply or not
  103. */
  104. setChecked (data: TreeNode | any, checked: boolean, deep: boolean): void
  105. /**
  106. * Return the highlight node's key (null if no node is highlighted)
  107. */
  108. getCurrentKey (): any
  109. /**
  110. * Set highlighted node by key, only works when node-key is assigned
  111. *
  112. * @param key The node's key to be highlighted
  113. */
  114. setCurrentKey (key: any): void
  115. /**
  116. * Return the highlight node (null if no node is highlighted)
  117. */
  118. getCurrentNode (): TreeNode
  119. /**
  120. * Set highlighted node, only works when node-key is assigned
  121. *
  122. * @param node The node to be highlighted
  123. */
  124. setCurrentNode (node: TreeNode): void
  125. }