UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 1.81 kB
{"version":3,"file":"util.mjs","sources":["../../../../../../../packages/components/tree/src/model/util.ts"],"sourcesContent":["import type Node from './node'\nimport type { TreeEmits } from '../tree'\nimport type { RootTreeType, TreeKey, TreeNodeData } from '../tree.type'\n\nexport const NODE_KEY = '$treeNodeId'\n\nexport const markNodeData = function (\n node: Node,\n data: TreeNodeData | null\n): void {\n if (!data || data[NODE_KEY]) return\n Object.defineProperty(data, NODE_KEY, {\n value: node.id,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nexport const getNodeKey = (key: TreeKey | undefined, data: TreeNodeData) =>\n data?.[key || NODE_KEY]\n\nexport const handleCurrentChange = (\n store: RootTreeType['store'],\n emit: TreeEmits,\n setCurrent: () => void\n) => {\n const preCurrentNode = store.value.currentNode\n setCurrent()\n const currentNode = store.value.currentNode\n if (preCurrentNode === currentNode) return\n\n emit('current-change', currentNode ? currentNode.data : null, currentNode)\n}\n"],"names":[],"mappings":"AAIO,MAAM,QAAW,GAAA,cAAA;AAEX,MAAA,YAAA,GAAe,SAC1B,IAAA,EACA,IACM,EAAA;AACN,EAAI,IAAA,CAAC,QAAQ,IAAK,CAAA,QAAA,CAAA;AAAW,IAAA,OAAA;AAC7B,EAAO,MAAA,CAAA,cAAA,CAAe,MAAM,QAAU,EAAA;AAAA,IACpC,OAAO,IAAK,CAAA,EAAA;AAAA,IACZ,UAAY,EAAA,KAAA;AAAA,IACZ,YAAc,EAAA,KAAA;AAAA,IACd,QAAU,EAAA,KAAA;AAAA,GACX,CAAA,CAAA;AACH,EAAA;AAEO,MAAM,UAAa,GAAA,CAAC,GAA0B,EAAA,IAAA,KACnD,6BAAO,GAAO,IAAA,QAAA,EAAA;AAET,MAAM,mBAAsB,GAAA,CACjC,KACA,EAAA,IAAA,EACA,UACG,KAAA;AACH,EAAM,MAAA,cAAA,GAAiB,MAAM,KAAM,CAAA,WAAA,CAAA;AACnC,EAAW,UAAA,EAAA,CAAA;AACX,EAAM,MAAA,WAAA,GAAc,MAAM,KAAM,CAAA,WAAA,CAAA;AAChC,EAAA,IAAI,cAAmB,KAAA,WAAA;AAAa,IAAA,OAAA;AAEpC,EAAA,IAAA,CAAK,gBAAkB,EAAA,WAAA,GAAc,WAAY,CAAA,IAAA,GAAO,MAAM,WAAW,CAAA,CAAA;AAC3E;;;;"}