element-plus
Version:
A Component Library for Vue 3
1 lines • 1.75 kB
Source Map (JSON)
{"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,QAAA,GAAW;AAEjB,MAAM,YAAA,GAAe,SAC1B,IAAA,EACA,IAAA,EACM;AACN,EAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,CAAK,QAAQ,CAAA,EAAG;AAC7B,EAAA,MAAA,CAAO,cAAA,CAAe,MAAM,QAAA,EAAU;AAAA,IACpC,OAAO,IAAA,CAAK,EAAA;AAAA,IACZ,UAAA,EAAY,KAAA;AAAA,IACZ,YAAA,EAAc,KAAA;AAAA,IACd,QAAA,EAAU;AAAA,GACX,CAAA;AACH;AAEO,MAAM,UAAA,GAAa,CAAC,GAAA,EAA0B,IAAA,KACnD,6BAAO,GAAA,IAAO,QAAA;AAET,MAAM,mBAAA,GAAsB,CACjC,KAAA,EACA,IAAA,EACA,UAAA,KACG;AACH,EAAA,MAAM,cAAA,GAAiB,MAAM,KAAA,CAAM,WAAA;AACnC,EAAA,UAAA,EAAW;AACX,EAAA,MAAM,WAAA,GAAc,MAAM,KAAA,CAAM,WAAA;AAChC,EAAA,IAAI,mBAAmB,WAAA,EAAa;AAEpC,EAAA,IAAA,CAAK,gBAAA,EAAkB,WAAA,GAAc,WAAA,CAAY,IAAA,GAAO,MAAM,WAAW,CAAA;AAC3E;;;;"}