{"version":3,"file":"virtual-tree.js","sources":["../../../../../../packages/components/tree-v2/src/virtual-tree.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n iconPropType,\n mutable,\n} from '@element-plus/utils'\nimport type { CheckboxValueType } from '@element-plus/components/checkbox'\nimport type { InjectionKey } from 'vue'\nimport type { TreeNodeData } from '@element-plus/components/tree/src/tree.type'\nimport type {\n CheckedInfo,\n FilterMethod,\n TreeContext,\n TreeData,\n TreeKey,\n TreeNode,\n TreeOptionProps,\n} from './types'\n\n// constants\nexport const ROOT_TREE_INJECTION_KEY: InjectionKey = Symbol()\nconst EMPTY_NODE = {\n key: -1,\n level: -1,\n data: {},\n} as const\n\n// enums\nexport enum TreeOptionsEnum {\n KEY = 'id',\n LABEL = 'label',\n CHILDREN = 'children',\n DISABLED = 'disabled',\n}\n\nexport const enum SetOperationEnum {\n ADD = 'add',\n DELETE = 'delete',\n}\n\nconst itemSize = {\n type: Number,\n default: 26,\n}\n\n// props\nexport const treeProps = buildProps({\n data: {\n type: definePropType(Array),\n default: () => mutable([] as const),\n },\n emptyText: {\n type: String,\n },\n height: {\n type: Number,\n default: 200,\n },\n props: {\n type: definePropType(Object),\n default: () =>\n mutable({\n children: TreeOptionsEnum.CHILDREN,\n label: TreeOptionsEnum.LABEL,\n disabled: TreeOptionsEnum.DISABLED,\n value: TreeOptionsEnum.KEY,\n } as const),\n },\n highlightCurrent: {\n type: Boolean,\n default: false,\n },\n showCheckbox: {\n type: Boolean,\n default: false,\n },\n defaultCheckedKeys: {\n type: definePropType(Array),\n default: () => mutable([] as const),\n },\n // Whether checked state of a node not affects its father and\n // child nodes when show-checkbox is true\n checkStrictly: {\n type: Boolean,\n default: false,\n },\n defaultExpandedKeys: {\n type: definePropType(Array),\n default: () => mutable([] as const),\n },\n indent: {\n type: Number,\n default: 16,\n },\n itemSize,\n icon: {\n type: iconPropType,\n },\n expandOnClickNode: {\n type: Boolean,\n default: true,\n },\n checkOnClickNode: {\n type: Boolean,\n default: false,\n },\n currentNodeKey: {\n type: definePropType([String, Number]),\n },\n // TODO need to optimization\n accordion: {\n type: Boolean,\n default: false,\n },\n filterMethod: {\n type: definePropType(Function),\n },\n // Performance mode will increase memory usage, but scrolling will be smoother\n perfMode: {\n type: Boolean,\n default: true,\n },\n} as const)\n\nexport const treeNodeProps = buildProps({\n node: {\n type: definePropType(Object),\n default: () => mutable(EMPTY_NODE),\n },\n expanded: {\n type: Boolean,\n default: false,\n },\n checked: {\n type: Boolean,\n default: false,\n },\n indeterminate: {\n type: Boolean,\n default: false,\n },\n showCheckbox: {\n type: Boolean,\n default: false,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n current: {\n type: Boolean,\n default: false,\n },\n hiddenExpandIcon: {\n type: Boolean,\n default: false,\n },\n itemSize,\n} as const)\n\nexport const treeNodeContentProps = buildProps({\n node: {\n type: definePropType(Object),\n required: true,\n },\n} as const)\n\n// emits\nexport const NODE_CLICK = 'node-click'\nexport const NODE_DROP = 'node-drop'\nexport const NODE_EXPAND = 'node-expand'\nexport const NODE_COLLAPSE = 'node-collapse'\nexport const CURRENT_CHANGE = 'current-change'\nexport const NODE_CHECK = 'check'\nexport const NODE_CHECK_CHANGE = 'check-change'\nexport const NODE_CONTEXTMENU = 'node-contextmenu'\n\nexport const treeEmits = {\n [NODE_CLICK]: (data: TreeNodeData, node: TreeNode, e: MouseEvent) =>\n data && node && e,\n [NODE_DROP]: (data: TreeNodeData, node: TreeNode, e: DragEvent) =>\n data && node && e,\n [NODE_EXPAND]: (data: TreeNodeData, node: TreeNode) => data && node,\n [NODE_COLLAPSE]: (data: TreeNodeData, node: TreeNode) => data && node,\n [CURRENT_CHANGE]: (data: TreeNodeData, node: TreeNode) => data && node,\n [NODE_CHECK]: (data: TreeNodeData, checkedInfo: CheckedInfo) =>\n data && checkedInfo,\n [NODE_CHECK_CHANGE]: (data: TreeNodeData, checked: boolean) =>\n data && typeof checked === 'boolean',\n [NODE_CONTEXTMENU]: (evt: Event, data: TreeNodeData, node: TreeNode) =>\n evt && data && node,\n}\n\nexport const treeNodeEmits = {\n click: (node: TreeNode, e: MouseEvent) => !!(node && e),\n drop: (node: TreeNode, e: DragEvent) => !!(node && e),\n toggle: (node: TreeNode) => !!node,\n check: (node: TreeNode, checked: CheckboxValueType) =>\n node && typeof checked === 'boolean',\n}\n"],"names":["buildProps","definePropType","mutable","iconPropType"],"mappings":";;;;;;;;;AAMY,MAAC,uBAAuB,GAAG,MAAM,GAAG;AAChD,MAAM,UAAU,GAAG;AACnB,EAAE,GAAG,EAAE,CAAC,CAAC;AACT,EAAE,KAAK,EAAE,CAAC,CAAC;AACX,EAAE,IAAI,EAAE,EAAE;AACV,CAAC,CAAC;AACQ,IAAC,eAAe,mBAAmB,CAAC,CAAC,gBAAgB,KAAK;AACpE,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;AACjC,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACtC,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC5C,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC5C,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC,EAAE,eAAe,IAAI,EAAE,EAAE;AAChB,IAAC,gBAAgB,mBAAmB,CAAC,CAAC,iBAAiB,KAAK;AACtE,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;AACnC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACzC,EAAE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,EAAE,gBAAgB,IAAI,EAAE,EAAE;AAC3B,MAAM,QAAQ,GAAG;AACjB,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,OAAO,EAAE,EAAE;AACb,CAAC,CAAC;AACU,MAAC,SAAS,GAAGA,kBAAU,CAAC;AACpC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAEC,sBAAc,CAA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