virtual-tree.mjs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import '../../../utils/index.mjs';
  2. import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
  3. import { mutable } from '../../../utils/typescript.mjs';
  4. import { iconPropType } from '../../../utils/vue/icon.mjs';
  5. const ROOT_TREE_INJECTION_KEY = Symbol();
  6. const EMPTY_NODE = {
  7. key: -1,
  8. level: -1,
  9. data: {}
  10. };
  11. var TreeOptionsEnum = /* @__PURE__ */ ((TreeOptionsEnum2) => {
  12. TreeOptionsEnum2["KEY"] = "id";
  13. TreeOptionsEnum2["LABEL"] = "label";
  14. TreeOptionsEnum2["CHILDREN"] = "children";
  15. TreeOptionsEnum2["DISABLED"] = "disabled";
  16. return TreeOptionsEnum2;
  17. })(TreeOptionsEnum || {});
  18. var SetOperationEnum = /* @__PURE__ */ ((SetOperationEnum2) => {
  19. SetOperationEnum2["ADD"] = "add";
  20. SetOperationEnum2["DELETE"] = "delete";
  21. return SetOperationEnum2;
  22. })(SetOperationEnum || {});
  23. const treeProps = buildProps({
  24. data: {
  25. type: definePropType(Array),
  26. default: () => mutable([])
  27. },
  28. emptyText: {
  29. type: String
  30. },
  31. height: {
  32. type: Number,
  33. default: 200
  34. },
  35. props: {
  36. type: definePropType(Object),
  37. default: () => mutable({
  38. children: "children" /* CHILDREN */,
  39. label: "label" /* LABEL */,
  40. disabled: "disabled" /* DISABLED */,
  41. value: "id" /* KEY */
  42. })
  43. },
  44. highlightCurrent: {
  45. type: Boolean,
  46. default: false
  47. },
  48. showCheckbox: {
  49. type: Boolean,
  50. default: false
  51. },
  52. defaultCheckedKeys: {
  53. type: definePropType(Array),
  54. default: () => mutable([])
  55. },
  56. checkStrictly: {
  57. type: Boolean,
  58. default: false
  59. },
  60. defaultExpandedKeys: {
  61. type: definePropType(Array),
  62. default: () => mutable([])
  63. },
  64. indent: {
  65. type: Number,
  66. default: 16
  67. },
  68. icon: {
  69. type: iconPropType
  70. },
  71. expandOnClickNode: {
  72. type: Boolean,
  73. default: true
  74. },
  75. checkOnClickNode: {
  76. type: Boolean,
  77. default: false
  78. },
  79. currentNodeKey: {
  80. type: definePropType([String, Number])
  81. },
  82. accordion: {
  83. type: Boolean,
  84. default: false
  85. },
  86. filterMethod: {
  87. type: definePropType(Function)
  88. },
  89. perfMode: {
  90. type: Boolean,
  91. default: true
  92. }
  93. });
  94. const treeNodeProps = buildProps({
  95. node: {
  96. type: definePropType(Object),
  97. default: () => mutable(EMPTY_NODE)
  98. },
  99. expanded: {
  100. type: Boolean,
  101. default: false
  102. },
  103. checked: {
  104. type: Boolean,
  105. default: false
  106. },
  107. indeterminate: {
  108. type: Boolean,
  109. default: false
  110. },
  111. showCheckbox: {
  112. type: Boolean,
  113. default: false
  114. },
  115. disabled: {
  116. type: Boolean,
  117. default: false
  118. },
  119. current: {
  120. type: Boolean,
  121. default: false
  122. },
  123. hiddenExpandIcon: {
  124. type: Boolean,
  125. default: false
  126. }
  127. });
  128. const treeNodeContentProps = buildProps({
  129. node: {
  130. type: definePropType(Object),
  131. required: true
  132. }
  133. });
  134. const NODE_CLICK = "node-click";
  135. const NODE_EXPAND = "node-expand";
  136. const NODE_COLLAPSE = "node-collapse";
  137. const CURRENT_CHANGE = "current-change";
  138. const NODE_CHECK = "check";
  139. const NODE_CHECK_CHANGE = "check-change";
  140. const NODE_CONTEXTMENU = "node-contextmenu";
  141. const treeEmits = {
  142. [NODE_CLICK]: (data, node, e) => data && node && e,
  143. [NODE_EXPAND]: (data, node) => data && node,
  144. [NODE_COLLAPSE]: (data, node) => data && node,
  145. [CURRENT_CHANGE]: (data, node) => data && node,
  146. [NODE_CHECK]: (data, checkedInfo) => data && checkedInfo,
  147. [NODE_CHECK_CHANGE]: (data, checked) => data && typeof checked === "boolean",
  148. [NODE_CONTEXTMENU]: (event, data, node) => event && data && node
  149. };
  150. const treeNodeEmits = {
  151. click: (node, e) => !!(node && e),
  152. toggle: (node) => !!node,
  153. check: (node, checked) => node && typeof checked === "boolean"
  154. };
  155. export { CURRENT_CHANGE, NODE_CHECK, NODE_CHECK_CHANGE, NODE_CLICK, NODE_COLLAPSE, NODE_CONTEXTMENU, NODE_EXPAND, ROOT_TREE_INJECTION_KEY, SetOperationEnum, TreeOptionsEnum, treeEmits, treeNodeContentProps, treeNodeEmits, treeNodeProps, treeProps };
  156. //# sourceMappingURL=virtual-tree.mjs.map