tree.d.ts 4.6 KB

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