hy-virtual-tree 1.1.53 → 1.1.55

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,20 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.1.55
4
+
5
+ _2025-12-26_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)修复在过滤状态下选中逻辑bug
9
+ (2)修复在过滤后选中状态没有动态更新问题
10
+
11
+ ### 1.1.54
12
+
13
+ _2025-12-25_
14
+
15
+ - 扩展[VirtualTree] 功能
16
+ (1)新增 getCheckedBusinessNodes 方法
17
+
3
18
  ### 1.1.53
4
19
 
5
20
  _2025-12-23_
package/dist/index.js CHANGED
@@ -1116,9 +1116,13 @@ const isCheckLeaf = (config, node) => {
1116
1116
  return node.isLeaf;
1117
1117
  return node.data.dataType === 3 ? true : node.isLeaf;
1118
1118
  };
1119
- function useCheck(props, tree) {
1119
+ function useCheck(props, instance) {
1120
+ const tree = instance._tree;
1120
1121
  const checkedKeys = new Set();
1121
1122
  let indeterminateKeys = new Set();
1123
+ const isHiddenNode = (key) => {
1124
+ return instance._hiddenNodeKeySet.has(key) || tree.hiddenNodeKeySet.has(key);
1125
+ };
1122
1126
  const updateCheckedKeys = () => {
1123
1127
  const { checkStrictly } = props.rowSelection;
1124
1128
  if (!tree || checkStrictly) {
@@ -1132,7 +1136,7 @@ function useCheck(props, tree) {
1132
1136
  if (!nodes)
1133
1137
  continue;
1134
1138
  nodes.forEach((node) => {
1135
- if (tree.hiddenNodeKeySet.has(node.key) || !isShowSelect(props, node))
1139
+ if (isHiddenNode(node.key) || !isShowSelect(props, node))
1136
1140
  return;
1137
1141
  if (node.children && !isCheckLeaf(props, node)) {
1138
1142
  let allChecked = true;
@@ -1142,7 +1146,7 @@ function useCheck(props, tree) {
1142
1146
  const key = childNode.key;
1143
1147
  // 通道需要循环处理
1144
1148
  if (childNode.data.dataType !== DataType.CHANNEL &&
1145
- (tree.hiddenNodeKeySet.has(key) || !isShowSelect(props, node))) {
1149
+ (isHiddenNode(key) || !isShowSelect(props, node))) {
1146
1150
  continue;
1147
1151
  }
1148
1152
  if ((props.businessConfig?.showOnlineState && childNode.data.deviceStatus !== DeviceStatus.OFF_LINE) ||
@@ -1183,7 +1187,7 @@ function useCheck(props, tree) {
1183
1187
  };
1184
1188
  const isChecked = (node) => checkedKeys.has(node.key);
1185
1189
  const isIndeterminate = (node) => indeterminateKeys.has(node.key);
1186
- const toggleCheckbox = (node, isChecked, nodeClick = true, immediateUpdate = true, checkOnDbclick = false, hiddenNodeKeySet = new Set()) => {
1190
+ const toggleCheckbox = (node, isChecked, nodeClick = true, immediateUpdate = true, checkOnDbclick = false) => {
1187
1191
  const { type, checkStrictly, cancelable } = props.rowSelection;
1188
1192
  const checkedKeySet = checkedKeys;
1189
1193
  // 单选
@@ -1200,7 +1204,7 @@ function useCheck(props, tree) {
1200
1204
  // 多选
1201
1205
  const toggle = (node, checked) => {
1202
1206
  // 对隐藏的节点不做处理
1203
- if (hiddenNodeKeySet.has(node.key) || (tree.hiddenNodeKeySet.has(node.key) && nodeClick))
1207
+ if (instance._hiddenNodeKeySet.has(node.key) || (tree.hiddenNodeKeySet.has(node.key) && nodeClick))
1204
1208
  return;
1205
1209
  checkedKeySet[checked ? 'add' : 'delete'](node.key);
1206
1210
  const children = node.children;
@@ -1251,6 +1255,9 @@ function useCheck(props, tree) {
1251
1255
  function getCheckedNodes(leafOnly = false) {
1252
1256
  return getChecked(leafOnly).checkedNodes;
1253
1257
  }
1258
+ function getCheckedBusinessNodes(leafOnly = false) {
1259
+ return getChecked(leafOnly).checkedBusinessNodes || [];
1260
+ }
1254
1261
  function getHalfCheckedKeys() {
1255
1262
  return getHalfChecked().halfCheckedKeys;
1256
1263
  }
@@ -1508,7 +1515,6 @@ function useCheck(props, tree) {
1508
1515
  if (!isIndeterminate(node) || props.rowSelection.checkStrictly || !node.children?.length)
1509
1516
  return !isChecked(node);
1510
1517
  const { isAllSelect } = getNodeCheckInfo(node.children || []);
1511
- console.log('isAllSelect', isAllSelect);
1512
1518
  return !isAllSelect;
1513
1519
  }
1514
1520
  // 获取当前项选中信息
@@ -1518,7 +1524,7 @@ function useCheck(props, tree) {
1518
1524
  let isCanAllSelect = true;
1519
1525
  let isAllSelect = true;
1520
1526
  for (const node of children) {
1521
- if (isChecked(node))
1527
+ if (isChecked(node) || isHiddenNode(node.key))
1522
1528
  continue;
1523
1529
  // 严格模式 或 非严格模式下没有子元素
1524
1530
  if (checkStrictly || (!checkStrictly && !node.children?.length)) {
@@ -1559,6 +1565,7 @@ function useCheck(props, tree) {
1559
1565
  afterNodeCheck,
1560
1566
  getCheckedKeys,
1561
1567
  getCheckedNodes,
1568
+ getCheckedBusinessNodes,
1562
1569
  getHalfCheckedKeys,
1563
1570
  getHalfCheckedNodes,
1564
1571
  setChecked,
@@ -8886,6 +8893,7 @@ class VirtualTree {
8886
8893
  getChecked;
8887
8894
  getCheckedKeys;
8888
8895
  getCheckedNodes;
8896
+ getCheckedBusinessNodes;
8889
8897
  setChecked;
8890
8898
  setCheckedKeys;
8891
8899
  setCheckedNodes;
@@ -9138,14 +9146,15 @@ class VirtualTree {
9138
9146
  this._flattenTree = this._genereateFlattenTree();
9139
9147
  const { checkedKeys, updateCheckedKeys, isIndeterminate, isChecked, toggleCheckbox, getChecked,
9140
9148
  // afterNodeCheck,
9141
- getCheckedKeys, getCheckedNodes,
9149
+ getCheckedKeys, getCheckedNodes, getCheckedBusinessNodes,
9142
9150
  // getHalfCheckedKeys,
9143
9151
  // getHalfCheckedNodes,
9144
- setChecked, setCheckedKeys, setCheckedNodes, getSwitchCheckedValue, } = useCheck(config, this._tree);
9152
+ setChecked, setCheckedKeys, setCheckedNodes, getSwitchCheckedValue, } = useCheck(config, this);
9145
9153
  this._updateCheckedKeys = updateCheckedKeys;
9146
9154
  this.getChecked = getChecked;
9147
9155
  this.getCheckedKeys = getCheckedKeys;
9148
9156
  this.getCheckedNodes = getCheckedNodes;
9157
+ this.getCheckedBusinessNodes = getCheckedBusinessNodes;
9149
9158
  this.setChecked = (key, isChecked, isBusiness) => {
9150
9159
  setChecked(key, isChecked, isBusiness);
9151
9160
  this._refreshRender();
@@ -9280,7 +9289,7 @@ class VirtualTree {
9280
9289
  onClick: () => {
9281
9290
  if (getDisabled(config, item))
9282
9291
  return;
9283
- toggleCheckbox(item, getSwitchCheckedValue(item), true, true, false, this._hiddenNodeKeySet);
9292
+ toggleCheckbox(item, getSwitchCheckedValue(item), true, true, false);
9284
9293
  this.refresh();
9285
9294
  }
9286
9295
  }).mount(el);
@@ -9780,6 +9789,7 @@ class VirtualTree {
9780
9789
  this._hiddenExpandIconKeySet = hiddenExpandIconKeySet;
9781
9790
  this._hiddenNodeKeySet = hiddenNodeKeySet;
9782
9791
  this._isForceHiddenExpandIcon = isForceHiddenExpandIcon;
9792
+ this._updateCheckedKeys();
9783
9793
  this._refreshVirtualScroll();
9784
9794
  }
9785
9795
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "1.1.53",
3
+ "version": "1.1.55",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",