hy-virtual-tree 1.1.33 → 1.1.35

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.1.35
4
+
5
+ _2025-09-24_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)添加setCheckedKeys和setCheckedNodes传参校验
9
+
3
10
  ### 1.1.33
4
11
 
5
12
  _2025-09-20_
package/dist/index.js CHANGED
@@ -1032,6 +1032,10 @@ function useCheck(props, tree) {
1032
1032
  };
1033
1033
  }
1034
1034
  function setCheckedKeys(keys, isBusiness = false) {
1035
+ if (!Array.isArray(keys)) {
1036
+ console.warn('setCheckedKeys请传入数组');
1037
+ return;
1038
+ }
1035
1039
  const { type } = props.rowSelection;
1036
1040
  checkedKeys.clear();
1037
1041
  indeterminateKeys.clear();
@@ -1108,6 +1112,10 @@ function useCheck(props, tree) {
1108
1112
  }
1109
1113
  }
1110
1114
  function setCheckedNodes(data, isBusiness = false) {
1115
+ if (!Array.isArray(data)) {
1116
+ console.warn('setCheckedNodes请传入数组');
1117
+ return;
1118
+ }
1111
1119
  const { type } = props.rowSelection;
1112
1120
  checkedKeys.clear();
1113
1121
  indeterminateKeys.clear();
@@ -1550,7 +1558,7 @@ function updateUserTree(tree, data, config) {
1550
1558
  const userMap = tree.userMap || new Map();
1551
1559
  data.forEach((v) => {
1552
1560
  const userList = userMap.get(v.id);
1553
- if (!userList.length)
1561
+ if (!userList || !userList?.length)
1554
1562
  return;
1555
1563
  userList.forEach((node) => {
1556
1564
  const target = tree.treeNodeMap.get(node.key);
@@ -1575,7 +1583,7 @@ function updateCsTree(tree, data, config) {
1575
1583
  const csMap = tree.csMap || new Map();
1576
1584
  data.forEach((v) => {
1577
1585
  const csList = csMap.get(v.id);
1578
- if (!csList.length)
1586
+ if (!csList || !csList?.length)
1579
1587
  return;
1580
1588
  csList.forEach((node) => {
1581
1589
  const target = tree.treeNodeMap.get(node.key);
@@ -2261,7 +2269,7 @@ class VirtualTree {
2261
2269
  continue;
2262
2270
  let count = isCountFiler ? 0 : target.data.count;
2263
2271
  let total = isTotalFiler ? 0 : target.data.total;
2264
- if (isCountFiler || isTotalFiler) {
2272
+ if ((isCountFiler || isTotalFiler) && target.children) {
2265
2273
  for (let i = 0; i < target.children.length; i++) {
2266
2274
  const item = target.children[i];
2267
2275
  count =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "1.1.33",
3
+ "version": "1.1.35",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -65,8 +65,5 @@
65
65
  "hy-virtual-tree"
66
66
  ],
67
67
  "author": "sailor-lin",
68
- "license": "MIT",
69
- "engines": {
70
- "node": ">=20.8.1"
71
- }
68
+ "license": "MIT"
72
69
  }