hy-virtual-tree 2.0.5 → 2.0.7

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,18 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.0.7
4
+
5
+ _2026-03-16_
6
+
7
+ (1)优化tooltip销毁时的效果
8
+ (2)setChecked、setCheckedKeys、setCheckedNodes 方法新增 isForce 参数,可以不考虑隐藏逻辑,强制选中
9
+
10
+ ### 2.0.6
11
+
12
+ _2026-03-13_
13
+
14
+ (1)修复元素销毁时,tooltip显示时无法跟随销毁
15
+
3
16
  ### 2.0.5
4
17
 
5
18
  _2026-03-13_
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* hy-virtual-tree v2.0.5 */
1
+ /* hy-virtual-tree v2.0.7 */
2
2
  import './svg_bundle.js';
3
3
  const isString = (e) => typeof e === 'string';
4
4
  const isNumber = (e) => typeof e === 'number';
@@ -7165,19 +7165,18 @@ class Tooltip {
7165
7165
  hide() {
7166
7166
  this._openTimer && clearTimeout(this._openTimer);
7167
7167
  this._closeTimer && clearTimeout(this._closeTimer);
7168
+ if (!this._el)
7169
+ return;
7170
+ const el = this._el;
7168
7171
  this._closeTimer = setTimeout(() => {
7169
- if (!this._el)
7170
- return;
7171
- this._el.classList.remove('hy-tooltip-show');
7172
+ el.classList.remove('hy-tooltip-show');
7172
7173
  this._closeTimer && clearTimeout(this._closeTimer);
7173
7174
  this._closeTimer = setTimeout(() => {
7174
- if (!this._el)
7175
- return;
7176
- this._el.style.setProperty('top', '-10000px');
7177
- this._el.style.setProperty('left', '-10000px');
7178
- if (!this._el.parentElement)
7175
+ el.style.setProperty('top', '-10000px');
7176
+ el.style.setProperty('left', '-10000px');
7177
+ if (!el.parentElement)
7179
7178
  return;
7180
- this._el.parentElement.removeChild(this._el);
7179
+ el.parentElement.removeChild(el);
7181
7180
  }, 200);
7182
7181
  }, 200);
7183
7182
  }
@@ -8232,7 +8231,7 @@ function useCheck(props, instance) {
8232
8231
  };
8233
8232
  const isChecked = (node) => checkedKeys.has(node.key);
8234
8233
  const isIndeterminate = (node) => indeterminateKeys.has(node.key);
8235
- const toggleCheckbox = (node, isChecked, nodeClick = true, immediateUpdate = true, checkOnDbclick = false) => {
8234
+ const toggleCheckbox = (node, isChecked, nodeClick = true, immediateUpdate = true, checkOnDbclick = false, isForce) => {
8236
8235
  const { type, checkStrictly, cancelable } = props.rowSelection;
8237
8236
  const checkedKeySet = checkedKeys;
8238
8237
  // 单选
@@ -8250,9 +8249,13 @@ function useCheck(props, instance) {
8250
8249
  }
8251
8250
  // 多选
8252
8251
  const toggle = (node, checked) => {
8253
- // 对隐藏的节点不做处理
8254
- if (instance._hiddenNodeKeySet.has(node.key) || (tree.hiddenNodeKeySet.has(node.key) && nodeClick))
8255
- return;
8252
+ // 是否强制选中
8253
+ if (!isForce) {
8254
+ // 对隐藏的节点不做处理
8255
+ if (instance._hiddenNodeKeySet.has(node.key) || (tree.hiddenNodeKeySet.has(node.key) && nodeClick))
8256
+ return;
8257
+ }
8258
+ console.log('???', checked);
8256
8259
  checkedKeySet[checked ? 'add' : 'delete'](node.key);
8257
8260
  const children = node.children;
8258
8261
  if ((!checkStrictly || checkOnDbclick) && children) {
@@ -8336,7 +8339,9 @@ function useCheck(props, instance) {
8336
8339
  checkedBusinessNodes.push(getNodeData(node));
8337
8340
  }
8338
8341
  // 通道类型业务选中
8339
- else if (business && [Business.CHANNEL, Business.PLAN_GROUP_DEVICE].includes(business) && [DataType.DEVICE, DataType.CHANNEL].includes(data.dataType)) {
8342
+ else if (business &&
8343
+ [Business.CHANNEL, Business.PLAN_GROUP_DEVICE].includes(business) &&
8344
+ [DataType.DEVICE, DataType.CHANNEL].includes(data.dataType)) {
8340
8345
  // 开启通道可选中
8341
8346
  if (props.businessConfig?.isShowChannelSelect) {
8342
8347
  // 通道类型 或 没有通道的设备
@@ -8392,7 +8397,7 @@ function useCheck(props, instance) {
8392
8397
  halfCheckedKeys
8393
8398
  };
8394
8399
  }
8395
- function setCheckedKeys(keys, isBusiness = false) {
8400
+ function setCheckedKeys(keys, isBusiness = false, isForce = false) {
8396
8401
  if (!Array.isArray(keys)) {
8397
8402
  console.warn('setCheckedKeys请传入数组');
8398
8403
  return;
@@ -8403,16 +8408,16 @@ function useCheck(props, instance) {
8403
8408
  if (type === 'radio' && keys.length > 1) {
8404
8409
  keys = [keys[0]];
8405
8410
  }
8406
- _setCheckedKeys(keys, isBusiness);
8411
+ _setCheckedKeys(keys, isBusiness, isForce);
8407
8412
  }
8408
- function setChecked(key, isChecked, isBusiness = false) {
8413
+ function setChecked(key, isChecked, isBusiness = false, isForce = false) {
8409
8414
  if (!tree || !isShowSelect(props))
8410
8415
  return;
8411
8416
  const { treeNodeMap, deviceMap, channelMap, teamMap, userMap, csMap } = tree;
8412
8417
  if (!isBusiness || !props.business) {
8413
8418
  const node = treeNodeMap.get(key);
8414
8419
  if (node) {
8415
- toggleCheckbox(node, isChecked, false);
8420
+ toggleCheckbox(node, isChecked, false, true, true, isForce);
8416
8421
  }
8417
8422
  return;
8418
8423
  }
@@ -8443,10 +8448,10 @@ function useCheck(props, instance) {
8443
8448
  for (const node of nodeList) {
8444
8449
  if (!isShowSelect(props, node))
8445
8450
  continue;
8446
- toggleCheckbox(node, isChecked, false);
8451
+ toggleCheckbox(node, isChecked, false, true, false, isForce);
8447
8452
  }
8448
8453
  }
8449
- function _setCheckedKeys(keys = [], isBusiness = false) {
8454
+ function _setCheckedKeys(keys = [], isBusiness = false, isForce = false) {
8450
8455
  if (!tree)
8451
8456
  return;
8452
8457
  const { treeNodeMap, deviceMap, channelMap, teamMap, userMap, csMap } = tree;
@@ -8457,7 +8462,7 @@ function useCheck(props, instance) {
8457
8462
  if (!isBusiness || !props.business) {
8458
8463
  const node = treeNodeMap.get(key);
8459
8464
  if (node && !isChecked(node) && isShowSelect(props, node)) {
8460
- toggleCheckbox(node, true, false, false);
8465
+ toggleCheckbox(node, true, false, false, false, isForce);
8461
8466
  }
8462
8467
  continue;
8463
8468
  }
@@ -8488,13 +8493,13 @@ function useCheck(props, instance) {
8488
8493
  }
8489
8494
  for (const node of nodeList) {
8490
8495
  if (node && !isChecked(node) && isShowSelect(props, node)) {
8491
- toggleCheckbox(node, true, false, false);
8496
+ toggleCheckbox(node, true, false, false, false, isForce);
8492
8497
  }
8493
8498
  }
8494
8499
  }
8495
8500
  updateCheckedKeys();
8496
8501
  }
8497
- function setCheckedNodes(data, isBusiness = false) {
8502
+ function setCheckedNodes(data, isBusiness = false, isForce = false) {
8498
8503
  if (!Array.isArray(data)) {
8499
8504
  console.warn('setCheckedNodes请传入数组');
8500
8505
  return;
@@ -8505,9 +8510,9 @@ function useCheck(props, instance) {
8505
8510
  if (type === 'radio' && data.length > 1) {
8506
8511
  data = [data[0]];
8507
8512
  }
8508
- _setCheckedNodes(data, isBusiness);
8513
+ _setCheckedNodes(data, isBusiness, isForce);
8509
8514
  }
8510
- function _setCheckedNodes(data = [], isBusiness = false) {
8515
+ function _setCheckedNodes(data = [], isBusiness = false, isForce = false) {
8511
8516
  if (tree) {
8512
8517
  const { treeNodeMap, deviceMap, channelMap, teamMap, userMap, csMap } = tree;
8513
8518
  if (!isShowSelect(props) || !treeNodeMap || !data.length)
@@ -8522,7 +8527,7 @@ function useCheck(props, instance) {
8522
8527
  if (!isBusiness || !props.business) {
8523
8528
  const node = treeNodeMap.get(key);
8524
8529
  if (node && !isChecked(node) && isShowSelect(props, node)) {
8525
- toggleCheckbox(node, true, false, false);
8530
+ toggleCheckbox(node, true, false, false, false, isForce);
8526
8531
  }
8527
8532
  continue;
8528
8533
  }
@@ -8560,7 +8565,7 @@ function useCheck(props, instance) {
8560
8565
  }
8561
8566
  for (const node of nodeList) {
8562
8567
  if (node && !isChecked(node) && isShowSelect(props, node)) {
8563
- toggleCheckbox(node, true, false, false);
8568
+ toggleCheckbox(node, true, false, false, false, isForce);
8564
8569
  }
8565
8570
  }
8566
8571
  }
@@ -9707,16 +9712,16 @@ class VirtualTree {
9707
9712
  this.getCheckedKeys = getCheckedKeys;
9708
9713
  this.getCheckedNodes = getCheckedNodes;
9709
9714
  this.getCheckedBusinessNodes = getCheckedBusinessNodes;
9710
- this.setChecked = (key, isChecked, isBusiness) => {
9711
- setChecked(key, isChecked, isBusiness);
9715
+ this.setChecked = (key, isChecked, isBusiness, isForce) => {
9716
+ setChecked(key, isChecked, isBusiness, isForce);
9712
9717
  this._refreshRender();
9713
9718
  };
9714
- this.setCheckedKeys = (keys, isBusiness) => {
9715
- setCheckedKeys(keys, isBusiness);
9719
+ this.setCheckedKeys = (keys, isBusiness, isForce) => {
9720
+ setCheckedKeys(keys, isBusiness, isForce);
9716
9721
  this._refreshRender();
9717
9722
  };
9718
- this.setCheckedNodes = (data, isBusiness) => {
9719
- setCheckedNodes(data, isBusiness);
9723
+ this.setCheckedNodes = (data, isBusiness, isForce) => {
9724
+ setCheckedNodes(data, isBusiness, isForce);
9720
9725
  this._refreshRender();
9721
9726
  };
9722
9727
  this.setRowSelection = (rowSelection) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",