@handaotech-design/bom 0.0.51 → 0.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -276,9 +276,28 @@ function getDepth(key: string): number {
276
276
  return parentKeys!.length + 1
277
277
  }
278
278
 
279
+ function getParentNodes(key: string): TreeNodeWithMeta[] {
280
+ const parentKeys = getParentKeys(key)
281
+ if (!parentKeys?.length) {
282
+ return []
283
+ }
284
+ return parentKeys.map(k => keyToNodeMap.value.get(k)).filter(Boolean) as TreeNodeWithMeta[]
285
+ }
286
+
287
+ function getPath(key: string): TreeNodeWithMeta[] {
288
+ const node = keyToNodeMap.value.get(key)
289
+ if (!node) {
290
+ return []
291
+ }
292
+ const parents = getParentNodes(key)
293
+ return [...parents, node]
294
+ }
295
+
279
296
  defineExpose({
280
297
  updateTreeWithPreservedState,
281
298
  getParentKeys,
299
+ getParentNodes,
300
+ getPath,
282
301
  getDepth,
283
302
  })
284
303
 
@@ -332,7 +351,7 @@ async function _loadData(node: EventDataNode) {
332
351
  <a-tree
333
352
  ref="treeRef"
334
353
  :height="treeContainerHeight"
335
- :tree-data="displayTreeData"
354
+ :tree-data="displayTreeData as any"
336
355
  :expanded-keys="expandedKeys"
337
356
  :auto-expand-parent="autoExpandParent"
338
357
  :block-node="true"
@@ -8,6 +8,7 @@ import HdLeftRight from '../left-right/index'
8
8
  import HdBomTree from '../bom-tree/index'
9
9
 
10
10
  const props = defineProps<Props>()
11
+ const emit = defineEmits(['select'])
11
12
  const COMPONENT_NAME = 'HdBomWorkbench'
12
13
  const treeRef = ref()
13
14
  defineOptions({
@@ -24,9 +25,9 @@ interface Props {
24
25
  loadData?: (node: BomNode, eventNode?: EventDataNode) => Promise<BomNode[]>
25
26
  }
26
27
  const selectedNode = ref<BomNode>()
27
-
28
28
  async function onSelected(data: BomNode) {
29
29
  selectedNode.value = data
30
+ emit('select', data)
30
31
  }
31
32
 
32
33
  watch(
@@ -276,9 +276,28 @@ function getDepth(key: string): number {
276
276
  return parentKeys!.length + 1
277
277
  }
278
278
 
279
+ function getParentNodes(key: string): TreeNodeWithMeta[] {
280
+ const parentKeys = getParentKeys(key)
281
+ if (!parentKeys?.length) {
282
+ return []
283
+ }
284
+ return parentKeys.map(k => keyToNodeMap.value.get(k)).filter(Boolean) as TreeNodeWithMeta[]
285
+ }
286
+
287
+ function getPath(key: string): TreeNodeWithMeta[] {
288
+ const node = keyToNodeMap.value.get(key)
289
+ if (!node) {
290
+ return []
291
+ }
292
+ const parents = getParentNodes(key)
293
+ return [...parents, node]
294
+ }
295
+
279
296
  defineExpose({
280
297
  updateTreeWithPreservedState,
281
298
  getParentKeys,
299
+ getParentNodes,
300
+ getPath,
282
301
  getDepth,
283
302
  })
284
303
 
@@ -332,7 +351,7 @@ async function _loadData(node: EventDataNode) {
332
351
  <a-tree
333
352
  ref="treeRef"
334
353
  :height="treeContainerHeight"
335
- :tree-data="displayTreeData"
354
+ :tree-data="displayTreeData as any"
336
355
  :expanded-keys="expandedKeys"
337
356
  :auto-expand-parent="autoExpandParent"
338
357
  :block-node="true"
@@ -8,6 +8,7 @@ import HdLeftRight from '../left-right/index'
8
8
  import HdBomTree from '../bom-tree/index'
9
9
 
10
10
  const props = defineProps<Props>()
11
+ const emit = defineEmits(['select'])
11
12
  const COMPONENT_NAME = 'HdBomWorkbench'
12
13
  const treeRef = ref()
13
14
  defineOptions({
@@ -24,9 +25,9 @@ interface Props {
24
25
  loadData?: (node: BomNode, eventNode?: EventDataNode) => Promise<BomNode[]>
25
26
  }
26
27
  const selectedNode = ref<BomNode>()
27
-
28
28
  async function onSelected(data: BomNode) {
29
29
  selectedNode.value = data
30
+ emit('select', data)
30
31
  }
31
32
 
32
33
  watch(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handaotech-design/bom",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "exports": {