@splicetree/adapter-vue 1.1.0 → 3.0.0

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.
package/dist/index.d.ts CHANGED
@@ -2,8 +2,11 @@ import { Ref, ShallowRef, WritableComputedRef } from "vue";
2
2
  import { SpliceTreeData, SpliceTreeData as SpliceTreeData$1, SpliceTreeInstance, SpliceTreeInstance as SpliceTreeInstance$1, SpliceTreeNode, SpliceTreeNode as SpliceTreeNode$1, UseSpliceTreeOptions, UseSpliceTreeOptions as UseSpliceTreeOptions$1 } from "@splicetree/core";
3
3
 
4
4
  //#region src/index.d.ts
5
- interface UseSpliceTreeReturn<T extends SpliceTreeData$1 = SpliceTreeData$1> extends Omit<SpliceTreeInstance$1<T>, 'items'> {
5
+ interface UseSpliceTreeReturn<T extends SpliceTreeData$1 = SpliceTreeData$1> extends Omit<SpliceTreeInstance$1<T>, 'items' | 'selectedKeys'> {
6
6
  items: ShallowRef<SpliceTreeNode$1<T>[]>;
7
+ selectedKeys: ShallowRef<string[]>;
8
+ /** 原始 Set 引用(当启用 selectable 插件时存在) */
9
+ selectedKeysSet?: Set<string>;
7
10
  }
8
11
  /**
9
12
  * Vue 3 适配器
package/dist/index.js CHANGED
@@ -461,12 +461,15 @@ function createSpliceTree(data, options = {}) {
461
461
  function useSpliceTree(data, options = {}) {
462
462
  const api = shallowRef();
463
463
  const items = shallowRef(api.value?.items?.() ?? []);
464
+ const selectedKeys = shallowRef([]);
464
465
  const createTree = () => {
465
466
  api.value = createSpliceTree(toValue(data), options);
466
467
  api.value.events.on("visibility", () => {
467
468
  items.value = api.value.items();
469
+ if (api.value?.selectedKeys instanceof Set) selectedKeys.value = Array.from(api.value.selectedKeys);
468
470
  });
469
471
  items.value = api.value.items();
472
+ if (api.value?.selectedKeys instanceof Set) selectedKeys.value = Array.from(api.value.selectedKeys);
470
473
  };
471
474
  createTree();
472
475
  watch(() => toValue(data), () => {
@@ -477,7 +480,9 @@ function useSpliceTree(data, options = {}) {
477
480
  });
478
481
  return {
479
482
  ...api.value,
480
- items
483
+ items,
484
+ selectedKeys,
485
+ selectedKeysSet: api.value?.selectedKeys
481
486
  };
482
487
  }
483
488
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@splicetree/adapter-vue",
3
3
  "type": "module",
4
- "version": "1.1.0",
4
+ "version": "3.0.0",
5
5
  "author": {
6
6
  "email": "michael.cocova@gmail.com",
7
7
  "name": "Michael Cocova"
@@ -30,7 +30,7 @@
30
30
  "unplugin-vue": "^7.1.0",
31
31
  "vue": "^3.0.0",
32
32
  "vue-tsc": "^3.1.5",
33
- "@splicetree/core": "1.1.0"
33
+ "@splicetree/core": "3.0.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"